V 0.7
This commit is contained in:
17
Scripts/Game.meta
Normal file
17
Scripts/Game.meta
Normal file
@@ -0,0 +1,17 @@
|
||||
MetaFileClass {
|
||||
Name "{B92491157EA3E4AD}Scripts/Game"
|
||||
Configurations {
|
||||
FolderResourceClass PC {
|
||||
}
|
||||
FolderResourceClass XBOX_ONE : PC {
|
||||
}
|
||||
FolderResourceClass XBOX_SERIES : PC {
|
||||
}
|
||||
FolderResourceClass PS4 : PC {
|
||||
}
|
||||
FolderResourceClass PS5 : PC {
|
||||
}
|
||||
FolderResourceClass HEADLESS : PC {
|
||||
}
|
||||
}
|
||||
}
|
||||
64
Scripts/Game/GTGAutorun/SCR_AutorunComponent.c
Normal file
64
Scripts/Game/GTGAutorun/SCR_AutorunComponent.c
Normal file
@@ -0,0 +1,64 @@
|
||||
[ComponentEditorProps(category: "GameScripted/Character", description: "Erlaubt automatisches Laufen/Rennen")]
|
||||
class SCR_AutorunComponentClass: ScriptComponentClass
|
||||
{
|
||||
}
|
||||
|
||||
class SCR_AutorunComponent: ScriptComponent
|
||||
{
|
||||
protected bool m_bIsAutorunEnabled = false;
|
||||
protected SCR_CharacterControllerComponent m_CharacterController;
|
||||
protected InputManager m_InputManager;
|
||||
|
||||
protected void OnAutorunPressed()
|
||||
{
|
||||
m_bIsAutorunEnabled = !m_bIsAutorunEnabled;
|
||||
}
|
||||
|
||||
protected void OnLifeStateChangedCallback()
|
||||
{
|
||||
m_bIsAutorunEnabled = false;
|
||||
}
|
||||
|
||||
protected void OnControlledByPlayerCallback(IEntity owner, bool controlled)
|
||||
{
|
||||
m_bIsAutorunEnabled = false;
|
||||
}
|
||||
|
||||
protected void OnPrepareControlsCallback(IEntity owner, ActionManager am, float dt, bool player)
|
||||
{
|
||||
if (!m_bIsAutorunEnabled)
|
||||
return;
|
||||
|
||||
// Autorun abbrechen, wenn: Kontext inaktiv, Karte offen oder Spieler bewegt sich manuell (W/S/A/D)
|
||||
if (!m_InputManager.IsContextActive("CharacterMovementContext") ||
|
||||
am.GetActionTriggered("GadgetMap") ||
|
||||
Math.AbsFloat(m_InputManager.GetActionValue("CharacterForward")) >= 0.75 ||
|
||||
Math.AbsFloat(m_InputManager.GetActionValue("CharacterRight")) >= 0.75)
|
||||
{
|
||||
m_bIsAutorunEnabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Bewegungswerte zwingen (Laufen + Rennen)
|
||||
m_InputManager.SetActionValue("CharacterForward", 1.0);
|
||||
m_InputManager.SetActionValue("CharacterSprint", 1.0);
|
||||
}
|
||||
|
||||
override void OnPostInit(IEntity owner)
|
||||
{
|
||||
m_CharacterController = SCR_CharacterControllerComponent.Cast(owner.FindComponent(SCR_CharacterControllerComponent));
|
||||
if (!m_CharacterController)
|
||||
{
|
||||
Print("[SCR_Autorun] Kein SCR_CharacterControllerComponent gefunden! Mod funktioniert nicht.", LogLevel.WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
void OnPrepareControls(IEntity owner, ActionManager am, float dt, bool player);
|
||||
typedef func OnPrepareControls;
|
||||
typedef ScriptInvokerBase<OnPrepareControls> OnPrepareControlsInvoker;
|
||||
|
||||
modded class SCR_CharacterControllerComponent
|
||||
{
|
||||
ref OnPrepareControlsInvoker m_OnPrepareControls = new OnPrepareControlsInvoker();
|
||||
|
||||
protected override void OnPrepareControls(IEntity owner, ActionManager am, float dt, bool player)
|
||||
{
|
||||
super.OnPrepareControls(owner, am, dt, player);
|
||||
m_OnPrepareControls.Invoke(owner, am, dt, player);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user