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,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();
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);
}

View File

@@ -1,6 +1,6 @@
using Content.Server.CombatMode;
using Content.Server.NPC.Components;
using Content.Server.NPC.Events;
using Content.Shared.CombatMode;
using Content.Shared.NPC;
using Content.Shared.Weapons.Melee;
using Robust.Shared.Map;
@@ -69,7 +69,7 @@ public sealed partial class NPCCombatSystem
{
if (TryComp<CombatModeComponent>(uid, out var combatMode))
{
combatMode.IsInCombatMode = false;
_combat.SetInCombatMode(uid, false, combatMode);
}
_steering.Unregister(component.Owner);
@@ -79,7 +79,7 @@ public sealed partial class NPCCombatSystem
{
if (TryComp<CombatModeComponent>(uid, out var combatMode))
{
combatMode.IsInCombatMode = true;
_combat.SetInCombatMode(uid, true, combatMode);
}
// 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
{
[Dependency] private readonly SharedCombatModeSystem _combat = default!;
[Dependency] private readonly RotateToFaceSystem _rotate = default!;
// TODO: Don't predict for hitscan
@@ -26,9 +27,9 @@ public sealed partial class NPCCombatSystem
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
{
@@ -38,9 +39,9 @@ public sealed partial class NPCCombatSystem
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 xformQuery = GetEntityQuery<TransformComponent>();
var combatQuery = GetEntityQuery<SharedCombatModeComponent>();
var combatQuery = GetEntityQuery<CombatModeComponent>();
var query = EntityQueryEnumerator<NPCRangedCombatComponent, TransformComponent>();
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))
{
combatMode.IsInCombatMode = true;
_combat.SetInCombatMode(uid, true, combatMode);
}
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.NPC.Components;
using Content.Server.NPC.Pathfinding;
using Content.Shared.CombatMode;
using Content.Shared.Doors.Components;
using Content.Shared.NPC;
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))
{
combatMode.IsInCombatMode = true;
_combat.SetInCombatMode(uid, true, combatMode);
var destructibleQuery = GetEntityQuery<DestructibleComponent>();
// 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)
return SteeringObstacleStatus.Completed;

View File

@@ -7,6 +7,7 @@ using Content.Server.NPC.Components;
using Content.Server.NPC.Events;
using Content.Server.NPC.Pathfinding;
using Content.Shared.CCVar;
using Content.Shared.CombatMode;
using Content.Shared.Interaction;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
@@ -55,6 +56,7 @@ namespace Content.Server.NPC.Systems
[Dependency] private readonly SharedMoverController _mover = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedCombatModeSystem _combat = default!;
/// <summary>
/// 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);
if (TryComp<SharedCombatModeComponent>(user, out var mode) && mode.IsInCombatMode && !openInCombat)
if (TryComp<CombatModeComponent>(user, out var mode) && mode.IsInCombatMode && !openInCombat)
return;
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.Chemistry.Components;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.CombatMode;
using Content.Server.CombatMode.Disarm;
using Content.Server.Contests;
using Content.Server.Examine;
@@ -202,7 +201,7 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
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))
return 1.0f;

View File

@@ -5,7 +5,6 @@ using Content.Server.Body.Systems;
using Content.Server.Chat;
using Content.Server.Chat.Managers;
using Content.Server.Chat.Systems;
using Content.Server.CombatMode;
using Content.Server.Disease.Components;
using Content.Server.Ghost.Roles.Components;
using Content.Server.Humanoid;
@@ -18,6 +17,7 @@ using Content.Server.Popups;
using Content.Server.Speech.Components;
using Content.Server.Temperature.Components;
using Content.Server.Traitor;
using Content.Shared.CombatMode;
using Content.Shared.Damage;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
@@ -53,6 +53,7 @@ namespace Content.Server.Zombies
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!;
[Dependency] private readonly AutoEmoteSystem _autoEmote = default!;
[Dependency] private readonly EmoteOnDamageSystem _emoteOnDamage = default!;
[Dependency] private readonly SharedCombatModeSystem _combat = default!;
[Dependency] private readonly IChatManager _chatMan = 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.
RemComp<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
//and range here because of stuff we'll find out later