diff --git a/Content.Client/Weather/WeatherOverlay.cs b/Content.Client/Weather/WeatherOverlay.cs deleted file mode 100644 index 12af31b863..0000000000 --- a/Content.Client/Weather/WeatherOverlay.cs +++ /dev/null @@ -1,218 +0,0 @@ -using System.Linq; -using System.Numerics; -using Content.Client.Parallax; -using Content.Shared.Weather; -using Robust.Client.GameObjects; -using Robust.Client.Graphics; -using Robust.Client.ResourceManagement; -using Robust.Client.Utility; -using Robust.Shared.Enums; -using Robust.Shared.Graphics.RSI; -using Robust.Shared.Map; -using Robust.Shared.Map.Components; -using Robust.Shared.Physics.Components; -using Robust.Shared.Prototypes; -using Robust.Shared.Timing; -using Robust.Shared.Utility; - -namespace Content.Client.Weather; - -public sealed class WeatherOverlay : Overlay -{ - [Dependency] private readonly IClyde _clyde = default!; - [Dependency] private readonly IEntityManager _entManager = default!; - [Dependency] private readonly IGameTiming _timing = default!; - [Dependency] private readonly IMapManager _mapManager = default!; - [Dependency] private readonly IPrototypeManager _protoManager = default!; - [Dependency] private readonly IResourceCache _cache = default!; - private readonly SharedTransformSystem _transform; - private readonly SpriteSystem _sprite; - private readonly WeatherSystem _weather; - - public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV; - - private IRenderTexture? _blep; - - public WeatherOverlay(SharedTransformSystem transform, SpriteSystem sprite, WeatherSystem weather) - { - ZIndex = ParallaxSystem.ParallaxZIndex + 1; - _transform = transform; - _weather = weather; - _sprite = sprite; - IoCManager.InjectDependencies(this); - } - - protected override bool BeforeDraw(in OverlayDrawArgs args) - { - if (args.MapId == MapId.Nullspace) - return false; - - if (!_entManager.TryGetComponent(_mapManager.GetMapEntityId(args.MapId), out var weather) || - weather.Weather.Count == 0) - { - return false; - } - - return base.BeforeDraw(in args); - } - - protected override void Draw(in OverlayDrawArgs args) - { - var mapUid = _mapManager.GetMapEntityId(args.MapId); - - if (!_entManager.TryGetComponent(mapUid, out var comp)) - { - return; - } - - foreach (var (proto, weather) in comp.Weather) - { - if (!_protoManager.TryIndex(proto, out var weatherProto)) - continue; - - var alpha = _weather.GetPercent(weather, mapUid); - DrawWorld(args, weatherProto, alpha); - } - } - - private void DrawWorld(in OverlayDrawArgs args, WeatherPrototype weatherProto, float alpha) - { - var worldHandle = args.WorldHandle; - var mapId = args.MapId; - var worldAABB = args.WorldAABB; - var worldBounds = args.WorldBounds; - var invMatrix = args.Viewport.GetWorldToLocalMatrix(); - var position = args.Viewport.Eye?.Position.Position ?? Vector2.Zero; - - if (_blep?.Texture.Size != args.Viewport.Size) - { - _blep?.Dispose(); - _blep = _clyde.CreateRenderTarget(args.Viewport.Size, new RenderTargetFormatParameters(RenderTargetColorFormat.Rgba8Srgb), name: "weather-stencil"); - } - - // Cut out the irrelevant bits via stencil - // This is why we don't just use parallax; we might want specific tiles to get drawn over - // particularly for planet maps or stations. - worldHandle.RenderInRenderTarget(_blep, () => - { - var bodyQuery = _entManager.GetEntityQuery(); - var xformQuery = _entManager.GetEntityQuery(); - var weatherIgnoreQuery = _entManager.GetEntityQuery(); - - // idk if this is safe to cache in a field and clear sloth help - var grids = new List>(); - _mapManager.FindGridsIntersecting(mapId, worldAABB, ref grids); - - foreach (var grid in grids) - { - var matrix = _transform.GetWorldMatrix(grid, xformQuery); - Matrix3.Multiply(in matrix, in invMatrix, out var matty); - worldHandle.SetTransform(matty); - - foreach (var tile in grid.Comp.GetTilesIntersecting(worldAABB)) - { - // Ignored tiles for stencil - if (_weather.CanWeatherAffect(grid, tile, weatherIgnoreQuery, bodyQuery)) - { - continue; - } - - var gridTile = new Box2(tile.GridIndices * grid.Comp.TileSize, - (tile.GridIndices + Vector2i.One) * grid.Comp.TileSize); - - worldHandle.DrawRect(gridTile, Color.White); - } - } - - }, Color.Transparent); - - worldHandle.SetTransform(Matrix3.Identity); - worldHandle.UseShader(_protoManager.Index("StencilMask").Instance()); - worldHandle.DrawTextureRect(_blep.Texture, worldBounds); - Texture? sprite = null; - var curTime = _timing.RealTime; - - switch (weatherProto.Sprite) - { - case SpriteSpecifier.Rsi rsi: - var rsiActual = _cache.GetResource(rsi.RsiPath).RSI; - rsiActual.TryGetState(rsi.RsiState, out var state); - var frames = state!.GetFrames(RsiDirection.South); - var delays = state.GetDelays(); - var totalDelay = delays.Sum(); - var time = curTime.TotalSeconds % totalDelay; - var delaySum = 0f; - - for (var i = 0; i < delays.Length; i++) - { - var delay = delays[i]; - delaySum += delay; - - if (time > delaySum) - continue; - - sprite = frames[i]; - break; - } - - sprite ??= _sprite.Frame0(weatherProto.Sprite); - break; - case SpriteSpecifier.Texture texture: - sprite = texture.GetTexture(_cache); - break; - default: - throw new NotImplementedException(); - } - - // Draw the rain - worldHandle.UseShader(_protoManager.Index("StencilDraw").Instance()); - - // TODO: This is very similar to parallax but we need stencil support but we can probably combine these somehow - // and not make it spaghetti, while getting the advantages of not-duped code? - - - // Okay I have spent like 5 hours on this at this point and afaict you have one of the following comprises: - // - No scrolling so the weather is always centered on the player - // - Crappy looking rotation but strafing looks okay and scrolls - // - Crappy looking strafing but rotation looks okay. - // - No rotation - // - Storing state across frames to do scrolling and just having it always do topdown. - - // I have chosen no rotation. - - const float scale = 1f; - const float slowness = 0f; - var scrolling = Vector2.Zero; - - // Size of the texture in world units. - var size = (sprite.Size / (float) EyeManager.PixelsPerMeter) * scale; - var scrolled = scrolling * (float) curTime.TotalSeconds; - - // Origin - start with the parallax shift itself. - var originBL = position * slowness + scrolled; - - // Centre the image. - originBL -= size / 2; - - // Remove offset so we can floor. - var flooredBL = args.WorldAABB.BottomLeft - originBL; - - // Floor to background size. - flooredBL = (flooredBL / size).Floored() * size; - - // Re-offset. - flooredBL += originBL; - - for (var x = flooredBL.X; x < args.WorldAABB.Right; x += size.X) - { - for (var y = flooredBL.Y; y < args.WorldAABB.Top; y += size.Y) - { - var box = Box2.FromDimensions(new Vector2(x, y), size); - worldHandle.DrawTextureRect(sprite, box, (weatherProto.Color ?? Color.White).WithAlpha(alpha)); - } - } - - worldHandle.SetTransform(Matrix3.Identity); - worldHandle.UseShader(null); - } -} diff --git a/Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs b/Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs index 5afa087297..25171e1ea2 100644 --- a/Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs +++ b/Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs @@ -500,7 +500,7 @@ public abstract partial class InteractionTest /// /// Assert whether or not the target has the given component. /// - protected void AssertComp(bool hasComp = true, NetEntity? target = null) where T : IComponent + protected void AssertComp(bool hasComp = true, NetEntity? target = null) { target ??= Target; if (target == null) diff --git a/Content.IntegrationTests/Tests/PrototypeSaveTest.cs b/Content.IntegrationTests/Tests/PrototypeSaveTest.cs index 3bcfb64f6c..6096c497ef 100644 --- a/Content.IntegrationTests/Tests/PrototypeSaveTest.cs +++ b/Content.IntegrationTests/Tests/PrototypeSaveTest.cs @@ -162,7 +162,7 @@ public sealed class PrototypeSaveTest } // An entity may also remove components on init -> check no components are missing. - foreach (var compType in prototype.Components.Keys) + foreach (var (compType, comp) in prototype.Components) { Assert.That(compNames, Does.Contain(compType), $"Prototype {prototype.ID} removes component {compType} on spawn."); } @@ -208,7 +208,7 @@ public sealed class PrototypeSaveTest Assert.Fail($"Uninitialized entities should not be saving entity Uids. Component: {WritingComponent}. Prototype: {Prototype.ID}"); } - return new ValueDataNode(value.Id.ToString()); + return new ValueDataNode(value.ToString()); } EntityUid ITypeReader.Read(ISerializationManager serializationManager, diff --git a/Content.Server/Administration/Commands/ControlMob.cs b/Content.Server/Administration/Commands/ControlMob.cs index 9d39cb9dde..317461a373 100644 --- a/Content.Server/Administration/Commands/ControlMob.cs +++ b/Content.Server/Administration/Commands/ControlMob.cs @@ -33,15 +33,15 @@ namespace Content.Server.Administration.Commands return; } - var targetNet = new NetEntity(targetId); + var target = new EntityUid(targetId); - if (!_entities.TryGetEntity(targetNet, out var target)) + if (!target.IsValid() || !_entities.EntityExists(target)) { shell.WriteLine(Loc.GetString("shell-invalid-entity-id")); return; } - _entities.System().ControlMob(player.UserId, target.Value); + _entities.System().ControlMob(player.UserId, target); } } } diff --git a/Content.Server/Administration/Commands/OwoifyCommand.cs b/Content.Server/Administration/Commands/OwoifyCommand.cs index 8ca35b1b42..73a1236d19 100644 --- a/Content.Server/Administration/Commands/OwoifyCommand.cs +++ b/Content.Server/Administration/Commands/OwoifyCommand.cs @@ -8,8 +8,6 @@ namespace Content.Server.Administration.Commands; [AdminCommand(AdminFlags.Fun)] public sealed class OwoifyCommand : IConsoleCommand { - [Dependency] private readonly IEntityManager _entManager = default!; - public string Command => "owoify"; public string Description => "For when you need everything to be cat. Uses OwOAccent's formatting on the name and description of an entity."; @@ -24,25 +22,22 @@ public sealed class OwoifyCommand : IConsoleCommand return; } + var entityManager = IoCManager.Resolve(); + if (!int.TryParse(args[0], out var targetId)) { shell.WriteLine(Loc.GetString("shell-argument-must-be-number")); return; } - var nent = new NetEntity(targetId); + var eUid = new EntityUid(targetId); - if (!_entManager.TryGetEntity(nent, out var eUid)) - { - return; - } + var meta = entityManager.GetComponent(eUid); - var meta = _entManager.GetComponent(eUid.Value); + var owoSys = entityManager.System(); + var metaDataSys = entityManager.System(); - var owoSys = _entManager.System(); - var metaDataSys = _entManager.System(); - - metaDataSys.SetEntityName(eUid.Value, owoSys.Accentuate(meta.EntityName), meta); - metaDataSys.SetEntityDescription(eUid.Value, owoSys.Accentuate(meta.EntityDescription), meta); + metaDataSys.SetEntityName(eUid, owoSys.Accentuate(meta.EntityName), meta); + metaDataSys.SetEntityDescription(eUid, owoSys.Accentuate(meta.EntityDescription), meta); } } diff --git a/Content.Server/Administration/Commands/SetMindCommand.cs b/Content.Server/Administration/Commands/SetMindCommand.cs index a7b6849423..5310c2dd7f 100644 --- a/Content.Server/Administration/Commands/SetMindCommand.cs +++ b/Content.Server/Administration/Commands/SetMindCommand.cs @@ -11,7 +11,6 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Admin)] sealed class SetMindCommand : IConsoleCommand { - [Dependency] private readonly IEntityManager _entManager = default!; public string Command => "setmind"; @@ -27,7 +26,7 @@ namespace Content.Server.Administration.Commands return; } - if (!int.TryParse(args[0], out var entInt)) + if (!int.TryParse(args[0], out var entityUid)) { shell.WriteLine(Loc.GetString("shell-entity-uid-must-be-number")); return; @@ -39,15 +38,17 @@ namespace Content.Server.Administration.Commands ghostOverride = bool.Parse(args[2]); } - var nent = new NetEntity(entInt); + var entityManager = IoCManager.Resolve(); - if (!_entManager.TryGetEntity(nent, out var eUid)) + var eUid = new EntityUid(entityUid); + + if (!eUid.IsValid() || !entityManager.EntityExists(eUid)) { shell.WriteLine(Loc.GetString("shell-invalid-entity-id")); return; } - if (!_entManager.HasComponent(eUid)) + if (!entityManager.HasComponent(eUid)) { shell.WriteLine(Loc.GetString("set-mind-command-target-has-no-mind-message")); return; @@ -67,8 +68,8 @@ namespace Content.Server.Administration.Commands return; } - var mindSystem = _entManager.System(); - var metadata = _entManager.GetComponent(eUid.Value); + var mindSystem = entityManager.System(); + var metadata = entityManager.GetComponent(eUid); var mind = playerCData.Mind ?? mindSystem.CreateMind(session.UserId, metadata.EntityName); diff --git a/Content.Server/Administration/Commands/SetOutfitCommand.cs b/Content.Server/Administration/Commands/SetOutfitCommand.cs index 4c66a09918..97c1fa0656 100644 --- a/Content.Server/Administration/Commands/SetOutfitCommand.cs +++ b/Content.Server/Administration/Commands/SetOutfitCommand.cs @@ -34,21 +34,21 @@ namespace Content.Server.Administration.Commands return; } - if (!int.TryParse(args[0], out var entInt)) + if (!int.TryParse(args[0], out var entityUid)) { shell.WriteLine(Loc.GetString("shell-entity-uid-must-be-number")); return; } - var targetNet = new NetEntity(entInt); + var target = new EntityUid(entityUid); - if (!_entities.TryGetEntity(targetNet, out var target)) + if (!target.IsValid() || !_entities.EntityExists(target)) { shell.WriteLine(Loc.GetString("shell-invalid-entity-id")); return; } - if (!_entities.HasComponent(target)) + if (!_entities.HasComponent(target)) { shell.WriteLine(Loc.GetString("shell-target-entity-does-not-have-message", ("missing", "inventory"))); return; @@ -63,12 +63,12 @@ namespace Content.Server.Administration.Commands } var eui = IoCManager.Resolve(); - var ui = new SetOutfitEui(targetNet); + var ui = new SetOutfitEui(target); eui.OpenEui(ui, player); return; } - if (!SetOutfit(target.Value, args[1], _entities)) + if (!SetOutfit(target, args[1], _entities)) shell.WriteLine(Loc.GetString("set-outfit-command-invalid-outfit-id-error")); } diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.cs b/Content.Server/Administration/Systems/AdminVerbSystem.cs index af27db29ff..bc065745f5 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.cs @@ -332,7 +332,7 @@ namespace Content.Server.Administration.Systems Text = Loc.GetString("set-outfit-verb-get-data-text"), Category = VerbCategory.Debug, Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/outfit.svg.192dpi.png")), - Act = () => _euiManager.OpenEui(new SetOutfitEui(GetNetEntity(args.Target)), player), + Act = () => _euiManager.OpenEui(new SetOutfitEui(args.Target), player), Impact = LogImpact.Medium }; args.Verbs.Add(verb); diff --git a/Content.Server/Administration/UI/SetOutfitEui.cs b/Content.Server/Administration/UI/SetOutfitEui.cs index 2812975f4d..6243657c32 100644 --- a/Content.Server/Administration/UI/SetOutfitEui.cs +++ b/Content.Server/Administration/UI/SetOutfitEui.cs @@ -10,9 +10,10 @@ namespace Content.Server.Administration.UI public sealed class SetOutfitEui : BaseEui { [Dependency] private readonly IAdminManager _adminManager = default!; - private readonly NetEntity _target; + [Dependency] private readonly IEntityManager _entManager = default!; + private readonly EntityUid _target; - public SetOutfitEui(NetEntity entity) + public SetOutfitEui(EntityUid entity) { _target = entity; IoCManager.InjectDependencies(this); @@ -30,7 +31,7 @@ namespace Content.Server.Administration.UI { return new SetOutfitEuiState { - TargetNetEntity = _target, + TargetNetEntity = _entManager.GetNetEntity(_target) }; } diff --git a/Content.Server/Humanoid/Systems/RandomHumanoidSystem.cs b/Content.Server/Humanoid/Systems/RandomHumanoidSystem.cs index f3607f74dc..6a17a52c3d 100644 --- a/Content.Server/Humanoid/Systems/RandomHumanoidSystem.cs +++ b/Content.Server/Humanoid/Systems/RandomHumanoidSystem.cs @@ -52,7 +52,7 @@ public sealed class RandomHumanoidSystem : EntitySystem { var comp = (Component) _serialization.CreateCopy(entry.Component, notNullableOverride: true); comp.Owner = humanoid; // This .owner must survive for now. - EntityManager.AddComponent(humanoid, comp); + EntityManager.AddComponent(humanoid, comp, true); } } diff --git a/Content.Server/Jobs/AddComponentSpecial.cs b/Content.Server/Jobs/AddComponentSpecial.cs index 62443a1c4e..1b183c5c3f 100644 --- a/Content.Server/Jobs/AddComponentSpecial.cs +++ b/Content.Server/Jobs/AddComponentSpecial.cs @@ -27,7 +27,7 @@ namespace Content.Server.Jobs var temp = (object) component; serializationManager.CopyTo(data.Component, ref temp); - entityManager.AddComponent(mob, (Component) temp!); + entityManager.AddComponent(mob, (Component) temp!, true); } } } diff --git a/Content.Server/NPC/Commands/AddNPCCommand.cs b/Content.Server/NPC/Commands/AddNPCCommand.cs index c5582b7b4c..070b9f35d3 100644 --- a/Content.Server/NPC/Commands/AddNPCCommand.cs +++ b/Content.Server/NPC/Commands/AddNPCCommand.cs @@ -24,11 +24,11 @@ namespace Content.Server.NPC.Commands return; } - var nent = new NetEntity(int.Parse(args[0])); + var entId = new EntityUid(int.Parse(args[0])); - if (!_entities.TryGetEntity(nent, out var entId)) + if (!_entities.EntityExists(entId)) { - shell.WriteError($"Unable to find entity {nent}"); + shell.WriteError($"Unable to find entity with uid {entId}"); return; } @@ -38,7 +38,7 @@ namespace Content.Server.NPC.Commands return; } - var comp = _entities.AddComponent(entId.Value); + var comp = _entities.AddComponent(entId); comp.RootTask = new HTNCompoundTask() { Task = args[1] diff --git a/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs b/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs index 2ab29d1b2f..cc20b71946 100644 --- a/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs +++ b/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs @@ -11,9 +11,6 @@ namespace Content.Server.Sandbox.Commands [AnyCommand] public sealed class ColorNetworkCommand : IConsoleCommand { - [Dependency] private readonly IAdminManager _adminManager = default!; - [Dependency] private readonly IEntityManager _entManager = default!; - public string Command => "colornetwork"; public string Description => Loc.GetString("color-network-command-description"); public string Help => Loc.GetString("color-network-command-help-text", ("command",Command)); @@ -33,21 +30,25 @@ namespace Content.Server.Sandbox.Commands return; } + + + var entityManager = IoCManager.Resolve(); + if (!int.TryParse(args[0], out var targetId)) { shell.WriteLine(Loc.GetString("shell-argument-must-be-number")); return; } - var nent = new NetEntity(targetId); + var eUid = new EntityUid(targetId); - if (!_entManager.TryGetEntity(nent, out var eUid)) + if (!eUid.IsValid() || !entityManager.EntityExists(eUid)) { shell.WriteLine(Loc.GetString("shell-invalid-entity-id")); return; } - if (!_entManager.TryGetComponent(eUid, out NodeContainerComponent? nodeContainerComponent)) + if (!entityManager.TryGetComponent(eUid, out NodeContainerComponent? nodeContainerComponent)) { shell.WriteLine(Loc.GetString("shell-entity-is-not-node-container")); return; @@ -73,15 +74,13 @@ namespace Content.Server.Sandbox.Commands { var group = nodeContainerComponent.Nodes[nodeGroupId.ToString().ToLower()].NodeGroup; - if (group == null) - return; + if (group == null) return; foreach (var x in group.Nodes) { - if (!_entManager.TryGetComponent(x.Owner, out AtmosPipeColorComponent? atmosPipeColorComponent)) - continue; + if (!IoCManager.Resolve().TryGetComponent(x.Owner, out AtmosPipeColorComponent? atmosPipeColorComponent)) continue; - _entManager.System().SetColor(x.Owner, atmosPipeColorComponent, color); + EntitySystem.Get().SetColor(x.Owner, atmosPipeColorComponent, color); } } } diff --git a/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs b/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs index cdaed3f928..fd656a9f71 100644 --- a/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs +++ b/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs @@ -12,10 +12,6 @@ namespace Content.Server.Traitor.Uplink.Commands [AdminCommand(AdminFlags.Admin)] public sealed class AddUplinkCommand : IConsoleCommand { - [Dependency] private readonly IConfigurationManager _cfgManager = default!; - [Dependency] private readonly IEntityManager _entManager = default!; - [Dependency] private readonly IPlayerManager _playerManager = default!; - public string Command => "adduplink"; public string Description => Loc.GetString("add-uplink-command-description"); @@ -45,7 +41,7 @@ namespace Content.Server.Traitor.Uplink.Commands if (args.Length > 0) { // Get player entity - if (!_playerManager.TryGetSessionByUsername(args[0], out session)) + if (!IoCManager.Resolve().TryGetSessionByUsername(args[0], out session)) { shell.WriteLine(Loc.GetString("shell-target-player-does-not-exist")); return; @@ -64,6 +60,7 @@ namespace Content.Server.Traitor.Uplink.Commands // Get target item EntityUid? uplinkEntity = null; + var entityManager = IoCManager.Resolve(); if (args.Length >= 2) { if (!int.TryParse(args[1], out var itemID)) @@ -72,9 +69,8 @@ namespace Content.Server.Traitor.Uplink.Commands return; } - var eNet = new NetEntity(itemID); - - if (!_entManager.TryGetEntity(eNet, out var eUid)) + var eUid = new EntityUid(itemID); + if (!eUid.IsValid() || !entityManager.EntityExists(eUid)) { shell.WriteLine(Loc.GetString("shell-invalid-entity-id")); return; @@ -84,10 +80,11 @@ namespace Content.Server.Traitor.Uplink.Commands } // Get TC count - var tcCount = _cfgManager.GetCVar(CCVars.TraitorStartingBalance); - Logger.Debug(_entManager.ToPrettyString(user)); + var configManager = IoCManager.Resolve(); + var tcCount = configManager.GetCVar(CCVars.TraitorStartingBalance); + Logger.Debug(entityManager.ToPrettyString(user)); // Finally add uplink - var uplinkSys = _entManager.System(); + var uplinkSys = entityManager.EntitySysManager.GetEntitySystem(); if (!uplinkSys.AddUplink(user, FixedPoint2.New(tcCount), uplinkEntity: uplinkEntity)) { shell.WriteLine(Loc.GetString("add-uplink-command-error-2")); diff --git a/Content.Server/Verbs/Commands/InvokeVerbCommand.cs b/Content.Server/Verbs/Commands/InvokeVerbCommand.cs index 3309ef8153..af2131fb55 100644 --- a/Content.Server/Verbs/Commands/InvokeVerbCommand.cs +++ b/Content.Server/Verbs/Commands/InvokeVerbCommand.cs @@ -9,8 +9,6 @@ namespace Content.Server.Verbs.Commands [AdminCommand(AdminFlags.Admin)] public sealed class InvokeVerbCommand : IConsoleCommand { - [Dependency] private readonly IEntityManager _entManager = default!; - public string Command => "invokeverb"; public string Description => Loc.GetString("invoke-verb-command-description"); public string Help => Loc.GetString("invoke-verb-command-help"); @@ -23,7 +21,8 @@ namespace Content.Server.Verbs.Commands return; } - var verbSystem = _entManager.System(); + var entityManager = IoCManager.Resolve(); + var verbSystem = entityManager.System(); // get the 'player' entity (defaulting to command user, otherwise uses a uid) EntityUid? playerEntity = null; @@ -39,6 +38,10 @@ namespace Content.Server.Verbs.Commands return; } } + else + { + entityManager.EntityExists(new EntityUid(intPlayerUid)); + } // gets the target entity if (!int.TryParse(args[1], out var intUid)) @@ -53,16 +56,16 @@ namespace Content.Server.Verbs.Commands return; } - var targetNet = new NetEntity(intUid); - - if (!_entManager.TryGetEntity(targetNet, out var target)) + var target = new EntityUid(intUid); + if (!entityManager.EntityExists(target)) { shell.WriteError(Loc.GetString("invoke-verb-command-invalid-target-entity")); return; } var verbName = args[2].ToLowerInvariant(); - var verbs = verbSystem.GetLocalVerbs(target.Value, playerEntity.Value, Verb.VerbTypes, true); + var verbs = verbSystem.GetLocalVerbs(target, playerEntity.Value, Verb.VerbTypes, true); + // if the "verb name" is actually a verb-type, try run any verb of that type. var verbType = Verb.VerbTypes.FirstOrDefault(x => x.Name == verbName); @@ -71,7 +74,7 @@ namespace Content.Server.Verbs.Commands var verb = verbs.FirstOrDefault(v => v.GetType() == verbType); if (verb != null) { - verbSystem.ExecuteVerb(verb, playerEntity.Value, target.Value, forced: true); + verbSystem.ExecuteVerb(verb, playerEntity.Value, target, forced: true); shell.WriteLine(Loc.GetString("invoke-verb-command-success", ("verb", verbName), ("target", target), ("player", playerEntity))); return; } @@ -81,7 +84,7 @@ namespace Content.Server.Verbs.Commands { if (verb.Text.ToLowerInvariant() == verbName) { - verbSystem.ExecuteVerb(verb, playerEntity.Value, target.Value, forced: true); + verbSystem.ExecuteVerb(verb, playerEntity.Value, target, forced: true); shell.WriteLine(Loc.GetString("invoke-verb-command-success", ("verb", verb.Text), ("target", target), ("player", playerEntity))); return; } diff --git a/Content.Server/Verbs/Commands/ListVerbsCommand.cs b/Content.Server/Verbs/Commands/ListVerbsCommand.cs index fd159e37bb..dc56cffb44 100644 --- a/Content.Server/Verbs/Commands/ListVerbsCommand.cs +++ b/Content.Server/Verbs/Commands/ListVerbsCommand.cs @@ -8,8 +8,6 @@ namespace Content.Server.Verbs.Commands [AdminCommand(AdminFlags.Admin)] public sealed class ListVerbsCommand : IConsoleCommand { - [Dependency] private readonly IEntityManager _entManager = default!; - public string Command => "listverbs"; public string Description => Loc.GetString("list-verbs-command-description"); public string Help => Loc.GetString("list-verbs-command-help"); @@ -22,11 +20,11 @@ namespace Content.Server.Verbs.Commands return; } - var verbSystem = _entManager.System(); + var entityManager = IoCManager.Resolve(); + var verbSystem = EntitySystem.Get(); // get the 'player' entity (defaulting to command user, otherwise uses a uid) EntityUid? playerEntity = null; - if (!int.TryParse(args[0], out var intPlayerUid)) { if (args[0] == "self" && shell.Player?.AttachedEntity != null) @@ -39,6 +37,10 @@ namespace Content.Server.Verbs.Commands return; } } + else + { + entityManager.EntityExists(new EntityUid(intPlayerUid)); + } // gets the target entity if (!int.TryParse(args[1], out var intUid)) @@ -53,15 +55,14 @@ namespace Content.Server.Verbs.Commands return; } - var targetNet = new NetEntity(intUid); - - if (!_entManager.TryGetEntity(targetNet, out var target)) + var target = new EntityUid(intUid); + if (!entityManager.EntityExists(target)) { shell.WriteError(Loc.GetString("list-verbs-command-invalid-target-entity")); return; } - var verbs = verbSystem.GetLocalVerbs(target.Value, playerEntity.Value, Verb.VerbTypes); + var verbs = verbSystem.GetLocalVerbs(target, playerEntity.Value, Verb.VerbTypes); foreach (var verb in verbs) { diff --git a/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactAnalyzerSystem.cs b/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactAnalyzerSystem.cs index 343826c7ae..9200928d66 100644 --- a/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactAnalyzerSystem.cs +++ b/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactAnalyzerSystem.cs @@ -180,9 +180,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem component.AnalyzerEntity = null; } - // TODO: Yeah this comp relies upon event ordering so we get this for now. - if (!TerminatingOrDeleted(uid)) - UpdateUserInterface(uid, component); + UpdateUserInterface(uid, component); } private void UpdateUserInterface(EntityUid uid, AnalysisConsoleComponent? component = null) diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Nodes.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Nodes.cs index ab4670b905..e6f937236d 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Nodes.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Nodes.cs @@ -204,7 +204,7 @@ public sealed partial class ArtifactSystem var temp = (object) comp; _serialization.CopyTo(entry.Component, ref temp); - EntityManager.AddComponent(uid, (Component) temp!); + EntityManager.AddComponent(uid, (Component) temp!, true); } node.Discovered = true; @@ -238,7 +238,7 @@ public sealed partial class ArtifactSystem comp.Owner = uid; var temp = (object) comp; _serialization.CopyTo(entry, ref temp); - EntityManager.AddComponent(uid, (Component) temp!); + EntityManager.AddComponent(uid, (Component) temp!, true); continue; } diff --git a/Content.Shared/Anomaly/SharedAnomalySystem.cs b/Content.Shared/Anomaly/SharedAnomalySystem.cs index e3678d1459..48413ac001 100644 --- a/Content.Shared/Anomaly/SharedAnomalySystem.cs +++ b/Content.Shared/Anomaly/SharedAnomalySystem.cs @@ -109,7 +109,7 @@ public abstract class SharedAnomalySystem : EntitySystem var pulse = EnsureComp(uid); pulse.EndTime = Timing.CurTime + pulse.PulseDuration; Appearance.SetData(uid, AnomalyVisuals.IsPulsing, true); - + var ev = new AnomalyPulseEvent(uid, component.Stability, component.Severity); RaiseLocalEvent(uid, ref ev, true); } diff --git a/Content.Shared/Blocking/BlockingSystem.User.cs b/Content.Shared/Blocking/BlockingSystem.User.cs index 237cdfa488..bfefaf2b92 100644 --- a/Content.Shared/Blocking/BlockingSystem.User.cs +++ b/Content.Shared/Blocking/BlockingSystem.User.cs @@ -1,4 +1,5 @@ using Content.Shared.Damage; +using Content.Shared.Damage.Prototypes; using Robust.Shared.Audio; using Robust.Shared.Containers; diff --git a/Content.Shared/Chasm/ChasmSystem.cs b/Content.Shared/Chasm/ChasmSystem.cs index c63691c3f9..7353bd0e9c 100644 --- a/Content.Shared/Chasm/ChasmSystem.cs +++ b/Content.Shared/Chasm/ChasmSystem.cs @@ -1,7 +1,9 @@ using Content.Shared.ActionBlocker; +using Content.Shared.Buckle.Components; using Content.Shared.Movement.Events; using Content.Shared.StepTrigger.Systems; using Robust.Shared.Network; +using Robust.Shared.Physics.Components; using Robust.Shared.Timing; namespace Content.Shared.Chasm; diff --git a/Content.Shared/Climbing/Systems/ClimbSystem.cs b/Content.Shared/Climbing/Systems/ClimbSystem.cs index 50ae6fb56c..f065d19dd3 100644 --- a/Content.Shared/Climbing/Systems/ClimbSystem.cs +++ b/Content.Shared/Climbing/Systems/ClimbSystem.cs @@ -1,3 +1,4 @@ +using System.Numerics; using Content.Shared.ActionBlocker; using Content.Shared.Body.Components; using Content.Shared.Body.Part; @@ -12,6 +13,7 @@ using Content.Shared.Hands.Components; using Content.Shared.IdentityManagement; using Content.Shared.Interaction; using Content.Shared.Movement.Events; +using Content.Shared.Movement.Systems; using Content.Shared.Physics; using Content.Shared.Popups; using Content.Shared.Stunnable; diff --git a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs index 789ff37dcf..9194a8208e 100644 --- a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs +++ b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs @@ -110,7 +110,7 @@ namespace Content.Shared.Containers.ItemSlots /// public void RemoveItemSlot(EntityUid uid, ItemSlot slot, ItemSlotsComponent? itemSlots = null) { - if (TerminatingOrDeleted(uid) || slot.ContainerSlot == null) + if (Terminating(uid) || slot.ContainerSlot == null) return; slot.ContainerSlot.Shutdown(); diff --git a/Content.Shared/Cuffs/SharedCuffableSystem.cs b/Content.Shared/Cuffs/SharedCuffableSystem.cs index f47daf5ee2..5dbe62aa6a 100644 --- a/Content.Shared/Cuffs/SharedCuffableSystem.cs +++ b/Content.Shared/Cuffs/SharedCuffableSystem.cs @@ -3,6 +3,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Administration.Components; using Content.Shared.Administration.Logs; using Content.Shared.Alert; +using Content.Shared.Atmos.Piping.Unary.Components; using Content.Shared.Buckle.Components; using Content.Shared.Cuffs.Components; using Content.Shared.Damage; diff --git a/Content.Shared/Inventory/InventorySystem.Equip.cs b/Content.Shared/Inventory/InventorySystem.Equip.cs index 6f373db115..7b6ccaf0d4 100644 --- a/Content.Shared/Inventory/InventorySystem.Equip.cs +++ b/Content.Shared/Inventory/InventorySystem.Equip.cs @@ -14,6 +14,7 @@ using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.Network; using Robust.Shared.Player; +using Robust.Shared.Prototypes; using Robust.Shared.Timing; namespace Content.Shared.Inventory; @@ -23,9 +24,9 @@ public abstract partial class InventorySystem [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!; [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; + [Dependency] private readonly SharedItemSystem _item = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!; - [Dependency] private readonly SharedItemSystem _item = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly INetManager _netMan = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; diff --git a/Content.Shared/Lock/LockSystem.cs b/Content.Shared/Lock/LockSystem.cs index 71a9f7d1c8..97baa28bf9 100644 --- a/Content.Shared/Lock/LockSystem.cs +++ b/Content.Shared/Lock/LockSystem.cs @@ -106,7 +106,7 @@ public sealed class LockSystem : EntitySystem lockComp.Locked = true; _appearanceSystem.SetData(uid, StorageVisuals.Locked, true); - Dirty(uid, lockComp); + Dirty(lockComp); var ev = new LockToggledEvent(true); RaiseLocalEvent(uid, ref ev, true); @@ -134,7 +134,7 @@ public sealed class LockSystem : EntitySystem lockComp.Locked = false; _appearanceSystem.SetData(uid, StorageVisuals.Locked, false); - Dirty(uid, lockComp); + Dirty(lockComp); var ev = new LockToggledEvent(false); RaiseLocalEvent(uid, ref ev, true); diff --git a/Content.Shared/Mech/Equipment/Systems/MechSoundboardSystem.cs b/Content.Shared/Mech/Equipment/Systems/MechSoundboardSystem.cs index c58a09a4f4..b4254fe079 100644 --- a/Content.Shared/Mech/Equipment/Systems/MechSoundboardSystem.cs +++ b/Content.Shared/Mech/Equipment/Systems/MechSoundboardSystem.cs @@ -1,5 +1,8 @@ +using Content.Shared.Mech; using Content.Shared.Mech.Equipment.Components; +using Content.Shared.Mech.Equipment.Systems; using Content.Shared.Timing; +using Robust.Shared.Audio; using System.Linq; namespace Content.Shared.Mech.Equipment.Systems; diff --git a/Content.Shared/RCD/Systems/RCDSystem.cs b/Content.Shared/RCD/Systems/RCDSystem.cs index cfdab20fb8..ccc47a2fde 100644 --- a/Content.Shared/RCD/Systems/RCDSystem.cs +++ b/Content.Shared/RCD/Systems/RCDSystem.cs @@ -12,6 +12,7 @@ using Content.Shared.Popups; using Content.Shared.RCD.Components; using Content.Shared.Tag; using Content.Shared.Tiles; +using Robust.Shared.Audio; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Network; diff --git a/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs b/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs index 2f1b3ac461..eb97fe4113 100644 --- a/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs +++ b/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs @@ -6,6 +6,7 @@ using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; using Content.Shared.Popups; using Content.Shared.Radio.Components; +using Content.Shared.Tools; using Content.Shared.Tools.Components; using Content.Shared.Wires; using Robust.Shared.Containers; diff --git a/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs b/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs index bbf4b42da4..f84a65398d 100644 --- a/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs @@ -20,7 +20,9 @@ using Robust.Shared.GameStates; using Robust.Shared.Map; using Robust.Shared.Network; using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Systems; +using Robust.Shared.Prototypes; using Robust.Shared.Timing; using Robust.Shared.Utility; diff --git a/Content.Shared/Stunnable/SharedStunSystem.cs b/Content.Shared/Stunnable/SharedStunSystem.cs index 289dcabd1d..4875f2f68f 100644 --- a/Content.Shared/Stunnable/SharedStunSystem.cs +++ b/Content.Shared/Stunnable/SharedStunSystem.cs @@ -1,5 +1,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Administration.Logs; +using Content.Shared.Audio; +using Content.Shared.DragDrop; using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.Inventory.Events; @@ -9,11 +11,15 @@ using Content.Shared.Database; using Content.Shared.Hands; using Content.Shared.Mobs; using Content.Shared.Mobs.Components; +using Content.Shared.Mobs.Systems; using Content.Shared.Movement.Events; using Content.Shared.Movement.Systems; using Content.Shared.Standing; using Content.Shared.StatusEffect; using Content.Shared.Throwing; +using Robust.Shared.Audio; +using Robust.Shared.GameStates; +using Robust.Shared.Player; namespace Content.Shared.Stunnable; diff --git a/Content.Shared/Weapons/Ranged/Systems/RechargeBasicEntityAmmoSystem.cs b/Content.Shared/Weapons/Ranged/Systems/RechargeBasicEntityAmmoSystem.cs index 13e07b922f..ded4ce34a2 100644 --- a/Content.Shared/Weapons/Ranged/Systems/RechargeBasicEntityAmmoSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/RechargeBasicEntityAmmoSystem.cs @@ -1,7 +1,9 @@ using Content.Shared.Examine; using Content.Shared.Weapons.Ranged.Components; using Robust.Shared.Network; +using Robust.Shared.Player; using Robust.Shared.Timing; +using Robust.Shared.Utility; namespace Content.Shared.Weapons.Ranged.Systems;