ECS tags (#6504)
This commit is contained in:
@@ -693,7 +693,9 @@ namespace Content.Server.Botany.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
if (usingItem.HasTag("Hoe"))
|
||||
var tagSystem = EntitySystem.Get<TagSystem>();
|
||||
|
||||
if (tagSystem.HasTag(usingItem, "Hoe"))
|
||||
{
|
||||
if (WeedLevel > 0)
|
||||
{
|
||||
@@ -712,7 +714,7 @@ namespace Content.Server.Botany.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
if (usingItem.HasTag("Shovel"))
|
||||
if (tagSystem.HasTag(usingItem, "Shovel"))
|
||||
{
|
||||
if (Seed != null)
|
||||
{
|
||||
@@ -764,7 +766,7 @@ namespace Content.Server.Botany.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
if (usingItem.HasTag("PlantSampleTaker"))
|
||||
if (tagSystem.HasTag(usingItem, "PlantSampleTaker"))
|
||||
{
|
||||
if (Seed == null)
|
||||
{
|
||||
@@ -800,7 +802,7 @@ namespace Content.Server.Botany.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
if (usingItem.HasTag("BotanySharp"))
|
||||
if (tagSystem.HasTag(usingItem, "BotanySharp"))
|
||||
{
|
||||
return DoHarvest(user);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Server.Botany.Components;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Tag;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -18,6 +19,7 @@ namespace Content.Server.Botany.Systems
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
|
||||
[Dependency] private readonly TagSystem _tags = default!;
|
||||
|
||||
private int _nextUid = 0;
|
||||
private float _timer = 0f;
|
||||
|
||||
@@ -136,7 +136,7 @@ public partial class BotanySystem
|
||||
|
||||
public bool CanHarvest(SeedPrototype proto, EntityUid? held = null)
|
||||
{
|
||||
return !proto.Ligneous || proto.Ligneous && held != null && held.Value.HasTag("BotanySharp");
|
||||
return !proto.Ligneous || proto.Ligneous && held != null && _tags.HasTag(held.Value, "BotanySharp");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace Content.Server.Botany.Systems;
|
||||
|
||||
public sealed class LogSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly TagSystem _tags = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -18,7 +20,7 @@ public sealed class LogSystem : EntitySystem
|
||||
|
||||
private void OnInteractUsing(EntityUid uid, LogComponent component, InteractUsingEvent args)
|
||||
{
|
||||
if (args.Used.HasTag("BotanySharp"))
|
||||
if (_tags.HasTag(args.Used, "BotanySharp"))
|
||||
{
|
||||
for (var i = 0; i < component.SpawnCount; i++)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ public class HasTag : ReagentEffectCondition
|
||||
public override bool Condition(ReagentEffectArgs args)
|
||||
{
|
||||
if (args.EntityManager.TryGetComponent<TagComponent>(args.SolutionEntity, out var tag))
|
||||
return tag.HasTag(Tag) ^ Invert;
|
||||
return EntitySystem.Get<TagSystem>().HasTag(tag, Tag) ^ Invert;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,22 +25,23 @@ namespace Content.Server.Construction.Commands
|
||||
var player = shell.Player as IPlayerSession;
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
GridId gridId;
|
||||
var xformQuery = entityManager.GetEntityQuery<TransformComponent>();
|
||||
|
||||
switch (args.Length)
|
||||
{
|
||||
case 0:
|
||||
if (player?.AttachedEntity is not {Valid: true} playerEntity)
|
||||
{
|
||||
shell.WriteLine("Only a player can run this command.");
|
||||
shell.WriteError("Only a player can run this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = entityManager.GetComponent<TransformComponent>(playerEntity).GridID;
|
||||
gridId = xformQuery.GetComponent(playerEntity).GridID;
|
||||
break;
|
||||
case 1:
|
||||
if (!int.TryParse(args[0], out var id))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid integer.");
|
||||
shell.WriteError($"{args[0]} is not a valid integer.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,18 +55,20 @@ namespace Content.Server.Construction.Commands
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
shell.WriteLine($"No grid exists with id {gridId}");
|
||||
shell.WriteError($"No grid exists with id {gridId}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.EntityExists(grid.GridEntityId))
|
||||
{
|
||||
shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
|
||||
shell.WriteError($"Grid {gridId} doesn't have an associated grid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
var changed = 0;
|
||||
foreach (var child in entityManager.GetComponent<TransformComponent>(grid.GridEntityId).ChildEntities)
|
||||
var tagSystem = EntitySystem.Get<TagSystem>();
|
||||
|
||||
foreach (var child in xformQuery.GetComponent(grid.GridEntityId).ChildEntities)
|
||||
{
|
||||
if (!entityManager.EntityExists(child))
|
||||
{
|
||||
@@ -85,18 +88,18 @@ namespace Content.Server.Construction.Commands
|
||||
// cables
|
||||
valid |= entityManager.HasComponent<CableComponent>(child);
|
||||
// anything else that might need this forced
|
||||
valid |= child.HasTag("ForceFixRotations");
|
||||
valid |= tagSystem.HasTag(child, "ForceFixRotations");
|
||||
// override
|
||||
valid &= !child.HasTag("ForceNoFixRotations");
|
||||
valid &= !tagSystem.HasTag(child, "ForceNoFixRotations");
|
||||
|
||||
if (!valid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entityManager.GetComponent<TransformComponent>(child).LocalRotation != Angle.Zero)
|
||||
var childXform = xformQuery.GetComponent(child);
|
||||
|
||||
if (childXform.LocalRotation != Angle.Zero)
|
||||
{
|
||||
entityManager.GetComponent<TransformComponent>(child).LocalRotation = Angle.Zero;
|
||||
childXform.LocalRotation = Angle.Zero;
|
||||
changed++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Stack;
|
||||
using Content.Shared.Construction;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Construction.Components
|
||||
{
|
||||
@@ -236,10 +231,12 @@ namespace Content.Server.Construction.Components
|
||||
_componentProgress[compName]++;
|
||||
}
|
||||
|
||||
var tagSystem = EntitySystem.Get<TagSystem>();
|
||||
|
||||
// I have MANY regrets.
|
||||
foreach (var (tagName, _) in TagRequirements)
|
||||
{
|
||||
if (!part.HasTag(tagName))
|
||||
if (!tagSystem.HasTag(part, tagName))
|
||||
continue;
|
||||
|
||||
if (!_tagProgress.ContainsKey(tagName))
|
||||
@@ -339,12 +336,14 @@ namespace Content.Server.Construction.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
var tags = EntitySystem.Get<TagSystem>();
|
||||
|
||||
foreach (var (tagName, info) in TagRequirements)
|
||||
{
|
||||
if (_tagProgress[tagName] >= info.Amount)
|
||||
continue;
|
||||
|
||||
if (!eventArgs.Using.HasTag(tagName))
|
||||
if (!tags.HasTag(eventArgs.Using, tagName))
|
||||
continue;
|
||||
|
||||
if (!eventArgs.Using.TryRemoveFromContainer() || !_partContainer.Insert(eventArgs.Using)) continue;
|
||||
|
||||
@@ -28,6 +28,7 @@ public sealed class DoorSystem : SharedDoorSystem
|
||||
[Dependency] private readonly ToolSystem _toolSystem = default!;
|
||||
[Dependency] private readonly AirtightSystem _airtightSystem = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -236,8 +237,10 @@ public sealed class DoorSystem : SharedDoorSystem
|
||||
if (door.State != DoorState.Closed)
|
||||
return;
|
||||
|
||||
if (TryComp(args.OtherFixture.Body.Owner, out TagComponent? tags) && tags.HasTag("DoorBumpOpener"))
|
||||
TryOpen(uid, door, args.OtherFixture.Body.Owner);
|
||||
var otherUid = args.OtherFixture.Body.Owner;
|
||||
|
||||
if (_tagSystem.HasTag(otherUid, "DoorBumpOpener"))
|
||||
TryOpen(uid, door, otherUid);
|
||||
}
|
||||
|
||||
public override void OnPartialOpen(EntityUid uid, DoorComponent? door = null, PhysicsComponent? physics = null)
|
||||
@@ -264,7 +267,7 @@ public sealed class DoorSystem : SharedDoorSystem
|
||||
if (!base.OnPartialClose(uid, door, physics))
|
||||
return false;
|
||||
|
||||
// update airtight, if we did not crush something.
|
||||
// update airtight, if we did not crush something.
|
||||
if (door.ChangeAirtight && door.CurrentlyCrushing.Count == 0 && TryComp(uid, out AirtightComponent? airtight))
|
||||
_airtightSystem.SetAirblocked(airtight, true);
|
||||
|
||||
|
||||
@@ -53,10 +53,11 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
[Dependency] private readonly TriggerSystem _triggers = default!;
|
||||
[Dependency] private readonly AdminLogSystem _logSystem = default!;
|
||||
[Dependency] private readonly CameraRecoilSystem _cameraRecoil = default!;
|
||||
[Dependency] private readonly TagSystem _tags = default!;
|
||||
|
||||
private bool IgnoreExplosivePassable(EntityUid e)
|
||||
{
|
||||
return e.HasTag("ExplosivePassable");
|
||||
return _tags.HasTag(e, "ExplosivePassable");
|
||||
}
|
||||
|
||||
private ExplosionSeverity CalculateSeverity(float distance, float devastationRange, float heavyRange)
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Content.Server.Paper
|
||||
|
||||
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.Using.HasTag("Write"))
|
||||
if (!EntitySystem.Get<TagSystem>().HasTag(eventArgs.Using, "Write"))
|
||||
return false;
|
||||
if (!_entMan.TryGetComponent(eventArgs.User, out ActorComponent? actor))
|
||||
return false;
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace Content.Server.Physics.Controllers
|
||||
{
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly TagSystem _tags = default!;
|
||||
|
||||
private const float StepSoundMoveDistanceRunning = 2;
|
||||
private const float StepSoundMoveDistanceWalking = 1.5f;
|
||||
@@ -272,7 +273,7 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
protected override void HandleFootsteps(IMoverComponent mover, IMobMoverComponent mobMover)
|
||||
{
|
||||
if (!mover.Owner.HasTag("FootstepSound")) return;
|
||||
if (!_tags.HasTag(mover.Owner, "FootstepSound")) return;
|
||||
|
||||
var transform = EntityManager.GetComponent<TransformComponent>(mover.Owner);
|
||||
var coordinates = transform.Coordinates;
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Content.Server.RCD.Systems
|
||||
|
||||
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
|
||||
private readonly RcdMode[] _modes = (RcdMode[]) Enum.GetValues(typeof(RcdMode));
|
||||
|
||||
@@ -191,7 +192,7 @@ namespace Content.Server.RCD.Systems
|
||||
return false;
|
||||
}
|
||||
//They tried to decon a non-turf but it's not in the whitelist
|
||||
if (eventArgs.Target != null && !eventArgs.Target.Value.HasTag("RCDDeconstructWhitelist"))
|
||||
if (eventArgs.Target != null && !_tagSystem.HasTag(eventArgs.Target.Value, "RCDDeconstructWhitelist"))
|
||||
{
|
||||
rcd.Owner.PopupMessage(eventArgs.User, Loc.GetString("rcd-component-deconstruct-target-not-on-whitelist-message"));
|
||||
return false;
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly TagSystem _tags = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -147,7 +148,7 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
/// </summary>
|
||||
private void HandleConsoleInteract(EntityUid uid, ShuttleConsoleComponent component, ActivateInWorldEvent args)
|
||||
{
|
||||
if (!args.User.HasTag("CanPilot"))
|
||||
if (!_tags.HasTag(args.User, "CanPilot"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace Content.Server.Singularity.EntitySystems
|
||||
{
|
||||
public sealed class ContainmentFieldGeneratorSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly TagSystem _tags = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -40,7 +42,7 @@ namespace Content.Server.Singularity.EntitySystems
|
||||
|
||||
private void HandleGeneratorCollide(EntityUid uid, ContainmentFieldGeneratorComponent component, StartCollideEvent args)
|
||||
{
|
||||
if (args.OtherFixture.Body.Owner.HasTag("EmitterBolt")) {
|
||||
if (_tags.HasTag(args.OtherFixture.Body.Owner, "EmitterBolt")) {
|
||||
component.ReceivePower(6);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Content.Server.Throwing
|
||||
{
|
||||
comp.Thrower = user;
|
||||
// Give it a l'il spin.
|
||||
if (!entity.HasTag("NoSpinOnThrow"))
|
||||
if (!EntitySystem.Get<TagSystem>().HasTag(entity, "NoSpinOnThrow"))
|
||||
{
|
||||
physicsComponent.ApplyAngularImpulse(ThrowAngularImpulse);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user