ECS tags (#6504)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user