Remove combat mode component reference (#15206)

This commit is contained in:
DrSmugleaf
2023-04-08 13:16:48 -07:00
committed by GitHub
parent b4164e62b1
commit 34bcd042d1
29 changed files with 126 additions and 159 deletions

View File

@@ -1,46 +0,0 @@
using Content.Client.ContextMenu.UI;
using Content.Client.Verbs;
using Content.Shared.CombatMode;
using Content.Shared.Targeting;
using Robust.Client.Player;
using Robust.Client.UserInterface;
namespace Content.Client.CombatMode
{
[RegisterComponent]
[ComponentReference(typeof(SharedCombatModeComponent))]
public sealed class CombatModeComponent : SharedCombatModeComponent
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
public override bool IsInCombatMode
{
get => base.IsInCombatMode;
set
{
base.IsInCombatMode = value;
UpdateHud();
}
}
public override TargetingZone ActiveZone
{
get => base.ActiveZone;
set
{
base.ActiveZone = value;
UpdateHud();
}
}
private void UpdateHud()
{
if (Owner != _playerManager.LocalPlayer?.ControlledEntity)
{
return;
}
IoCManager.Resolve<IUserInterfaceManager>().GetUIController<ContextMenuUIController>().Close();
}
}
}

View File

@@ -12,27 +12,36 @@ namespace Content.Client.CombatMode
{ {
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
public event Action? LocalPlayerCombatModeUpdated;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<SharedCombatModeComponent, ComponentHandleState>(OnHandleState); SubscribeLocalEvent<CombatModeComponent, ComponentHandleState>(OnHandleState);
} }
private void OnHandleState(EntityUid uid, SharedCombatModeComponent component, ref ComponentHandleState args) private void OnHandleState(EntityUid uid, CombatModeComponent component, ref ComponentHandleState args)
{ {
if (args.Current is not CombatModeComponentState state) if (args.Current is not CombatModeComponentState state)
return; return;
component.IsInCombatMode = state.IsInCombatMode; component.IsInCombatMode = state.IsInCombatMode;
component.ActiveZone = state.TargetingZone; component.ActiveZone = state.TargetingZone;
UpdateHud(uid);
} }
public override void Shutdown() public override void Shutdown()
{ {
CommandBinds.Unregister<CombatModeSystem>(); CommandBinds.Unregister<CombatModeSystem>();
base.Shutdown(); base.Shutdown();
} }
private void OnTargetingZoneChanged(TargetingZone obj)
{
EntityManager.RaisePredictiveEvent(new CombatModeSystemMessages.SetTargetZoneMessage(obj));
}
public bool IsInCombatMode() public bool IsInCombatMode()
{ {
var entity = _playerManager.LocalPlayer?.ControlledEntity; var entity = _playerManager.LocalPlayer?.ControlledEntity;
@@ -43,9 +52,26 @@ namespace Content.Client.CombatMode
return IsInCombatMode(entity.Value); return IsInCombatMode(entity.Value);
} }
private void OnTargetingZoneChanged(TargetingZone obj) public override void SetInCombatMode(EntityUid entity, bool inCombatMode, CombatModeComponent? component = null)
{ {
EntityManager.RaisePredictiveEvent(new CombatModeSystemMessages.SetTargetZoneMessage(obj)); base.SetInCombatMode(entity, inCombatMode, component);
UpdateHud(entity);
}
public override void SetActiveZone(EntityUid entity, TargetingZone zone, CombatModeComponent? component = null)
{
base.SetActiveZone(entity, zone, component);
UpdateHud(entity);
}
private void UpdateHud(EntityUid entity)
{
if (entity != _playerManager.LocalPlayer?.ControlledEntity)
{
return;
}
LocalPlayerCombatModeUpdated?.Invoke();
} }
} }
} }

View File

@@ -1,8 +1,10 @@
using System.Threading; using System.Threading;
using Content.Client.CombatMode;
using Content.Client.Gameplay; using Content.Client.Gameplay;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers; using Robust.Client.UserInterface.Controllers;
using Timer = Robust.Shared.Timing.Timer; using Timer = Robust.Shared.Timing.Timer;
namespace Content.Client.ContextMenu.UI namespace Content.Client.ContextMenu.UI
{ {
/// <summary> /// <summary>
@@ -13,7 +15,7 @@ namespace Content.Client.ContextMenu.UI
/// <remarks> /// <remarks>
/// This largely involves setting up timers to open and close sub-menus when hovering over other menu elements. /// This largely involves setting up timers to open and close sub-menus when hovering over other menu elements.
/// </remarks> /// </remarks>
public sealed class ContextMenuUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState> public sealed class ContextMenuUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>, IOnSystemChanged<CombatModeSystem>
{ {
public static readonly TimeSpan HoverDelay = TimeSpan.FromSeconds(0.2); public static readonly TimeSpan HoverDelay = TimeSpan.FromSeconds(0.2);
@@ -206,5 +208,20 @@ namespace Content.Client.ContextMenu.UI
menu.InvalidateMeasure(); menu.InvalidateMeasure();
} }
private void OnCombatModeUpdated()
{
Close();
}
public void OnSystemLoaded(CombatModeSystem system)
{
system.LocalPlayerCombatModeUpdated += OnCombatModeUpdated;
}
public void OnSystemUnloaded(CombatModeSystem system)
{
system.LocalPlayerCombatModeUpdated -= OnCombatModeUpdated;
}
} }
} }

View File

@@ -1,5 +1,5 @@
using Content.Client.CombatMode;
using Content.Client.Gameplay; using Content.Client.Gameplay;
using Content.Shared.CombatMode;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Components;
using Content.Shared.StatusEffect; using Content.Shared.StatusEffect;

View File

@@ -1,15 +0,0 @@
using Content.Shared.CombatMode;
namespace Content.Server.CombatMode
{
/// <summary>
/// Stores whether an entity is in "combat mode"
/// This is used to differentiate between regular item interactions or
/// using *everything* as a weapon.
/// </summary>
[RegisterComponent]
[ComponentReference(typeof(SharedCombatModeComponent))]
public sealed class CombatModeComponent : SharedCombatModeComponent
{
}
}

View File

@@ -11,10 +11,10 @@ namespace Content.Server.CombatMode
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<SharedCombatModeComponent, ComponentGetState>(OnGetState); SubscribeLocalEvent<CombatModeComponent, ComponentGetState>(OnGetState);
} }
private void OnGetState(EntityUid uid, SharedCombatModeComponent component, ref ComponentGetState args) private void OnGetState(EntityUid uid, CombatModeComponent component, ref ComponentGetState args)
{ {
args.State = new CombatModeComponentState(component.IsInCombatMode, component.ActiveZone); args.State = new CombatModeComponentState(component.IsInCombatMode, component.ActiveZone);
} }

View File

@@ -1,6 +1,6 @@
using Content.Server.CombatMode;
using Content.Server.NPC.Components; using Content.Server.NPC.Components;
using Content.Server.NPC.Events; using Content.Server.NPC.Events;
using Content.Shared.CombatMode;
using Content.Shared.NPC; using Content.Shared.NPC;
using Content.Shared.Weapons.Melee; using Content.Shared.Weapons.Melee;
using Robust.Shared.Map; using Robust.Shared.Map;
@@ -69,7 +69,7 @@ public sealed partial class NPCCombatSystem
{ {
if (TryComp<CombatModeComponent>(uid, out var combatMode)) if (TryComp<CombatModeComponent>(uid, out var combatMode))
{ {
combatMode.IsInCombatMode = false; _combat.SetInCombatMode(uid, false, combatMode);
} }
_steering.Unregister(component.Owner); _steering.Unregister(component.Owner);
@@ -79,7 +79,7 @@ public sealed partial class NPCCombatSystem
{ {
if (TryComp<CombatModeComponent>(uid, out var combatMode)) if (TryComp<CombatModeComponent>(uid, out var combatMode))
{ {
combatMode.IsInCombatMode = true; _combat.SetInCombatMode(uid, true, combatMode);
} }
// TODO: Cleanup later, just looking for parity for now. // TODO: Cleanup later, just looking for parity for now.

View File

@@ -8,6 +8,7 @@ namespace Content.Server.NPC.Systems;
public sealed partial class NPCCombatSystem public sealed partial class NPCCombatSystem
{ {
[Dependency] private readonly SharedCombatModeSystem _combat = default!;
[Dependency] private readonly RotateToFaceSystem _rotate = default!; [Dependency] private readonly RotateToFaceSystem _rotate = default!;
// TODO: Don't predict for hitscan // TODO: Don't predict for hitscan
@@ -26,9 +27,9 @@ public sealed partial class NPCCombatSystem
private void OnRangedStartup(EntityUid uid, NPCRangedCombatComponent component, ComponentStartup args) private void OnRangedStartup(EntityUid uid, NPCRangedCombatComponent component, ComponentStartup args)
{ {
if (TryComp<SharedCombatModeComponent>(uid, out var combat)) if (TryComp<CombatModeComponent>(uid, out var combat))
{ {
combat.IsInCombatMode = true; _combat.SetInCombatMode(uid, true, combat);
} }
else else
{ {
@@ -38,9 +39,9 @@ public sealed partial class NPCCombatSystem
private void OnRangedShutdown(EntityUid uid, NPCRangedCombatComponent component, ComponentShutdown args) private void OnRangedShutdown(EntityUid uid, NPCRangedCombatComponent component, ComponentShutdown args)
{ {
if (TryComp<SharedCombatModeComponent>(uid, out var combat)) if (TryComp<CombatModeComponent>(uid, out var combat))
{ {
combat.IsInCombatMode = false; _combat.SetInCombatMode(uid, false, combat);
} }
} }
@@ -48,7 +49,7 @@ public sealed partial class NPCCombatSystem
{ {
var bodyQuery = GetEntityQuery<PhysicsComponent>(); var bodyQuery = GetEntityQuery<PhysicsComponent>();
var xformQuery = GetEntityQuery<TransformComponent>(); var xformQuery = GetEntityQuery<TransformComponent>();
var combatQuery = GetEntityQuery<SharedCombatModeComponent>(); var combatQuery = GetEntityQuery<CombatModeComponent>();
var query = EntityQueryEnumerator<NPCRangedCombatComponent, TransformComponent>(); var query = EntityQueryEnumerator<NPCRangedCombatComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var comp, out var xform)) while (query.MoveNext(out var uid, out var comp, out var xform))
@@ -73,7 +74,7 @@ public sealed partial class NPCCombatSystem
if (combatQuery.TryGetComponent(uid, out var combatMode)) if (combatQuery.TryGetComponent(uid, out var combatMode))
{ {
combatMode.IsInCombatMode = true; _combat.SetInCombatMode(uid, true, combatMode);
} }
if (!_gun.TryGetGun(uid, out var gunUid, out var gun)) if (!_gun.TryGetGun(uid, out var gunUid, out var gun))

View File

@@ -1,7 +1,7 @@
using Content.Server.CombatMode;
using Content.Server.Destructible; using Content.Server.Destructible;
using Content.Server.NPC.Components; using Content.Server.NPC.Components;
using Content.Server.NPC.Pathfinding; using Content.Server.NPC.Pathfinding;
using Content.Shared.CombatMode;
using Content.Shared.Doors.Components; using Content.Shared.Doors.Components;
using Content.Shared.NPC; using Content.Shared.NPC;
using Robust.Shared.Physics; using Robust.Shared.Physics;
@@ -115,7 +115,7 @@ public sealed partial class NPCSteeringSystem
{ {
if (_melee.TryGetWeapon(uid, out var meleeUid, out var meleeWeapon) && meleeWeapon.NextAttack <= _timing.CurTime && TryComp<CombatModeComponent>(uid, out var combatMode)) if (_melee.TryGetWeapon(uid, out var meleeUid, out var meleeWeapon) && meleeWeapon.NextAttack <= _timing.CurTime && TryComp<CombatModeComponent>(uid, out var combatMode))
{ {
combatMode.IsInCombatMode = true; _combat.SetInCombatMode(uid, true, combatMode);
var destructibleQuery = GetEntityQuery<DestructibleComponent>(); var destructibleQuery = GetEntityQuery<DestructibleComponent>();
// TODO: This is a hack around grilles and windows. // TODO: This is a hack around grilles and windows.
@@ -131,7 +131,7 @@ public sealed partial class NPCSteeringSystem
} }
} }
combatMode.IsInCombatMode = false; _combat.SetInCombatMode(uid, false, combatMode);
if (obstacleEnts.Count == 0) if (obstacleEnts.Count == 0)
return SteeringObstacleStatus.Completed; return SteeringObstacleStatus.Completed;

View File

@@ -7,6 +7,7 @@ using Content.Server.NPC.Components;
using Content.Server.NPC.Events; using Content.Server.NPC.Events;
using Content.Server.NPC.Pathfinding; using Content.Server.NPC.Pathfinding;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.CombatMode;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems; using Content.Shared.Movement.Systems;
@@ -55,6 +56,7 @@ namespace Content.Server.NPC.Systems
[Dependency] private readonly SharedMoverController _mover = default!; [Dependency] private readonly SharedMoverController _mover = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedCombatModeSystem _combat = default!;
/// <summary> /// <summary>
/// Enabled antistuck detection so if an NPC is in the same spot for a while it will re-path. /// Enabled antistuck detection so if an NPC is in the same spot for a while it will re-path.

View File

@@ -110,7 +110,7 @@ namespace Content.Server.Strip
{ {
base.StartOpeningStripper(user, component, openInCombat); base.StartOpeningStripper(user, component, openInCombat);
if (TryComp<SharedCombatModeComponent>(user, out var mode) && mode.IsInCombatMode && !openInCombat) if (TryComp<CombatModeComponent>(user, out var mode) && mode.IsInCombatMode && !openInCombat)
return; return;
if (TryComp<ActorComponent>(user, out var actor)) if (TryComp<ActorComponent>(user, out var actor))

View File

@@ -4,7 +4,6 @@ using Content.Server.Body.Components;
using Content.Server.Body.Systems; using Content.Server.Body.Systems;
using Content.Server.Chemistry.Components; using Content.Server.Chemistry.Components;
using Content.Server.Chemistry.EntitySystems; using Content.Server.Chemistry.EntitySystems;
using Content.Server.CombatMode;
using Content.Server.CombatMode.Disarm; using Content.Server.CombatMode.Disarm;
using Content.Server.Contests; using Content.Server.Contests;
using Content.Server.Examine; using Content.Server.Examine;
@@ -202,7 +201,7 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
RaiseNetworkEvent(new DamageEffectEvent(Color.Red, targets), filter); RaiseNetworkEvent(new DamageEffectEvent(Color.Red, targets), filter);
} }
private float CalculateDisarmChance(EntityUid disarmer, EntityUid disarmed, EntityUid? inTargetHand, SharedCombatModeComponent disarmerComp) private float CalculateDisarmChance(EntityUid disarmer, EntityUid disarmed, EntityUid? inTargetHand, CombatModeComponent disarmerComp)
{ {
if (HasComp<DisarmProneComponent>(disarmer)) if (HasComp<DisarmProneComponent>(disarmer))
return 1.0f; return 1.0f;

View File

@@ -5,7 +5,6 @@ using Content.Server.Body.Systems;
using Content.Server.Chat; using Content.Server.Chat;
using Content.Server.Chat.Managers; using Content.Server.Chat.Managers;
using Content.Server.Chat.Systems; using Content.Server.Chat.Systems;
using Content.Server.CombatMode;
using Content.Server.Disease.Components; using Content.Server.Disease.Components;
using Content.Server.Ghost.Roles.Components; using Content.Server.Ghost.Roles.Components;
using Content.Server.Humanoid; using Content.Server.Humanoid;
@@ -18,6 +17,7 @@ using Content.Server.Popups;
using Content.Server.Speech.Components; using Content.Server.Speech.Components;
using Content.Server.Temperature.Components; using Content.Server.Temperature.Components;
using Content.Server.Traitor; using Content.Server.Traitor;
using Content.Shared.CombatMode;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems; using Content.Shared.Hands.EntitySystems;
@@ -53,6 +53,7 @@ namespace Content.Server.Zombies
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!; [Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!;
[Dependency] private readonly AutoEmoteSystem _autoEmote = default!; [Dependency] private readonly AutoEmoteSystem _autoEmote = default!;
[Dependency] private readonly EmoteOnDamageSystem _emoteOnDamage = default!; [Dependency] private readonly EmoteOnDamageSystem _emoteOnDamage = default!;
[Dependency] private readonly SharedCombatModeSystem _combat = default!;
[Dependency] private readonly IChatManager _chatMan = default!; [Dependency] private readonly IChatManager _chatMan = default!;
[Dependency] private readonly IPrototypeManager _proto = default!; [Dependency] private readonly IPrototypeManager _proto = default!;
@@ -116,7 +117,7 @@ namespace Content.Server.Zombies
//in an attempt to make an entity not attack. This is the easiest way to do it. //in an attempt to make an entity not attack. This is the easiest way to do it.
RemComp<CombatModeComponent>(target); RemComp<CombatModeComponent>(target);
var combat = AddComp<CombatModeComponent>(target); var combat = AddComp<CombatModeComponent>(target);
combat.IsInCombatMode = true; _combat.SetInCombatMode(target, true, combat);
//This is the actual damage of the zombie. We assign the visual appearance //This is the actual damage of the zombie. We assign the visual appearance
//and range here because of stuff we'll find out later //and range here because of stuff we'll find out later

View File

@@ -1,17 +1,20 @@
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes; using Content.Shared.Actions.ActionTypes;
using Content.Shared.Targeting; using Content.Shared.Targeting;
using Content.Shared.Verbs;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Utility;
namespace Content.Shared.CombatMode namespace Content.Shared.CombatMode
{ {
[NetworkedComponent()] /// <summary>
public abstract class SharedCombatModeComponent : Component /// Stores whether an entity is in "combat mode"
/// This is used to differentiate between regular item interactions or
/// using *everything* as a weapon.
/// </summary>
[RegisterComponent, NetworkedComponent]
[Access(typeof(SharedCombatModeSystem))]
public sealed class CombatModeComponent : Component
{ {
#region Disarm #region Disarm
@@ -40,7 +43,7 @@ namespace Content.Shared.CombatMode
public InstantAction? CombatToggleAction; public InstantAction? CombatToggleAction;
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public virtual bool IsInCombatMode public bool IsInCombatMode
{ {
get => _isInCombatMode; get => _isInCombatMode;
set set
@@ -55,7 +58,7 @@ namespace Content.Shared.CombatMode
} }
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public virtual TargetingZone ActiveZone public TargetingZone ActiveZone
{ {
get => _activeZone; get => _activeZone;
set set

View File

@@ -6,6 +6,7 @@ namespace Content.Shared.CombatMode.Pacification
public sealed class PacificationSystem : EntitySystem public sealed class PacificationSystem : EntitySystem
{ {
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!; [Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly SharedCombatModeSystem _combatSystem = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -22,13 +23,13 @@ namespace Content.Shared.CombatMode.Pacification
private void OnStartup(EntityUid uid, PacifiedComponent component, ComponentStartup args) private void OnStartup(EntityUid uid, PacifiedComponent component, ComponentStartup args)
{ {
if (!TryComp<SharedCombatModeComponent>(uid, out var combatMode)) if (!TryComp<CombatModeComponent>(uid, out var combatMode))
return; return;
if (combatMode.CanDisarm != null) if (combatMode.CanDisarm != null)
combatMode.CanDisarm = false; _combatSystem.SetCanDisarm(uid, false, combatMode);
combatMode.IsInCombatMode = false; _combatSystem.SetInCombatMode(uid, false, combatMode);
if (combatMode.CombatToggleAction != null) if (combatMode.CombatToggleAction != null)
{ {
@@ -38,11 +39,11 @@ namespace Content.Shared.CombatMode.Pacification
private void OnShutdown(EntityUid uid, PacifiedComponent component, ComponentShutdown args) private void OnShutdown(EntityUid uid, PacifiedComponent component, ComponentShutdown args)
{ {
if (!TryComp<SharedCombatModeComponent>(uid, out var combatMode)) if (!TryComp<CombatModeComponent>(uid, out var combatMode))
return; return;
if (combatMode.CanDisarm != null) if (combatMode.CanDisarm != null)
combatMode.CanDisarm = true; _combatSystem.SetCanDisarm(uid, true, combatMode);
if (combatMode.CombatToggleAction != null) if (combatMode.CombatToggleAction != null)
_actionsSystem.SetEnabled(combatMode.CombatToggleAction, true); _actionsSystem.SetEnabled(combatMode.CombatToggleAction, true);

View File

@@ -15,12 +15,12 @@ namespace Content.Shared.CombatMode
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<SharedCombatModeComponent, ComponentStartup>(OnStartup); SubscribeLocalEvent<CombatModeComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<SharedCombatModeComponent, ComponentShutdown>(OnShutdown); SubscribeLocalEvent<CombatModeComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<SharedCombatModeComponent, ToggleCombatActionEvent>(OnActionPerform); SubscribeLocalEvent<CombatModeComponent, ToggleCombatActionEvent>(OnActionPerform);
} }
private void OnStartup(EntityUid uid, SharedCombatModeComponent component, ComponentStartup args) private void OnStartup(EntityUid uid, CombatModeComponent component, ComponentStartup args)
{ {
if (component.CombatToggleAction == null if (component.CombatToggleAction == null
&& _protoMan.TryIndex(component.CombatToggleActionId, out InstantActionPrototype? toggleProto)) && _protoMan.TryIndex(component.CombatToggleActionId, out InstantActionPrototype? toggleProto))
@@ -32,26 +32,52 @@ namespace Content.Shared.CombatMode
_actionsSystem.AddAction(uid, component.CombatToggleAction, null); _actionsSystem.AddAction(uid, component.CombatToggleAction, null);
} }
private void OnShutdown(EntityUid uid, SharedCombatModeComponent component, ComponentShutdown args) private void OnShutdown(EntityUid uid, CombatModeComponent component, ComponentShutdown args)
{ {
if (component.CombatToggleAction != null) if (component.CombatToggleAction != null)
_actionsSystem.RemoveAction(uid, component.CombatToggleAction); _actionsSystem.RemoveAction(uid, component.CombatToggleAction);
} }
public bool IsInCombatMode(EntityUid? entity, SharedCombatModeComponent? component = null) private void OnActionPerform(EntityUid uid, CombatModeComponent component, ToggleCombatActionEvent args)
{
return entity != null && Resolve(entity.Value, ref component, false) && component.IsInCombatMode;
}
private void OnActionPerform(EntityUid uid, SharedCombatModeComponent component, ToggleCombatActionEvent args)
{ {
if (args.Handled) if (args.Handled)
return; return;
component.IsInCombatMode = !component.IsInCombatMode; SetInCombatMode(uid, !component.IsInCombatMode, component);
args.Handled = true; args.Handled = true;
} }
public void SetCanDisarm(EntityUid entity, bool canDisarm, CombatModeComponent? component = null)
{
if (!Resolve(entity, ref component))
return;
component.CanDisarm = canDisarm;
}
public bool IsInCombatMode(EntityUid? entity, CombatModeComponent? component = null)
{
return entity != null && Resolve(entity.Value, ref component, false) && component.IsInCombatMode;
}
public virtual void SetInCombatMode(EntityUid entity, bool inCombatMode,
CombatModeComponent? component = null)
{
if (!Resolve(entity, ref component))
return;
component.IsInCombatMode = inCombatMode;
}
public virtual void SetActiveZone(EntityUid entity, TargetingZone zone,
CombatModeComponent? component = null)
{
if (!Resolve(entity, ref component))
return;
component.ActiveZone = zone;
}
[Serializable, NetSerializable] [Serializable, NetSerializable]
protected sealed class CombatModeComponentState : ComponentState protected sealed class CombatModeComponentState : ComponentState
{ {

View File

@@ -250,7 +250,7 @@ namespace Content.Shared.Interaction
if (target != null && Deleted(target.Value)) if (target != null && Deleted(target.Value))
return; return;
if (!altInteract && TryComp(user, out SharedCombatModeComponent? combatMode) && combatMode.IsInCombatMode) if (!altInteract && TryComp(user, out CombatModeComponent? combatMode) && combatMode.IsInCombatMode)
{ {
// Eat the input // Eat the input
return; return;

View File

@@ -73,10 +73,6 @@
description: Nice to have, but you can't build a civilization on a foundation of honey alone. description: Nice to have, but you can't build a civilization on a foundation of honey alone.
components: components:
- type: CombatMode - type: CombatMode
disarmAction:
enabled: false
autoPopulate: false
name: action-name-disarm
- type: MovementSpeedModifier - type: MovementSpeedModifier
baseWalkSpeed : 7 baseWalkSpeed : 7
baseSprintSpeed : 7 baseSprintSpeed : 7
@@ -134,10 +130,6 @@
description: How nice a bee. Oh no, it looks angry and wants my pizza. description: How nice a bee. Oh no, it looks angry and wants my pizza.
components: components:
- type: CombatMode - type: CombatMode
disarmAction:
enabled: false
autoPopulate: false
name: action-name-disarm
- type: MeleeWeapon - type: MeleeWeapon
hidden: true hidden: true
angle: 0 angle: 0
@@ -652,7 +644,6 @@
description: A large marsupial herbivore. It has powerful hind legs and... boxing gloves? description: A large marsupial herbivore. It has powerful hind legs and... boxing gloves?
components: components:
- type: CombatMode - type: CombatMode
disarm: null
- type: Sprite - type: Sprite
drawdepth: Mobs drawdepth: Mobs
layers: layers:
@@ -690,7 +681,6 @@
description: New church of neo-darwinists actually believe that EVERY animal evolved from a monkey. Tastes like pork, and killing them is both fun and relaxing. description: New church of neo-darwinists actually believe that EVERY animal evolved from a monkey. Tastes like pork, and killing them is both fun and relaxing.
components: components:
- type: CombatMode - type: CombatMode
disarm: null
- type: NameIdentifier - type: NameIdentifier
group: Monkey group: Monkey
- type: SentienceTarget - type: SentienceTarget
@@ -858,10 +848,6 @@
enabled: false enabled: false
autoPopulate: false autoPopulate: false
name: action-name-combat name: action-name-combat
disarmAction:
enabled: false
autoPopulate: false
name: action-name-disarm
- type: Bloodstream - type: Bloodstream
bloodMaxVolume: 50 bloodMaxVolume: 50
- type: DiseaseCarrier #The other class lab animal and disease vector - type: DiseaseCarrier #The other class lab animal and disease vector
@@ -1329,10 +1315,6 @@
- id: FoodMeatSpider - id: FoodMeatSpider
amount: 2 amount: 2
- type: CombatMode - type: CombatMode
disarmAction:
enabled: false
autoPopulate: false
name: action-name-disarm
- type: MobThresholds - type: MobThresholds
thresholds: thresholds:
0: Alive 0: Alive
@@ -2028,10 +2010,6 @@
types: types:
Blunt: 0.1 Blunt: 0.1
- type: CombatMode - type: CombatMode
disarmAction:
enabled: false
autoPopulate: false
name: action-name-disarm
- type: MeleeWeapon - type: MeleeWeapon
hidden: true hidden: true
soundHit: soundHit:

View File

@@ -56,10 +56,6 @@
bloodMaxVolume: 300 bloodMaxVolume: 300
bloodReagent: Cryoxadone bloodReagent: Cryoxadone
- type: CombatMode - type: CombatMode
disarmAction:
enabled: false
autoPopulate: false
name: action-name-disarm
- type: Temperature - type: Temperature
heatDamageThreshold: 500 heatDamageThreshold: 500
coldDamageThreshold: 0 coldDamageThreshold: 0

View File

@@ -20,10 +20,6 @@
- map: [ "enum.DamageStateVisualLayers.Base" ] - map: [ "enum.DamageStateVisualLayers.Base" ]
state: base state: base
- type: CombatMode - type: CombatMode
disarmAction:
enabled: false
autoPopulate: false
name: action-name-disarm
- type: Physics - type: Physics
- type: Fixtures - type: Fixtures
fixtures: fixtures:

View File

@@ -39,10 +39,6 @@
- type: Bloodstream - type: Bloodstream
bloodMaxVolume: 100 bloodMaxVolume: 100
- type: CombatMode - type: CombatMode
disarmAction:
enabled: false
autoPopulate: false
name: action-name-disarm
- type: MeleeWeapon - type: MeleeWeapon
hidden: true hidden: true
soundHit: soundHit:

View File

@@ -57,10 +57,6 @@
- type: Bloodstream - type: Bloodstream
bloodMaxVolume: 50 bloodMaxVolume: 50
- type: CombatMode - type: CombatMode
disarmAction:
enabled: false
autoPopulate: false
name: action-name-disarm
- type: MeleeWeapon - type: MeleeWeapon
hidden: true hidden: true
soundHit: soundHit:

View File

@@ -9,7 +9,6 @@
- type: DiseaseProtection - type: DiseaseProtection
protection: 1 protection: 1
- type: CombatMode - type: CombatMode
disarm: null
- type: InputMover - type: InputMover
- type: MobMover - type: MobMover
- type: HTN - type: HTN

View File

@@ -18,10 +18,6 @@
- Dragon - Dragon
- type: Speech - type: Speech
- type: CombatMode - type: CombatMode
disarmAction:
enabled: false
autoPopulate: false
name: action-name-disarm
- type: MobMover - type: MobMover
- type: InputMover - type: InputMover
- type: MovementSpeedModifier - type: MovementSpeedModifier

View File

@@ -5,7 +5,6 @@
id: MobDwarf id: MobDwarf
components: components:
- type: CombatMode - type: CombatMode
disarm: null
- type: InteractionPopup - type: InteractionPopup
successChance: 1 successChance: 1
interactSuccessString: hugging-success-generic interactSuccessString: hugging-success-generic

View File

@@ -5,7 +5,6 @@
id: MobHuman id: MobHuman
components: components:
- type: CombatMode - type: CombatMode
disarm: null
- type: InteractionPopup - type: InteractionPopup
successChance: 1 successChance: 1
interactSuccessString: hugging-success-generic interactSuccessString: hugging-success-generic

View File

@@ -5,7 +5,6 @@
id: MobReptilian id: MobReptilian
components: components:
- type: CombatMode - type: CombatMode
disarm: null
- type: InteractionPopup - type: InteractionPopup
successChance: 1 successChance: 1
interactSuccessString: hugging-success-generic interactSuccessString: hugging-success-generic

View File

@@ -4,7 +4,6 @@
id: MobSlimePerson id: MobSlimePerson
components: components:
- type: CombatMode - type: CombatMode
disarm: null
- type: InteractionPopup - type: InteractionPopup
successChance: 1 successChance: 1
interactSuccessString: hugging-success-generic interactSuccessString: hugging-success-generic

View File

@@ -5,7 +5,6 @@
id: MobVox id: MobVox
components: components:
- type: CombatMode - type: CombatMode
disarm: null
- type: InteractionPopup - type: InteractionPopup
successChance: 1 successChance: 1
interactSuccessString: hugging-success-generic interactSuccessString: hugging-success-generic