Follow mouse rotation in combat mode (#20433)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using Content.Shared.MouseRotator;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Targeting;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
@@ -41,6 +43,13 @@ namespace Content.Shared.CombatMode
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("isInCombatMode"), AutoNetworkedField]
|
||||
public bool IsInCombatMode;
|
||||
|
||||
/// <summary>
|
||||
/// Will add <see cref="MouseRotatorComponent"/> and <see cref="NoRotateOnMoveComponent"/>
|
||||
/// to entities with this flag enabled that enter combat mode, and vice versa for removal.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public bool ToggleMouseRotator = true;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("activeZone"), AutoNetworkedField]
|
||||
public TargetingZone ActiveZone;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.MouseRotator;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Targeting;
|
||||
using Robust.Shared.Network;
|
||||
@@ -30,6 +32,8 @@ public abstract class SharedCombatModeSystem : EntitySystem
|
||||
private void OnShutdown(EntityUid uid, CombatModeComponent component, ComponentShutdown args)
|
||||
{
|
||||
_actionsSystem.RemoveAction(uid, component.CombatToggleActionEntity);
|
||||
|
||||
SetMouseRotatorComponents(uid, false);
|
||||
}
|
||||
|
||||
private void OnActionPerform(EntityUid uid, CombatModeComponent component, ToggleCombatActionEvent args)
|
||||
@@ -76,6 +80,12 @@ public abstract class SharedCombatModeSystem : EntitySystem
|
||||
|
||||
if (component.CombatToggleActionEntity != null)
|
||||
_actionsSystem.SetToggled(component.CombatToggleActionEntity, component.IsInCombatMode);
|
||||
|
||||
// Change mouse rotator comps if flag is set
|
||||
if (!component.ToggleMouseRotator)
|
||||
return;
|
||||
|
||||
SetMouseRotatorComponents(entity, value);
|
||||
}
|
||||
|
||||
public virtual void SetActiveZone(EntityUid entity, TargetingZone zone,
|
||||
@@ -86,6 +96,20 @@ public abstract class SharedCombatModeSystem : EntitySystem
|
||||
|
||||
component.ActiveZone = zone;
|
||||
}
|
||||
|
||||
private void SetMouseRotatorComponents(EntityUid uid, bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
EnsureComp<MouseRotatorComponent>(uid);
|
||||
EnsureComp<NoRotateOnMoveComponent>(uid);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemComp<MouseRotatorComponent>(uid);
|
||||
RemComp<NoRotateOnMoveComponent>(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed partial class ToggleCombatActionEvent : InstantActionEvent { }
|
||||
|
||||
Reference in New Issue
Block a user