1.0.2
This commit is contained in:
@@ -6,12 +6,24 @@ class SCR_AutorunComponentClass: ScriptComponentClass
|
||||
class SCR_AutorunComponent: ScriptComponent
|
||||
{
|
||||
protected bool m_bIsAutorunEnabled = false;
|
||||
protected bool m_bWaitForKeyRelease = false; // Neu: Die Sicherung
|
||||
|
||||
protected SCR_CharacterControllerComponent m_CharacterController;
|
||||
protected InputManager m_InputManager;
|
||||
|
||||
protected void OnAutorunPressed()
|
||||
{
|
||||
m_bIsAutorunEnabled = !m_bIsAutorunEnabled;
|
||||
|
||||
// Wenn Autorun AN geht und der Spieler hält W bereits gedrückt...
|
||||
if (m_bIsAutorunEnabled && m_InputManager.GetActionValue("CharacterForward") > 0.5)
|
||||
{
|
||||
m_bWaitForKeyRelease = true; // ...Sicherung aktivieren!
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bWaitForKeyRelease = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnLifeStateChangedCallback()
|
||||
@@ -28,12 +40,22 @@ class SCR_AutorunComponent: ScriptComponent
|
||||
{
|
||||
if (!m_bIsAutorunEnabled)
|
||||
return;
|
||||
|
||||
float forwardInput = m_InputManager.GetActionValue("CharacterForward");
|
||||
float rightInput = m_InputManager.GetActionValue("CharacterRight");
|
||||
|
||||
// Autorun abbrechen, wenn: Kontext inaktiv, Karte offen oder Spieler bewegt sich manuell (W/S/A/D)
|
||||
// Wenn die Sicherung an ist und der Spieler W loslässt (Wert unter 0.5) -> Sicherung raus
|
||||
if (m_bWaitForKeyRelease && forwardInput < 0.5)
|
||||
{
|
||||
m_bWaitForKeyRelease = false;
|
||||
}
|
||||
|
||||
// Autorun abbrechen, wenn: Kontext inaktiv, Karte offen, A/D gedrückt,
|
||||
// oder W/S gedrückt (ABER W bricht nur ab, wenn die Sicherung draußen ist!)
|
||||
if (!m_InputManager.IsContextActive("CharacterMovementContext") ||
|
||||
am.GetActionTriggered("GadgetMap") ||
|
||||
Math.AbsFloat(m_InputManager.GetActionValue("CharacterForward")) >= 0.75 ||
|
||||
Math.AbsFloat(m_InputManager.GetActionValue("CharacterRight")) >= 0.75)
|
||||
Math.AbsFloat(rightInput) >= 0.75 ||
|
||||
(!m_bWaitForKeyRelease && Math.AbsFloat(forwardInput) >= 0.75))
|
||||
{
|
||||
m_bIsAutorunEnabled = false;
|
||||
return;
|
||||
@@ -55,10 +77,7 @@ class SCR_AutorunComponent: ScriptComponent
|
||||
|
||||
m_InputManager = GetGame().GetInputManager();
|
||||
|
||||
// Events abonnieren
|
||||
m_CharacterController.m_OnPrepareControls.Insert(OnPrepareControlsCallback);
|
||||
|
||||
// Action Listener (Der Name "SCR_Autorun" muss mit der Input-Config übereinstimmen!)
|
||||
m_InputManager.AddActionListener("SCR_Autorun", EActionTrigger.DOWN, OnAutorunPressed);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user