diff --git a/Content.Client/Construction/MachineFrameVisualizer.cs b/Content.Client/Construction/MachineFrameVisualizer.cs index fc19bfbbd4..f0bcbf4df3 100644 --- a/Content.Client/Construction/MachineFrameVisualizer.cs +++ b/Content.Client/Construction/MachineFrameVisualizer.cs @@ -1,8 +1,6 @@ using Content.Shared.Construction; using JetBrains.Annotations; using Robust.Client.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; namespace Content.Client.Construction { diff --git a/Content.Client/Construction/UI/ConstructionMenuPresenter.cs b/Content.Client/Construction/UI/ConstructionMenuPresenter.cs index f403eb74cb..d5c2147ea9 100644 --- a/Content.Client/Construction/UI/ConstructionMenuPresenter.cs +++ b/Content.Client/Construction/UI/ConstructionMenuPresenter.cs @@ -1,6 +1,8 @@ using System.Linq; using Content.Client.UserInterface.Systems.MenuBar.Widgets; using Content.Shared.Construction.Prototypes; +using Robust.Client.GameObjects; +using Robust.Client.Graphics; using Robust.Client.Placement; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; @@ -67,7 +69,6 @@ namespace Content.Client.Construction.UI /// /// Constructs a new instance of . /// - /// GUI that is being presented to. public ConstructionMenuPresenter() { // This is a lot easier than a factory @@ -203,8 +204,9 @@ namespace Content.Client.Construction.UI private void PopulateInfo(ConstructionPrototype prototype) { + var spriteSys = _systemManager.GetEntitySystem(); _constructionView.ClearRecipeInfo(); - _constructionView.SetRecipeInfo(prototype.Name, prototype.Description, prototype.Icon.Frame0(), prototype.Type != ConstructionType.Item); + _constructionView.SetRecipeInfo(prototype.Name, prototype.Description, spriteSys.Frame0(prototype.Icon), prototype.Type != ConstructionType.Item); var stepList = _constructionView.RecipeStepList; GenerateStepList(prototype, stepList); @@ -215,19 +217,24 @@ namespace Content.Client.Construction.UI if (_constructionSystem?.GetGuide(prototype) is not { } guide) return; + var spriteSys = _systemManager.GetEntitySystem(); + foreach (var entry in guide.Entries) { var text = entry.Arguments != null ? Loc.GetString(entry.Localization, entry.Arguments) : Loc.GetString(entry.Localization); if (entry.EntryNumber is {} number) + { text = Loc.GetString("construction-presenter-step-wrapper", ("step-number", number), ("text", text)); + } // The padding needs to be applied regardless of text length... (See PadLeft documentation) text = text.PadLeft(text.Length + entry.Padding); - stepList.AddItem(text, entry.Icon?.Frame0(), false); + var icon = entry.Icon != null ? spriteSys.Frame0(entry.Icon) : Texture.Transparent; + stepList.AddItem(text, icon, false); } } @@ -281,7 +288,7 @@ namespace Content.Client.Construction.UI { if (_selected == null || _selected.Type != ConstructionType.Structure) return; - var constructSystem = EntitySystem.Get(); + var constructSystem = _systemManager.GetEntitySystem(); _placementManager.BeginPlacing(new PlacementInformation() { diff --git a/Content.IntegrationTests/Tests/PrototypeSaveTest.cs b/Content.IntegrationTests/Tests/PrototypeSaveTest.cs index d5d7114bea..49fbb357e6 100644 --- a/Content.IntegrationTests/Tests/PrototypeSaveTest.cs +++ b/Content.IntegrationTests/Tests/PrototypeSaveTest.cs @@ -103,7 +103,6 @@ public sealed class PrototypeSaveTest "CrateArtifactContainer", "CloningPod", "DrinkColaCan", - "MachineFrame", "WeaponImprovisedPneumaticCannon", "LauncherCreamPie", "GravityGenerator", diff --git a/Content.Server/Construction/AnchorableSystem.cs b/Content.Server/Construction/AnchorableSystem.cs index 93b8b1acf4..0995242728 100644 --- a/Content.Server/Construction/AnchorableSystem.cs +++ b/Content.Server/Construction/AnchorableSystem.cs @@ -51,9 +51,9 @@ namespace Content.Server.Construction component.CancelToken = null; var xform = Transform(uid); - RaiseLocalEvent(uid, new BeforeUnanchoredEvent(args.User, args.Using), false); + RaiseLocalEvent(uid, new BeforeUnanchoredEvent(args.User, args.Using)); xform.Anchored = false; - RaiseLocalEvent(uid, new UserUnanchoredEvent(args.User, args.Using), false); + RaiseLocalEvent(uid, new UserUnanchoredEvent(args.User, args.Using)); _popup.PopupEntity(Loc.GetString("anchorable-unanchored"), uid, Filter.Pvs(uid, entityManager: EntityManager)); @@ -93,9 +93,9 @@ namespace Content.Server.Construction if (component.Snap) xform.Coordinates = xform.Coordinates.SnapToGrid(EntityManager, _mapManager); - RaiseLocalEvent(uid, new BeforeAnchoredEvent(args.User, args.Using), false); + RaiseLocalEvent(uid, new BeforeAnchoredEvent(args.User, args.Using)); xform.Anchored = true; - RaiseLocalEvent(uid, new UserAnchoredEvent(args.User, args.Using), false); + RaiseLocalEvent(uid, new UserAnchoredEvent(args.User, args.Using)); _popup.PopupEntity(Loc.GetString("anchorable-anchored"), uid, Filter.Pvs(uid, entityManager: EntityManager)); @@ -155,16 +155,13 @@ namespace Content.Server.Construction // Need to cast the event or it will be raised as BaseAnchoredAttemptEvent. if (anchoring) - RaiseLocalEvent(uid, (AnchorAttemptEvent) attempt, false); + RaiseLocalEvent(uid, (AnchorAttemptEvent) attempt); else - RaiseLocalEvent(uid, (UnanchorAttemptEvent) attempt, false); + RaiseLocalEvent(uid, (UnanchorAttemptEvent) attempt); anchorable.Delay += attempt.Delay; - if (attempt.Cancelled) - return false; - - return true; + return !attempt.Cancelled; } /// diff --git a/Content.Server/Construction/Commands/FixRotationsCommand.cs b/Content.Server/Construction/Commands/FixRotationsCommand.cs index 1bacaf3f8f..8d933ef04c 100644 --- a/Content.Server/Construction/Commands/FixRotationsCommand.cs +++ b/Content.Server/Construction/Commands/FixRotationsCommand.cs @@ -63,7 +63,7 @@ namespace Content.Server.Construction.Commands } var changed = 0; - var tagSystem = EntitySystem.Get(); + var tagSystem = entityManager.EntitySysManager.GetEntitySystem(); foreach (var child in xformQuery.GetComponent(grid.GridEntityId).ChildEntities) { diff --git a/Content.Server/Construction/Commands/TileReplaceCommand.cs b/Content.Server/Construction/Commands/TileReplaceCommand.cs index 82d27f10e3..3794dfd424 100644 --- a/Content.Server/Construction/Commands/TileReplaceCommand.cs +++ b/Content.Server/Construction/Commands/TileReplaceCommand.cs @@ -1,11 +1,8 @@ using Content.Server.Administration; using Content.Shared.Administration; -using Content.Shared.Maps; -using Content.Shared.Tag; using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Map; -using Robust.Shared.Prototypes; namespace Content.Server.Construction.Commands; @@ -22,8 +19,8 @@ sealed class TileReplaceCommand : IConsoleCommand var player = shell.Player as IPlayerSession; var entityManager = IoCManager.Resolve(); EntityUid? gridId; - string tileIdA = ""; - string tileIdB = ""; + string tileIdA; + string tileIdB; switch (args.Length) { diff --git a/Content.Server/Construction/Commands/TileWallsCommand.cs b/Content.Server/Construction/Commands/TileWallsCommand.cs index 9b85f3d9da..12e592eb0b 100644 --- a/Content.Server/Construction/Commands/TileWallsCommand.cs +++ b/Content.Server/Construction/Commands/TileWallsCommand.cs @@ -5,7 +5,6 @@ using Content.Shared.Tag; using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Map; -using Robust.Shared.Prototypes; namespace Content.Server.Construction.Commands { @@ -17,7 +16,7 @@ namespace Content.Server.Construction.Commands public string Description => "Puts an underplating tile below every wall on a grid."; public string Help => $"Usage: {Command} | {Command}"; - public const string TilePrototypeID = "Plating"; + public const string TilePrototypeId = "Plating"; public const string WallTag = "Wall"; public void Execute(IConsoleShell shell, string argStr, string[] args) @@ -65,8 +64,8 @@ namespace Content.Server.Construction.Commands } var tileDefinitionManager = IoCManager.Resolve(); - var tagSystem = EntitySystem.Get(); - var underplating = tileDefinitionManager[TilePrototypeID]; + var tagSystem = entityManager.EntitySysManager.GetEntitySystem(); + var underplating = tileDefinitionManager[TilePrototypeId]; var underplatingTile = new Tile(underplating.TileId); var changed = 0; foreach (var child in entityManager.GetComponent(grid.GridEntityId).ChildEntities) @@ -91,7 +90,7 @@ namespace Content.Server.Construction.Commands var tile = grid.GetTileRef(childTransform.Coordinates); var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId]; - if (tileDef.ID == TilePrototypeID) + if (tileDef.ID == TilePrototypeId) { continue; } diff --git a/Content.Server/Construction/Completions/AddContainer.cs b/Content.Server/Construction/Completions/AddContainer.cs index deccd281a3..882c5c2a52 100644 --- a/Content.Server/Construction/Completions/AddContainer.cs +++ b/Content.Server/Construction/Completions/AddContainer.cs @@ -7,7 +7,7 @@ namespace Content.Server.Construction.Completions [DataDefinition] public sealed class AddContainer : IGraphAction { - [DataField("container")] public string? Container { get; private set; } = null; + [DataField("container")] public string? Container { get; private set; } public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager) { diff --git a/Content.Server/Construction/Completions/AttemptElectrocute.cs b/Content.Server/Construction/Completions/AttemptElectrocute.cs index 3d4000f755..cabb792552 100644 --- a/Content.Server/Construction/Completions/AttemptElectrocute.cs +++ b/Content.Server/Construction/Completions/AttemptElectrocute.cs @@ -11,7 +11,7 @@ namespace Content.Server.Construction.Completions if (userUid == null) return; - EntitySystem.Get().TryDoElectrifiedAct(uid, userUid.Value); + entityManager.EntitySysManager.GetEntitySystem().TryDoElectrifiedAct(uid, userUid.Value); } } } diff --git a/Content.Server/Construction/Completions/BuildMachine.cs b/Content.Server/Construction/Completions/BuildMachine.cs index 230613e260..917d0ab887 100644 --- a/Content.Server/Construction/Completions/BuildMachine.cs +++ b/Content.Server/Construction/Completions/BuildMachine.cs @@ -2,6 +2,7 @@ using System.Linq; using Content.Server.Construction.Components; using Content.Shared.Construction; using JetBrains.Annotations; +using Robust.Server.Containers; using Robust.Shared.Containers; namespace Content.Server.Construction.Completions @@ -24,7 +25,7 @@ namespace Content.Server.Construction.Completions return; } - if (!EntitySystem.Get().IsComplete(machineFrame)) + if (!entityManager.EntitySysManager.GetEntitySystem().IsComplete(machineFrame)) { Logger.Warning($"Machine frame entity {uid} doesn't have all required parts to be built! Aborting build machine action."); return; @@ -57,24 +58,25 @@ namespace Content.Server.Construction.Completions entBoardContainer.Remove(board); + var containerSys = entityManager.EntitySysManager.GetEntitySystem(); var transform = entityManager.GetComponent(uid); var machine = entityManager.SpawnEntity(boardComponent.Prototype, transform.Coordinates); entityManager.GetComponent(machine).LocalRotation = transform.LocalRotation; - var boardContainer = machine.EnsureContainer(MachineFrameComponent.BoardContainerName, out var existed); + var boardContainer = containerSys.EnsureContainer(machine, MachineFrameComponent.BoardContainerName, out var existed); if (existed) { // Clean that up... - boardContainer.CleanContainer(); + containerSys.CleanContainer(boardContainer); } - var partContainer = machine.EnsureContainer(MachineFrameComponent.PartContainerName, out existed); + var partContainer = containerSys.EnsureContainer(machine, MachineFrameComponent.PartContainerName, out existed); if (existed) { // Clean that up, too... - partContainer.CleanContainer(); + containerSys.CleanContainer(partContainer); } boardContainer.Insert(board); diff --git a/Content.Server/Construction/Completions/ConditionalAction.cs b/Content.Server/Construction/Completions/ConditionalAction.cs index 13fe62e4f6..d2827c5ecb 100644 --- a/Content.Server/Construction/Completions/ConditionalAction.cs +++ b/Content.Server/Construction/Completions/ConditionalAction.cs @@ -7,13 +7,13 @@ namespace Content.Server.Construction.Completions [DataDefinition] public sealed class ConditionalAction : IGraphAction { - [DataField("passUser")] public bool PassUser { get; } = false; + [DataField("passUser")] public bool PassUser { get; } - [DataField("condition", required:true)] public IGraphCondition? Condition { get; } = null; + [DataField("condition", required:true)] public IGraphCondition? Condition { get; } - [DataField("action", required:true)] public IGraphAction? Action { get; } = null; + [DataField("action", required:true)] public IGraphAction? Action { get; } - [DataField("else")] public IGraphAction? Else { get; } = null; + [DataField("else")] public IGraphAction? Else { get; } public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager) { diff --git a/Content.Server/Construction/Completions/DeleteEntitiesInContainer.cs b/Content.Server/Construction/Completions/DeleteEntitiesInContainer.cs index 4f22aba61d..0b030447ac 100644 --- a/Content.Server/Construction/Completions/DeleteEntitiesInContainer.cs +++ b/Content.Server/Construction/Completions/DeleteEntitiesInContainer.cs @@ -1,5 +1,6 @@ using System.Linq; using Content.Shared.Construction; +using Robust.Server.Containers; using Robust.Shared.Containers; namespace Content.Server.Construction.Completions @@ -11,10 +12,12 @@ namespace Content.Server.Construction.Completions public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager) { - if (string.IsNullOrEmpty(Container)) return; - // TODO CONSTRUCTION: Use the new ContainerSystem methods here. - if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerMan)) return; - if (!containerMan.TryGetContainer(Container, out var container)) return; + if (string.IsNullOrEmpty(Container)) + return; + var containerSys = entityManager.EntitySysManager.GetEntitySystem(); + + if (!containerSys.TryGetContainer(uid, Container, out var container)) + return; foreach (var contained in container.ContainedEntities.ToArray()) { diff --git a/Content.Server/Construction/Completions/EmptyAllContainers.cs b/Content.Server/Construction/Completions/EmptyAllContainers.cs index 77a71c51c4..9cf5c9f83c 100644 --- a/Content.Server/Construction/Completions/EmptyAllContainers.cs +++ b/Content.Server/Construction/Completions/EmptyAllContainers.cs @@ -1,5 +1,6 @@ using Content.Shared.Construction; using JetBrains.Annotations; +using Robust.Server.Containers; using Robust.Shared.Containers; namespace Content.Server.Construction.Completions @@ -14,9 +15,10 @@ namespace Content.Server.Construction.Completions return; var transform = entityManager.GetComponent(uid); + var containerSys = entityManager.EntitySysManager.GetEntitySystem(); foreach (var container in containerManager.GetAllContainers()) { - container.EmptyContainer(true, transform.Coordinates); + containerSys.EmptyContainer(container, true, transform.Coordinates); } } } diff --git a/Content.Server/Construction/Completions/EmptyContainer.cs b/Content.Server/Construction/Completions/EmptyContainer.cs index ebb80a749b..88c3b807bd 100644 --- a/Content.Server/Construction/Completions/EmptyContainer.cs +++ b/Content.Server/Construction/Completions/EmptyContainer.cs @@ -1,6 +1,7 @@ using System.Linq; using Content.Shared.Construction; using JetBrains.Annotations; +using Robust.Server.Containers; using Robust.Shared.Containers; namespace Content.Server.Construction.Completions @@ -16,15 +17,9 @@ namespace Content.Server.Construction.Completions if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager) || !containerManager.TryGetContainer(Container, out var container)) return; - // TODO: Use container system methods. + var containerSys = entityManager.EntitySysManager.GetEntitySystem(); var transform = entityManager.GetComponent(uid); - foreach (var contained in container.ContainedEntities.ToArray()) - { - container.ForceRemove(contained); - var cTransform = entityManager.GetComponent(contained); - cTransform.Coordinates = transform.Coordinates; - cTransform.AttachToGridOrMap(); - } + containerSys.EmptyContainer(container, true, transform.Coordinates, true); } } } diff --git a/Content.Server/Construction/Completions/MachineFrameRegenerateProgress.cs b/Content.Server/Construction/Completions/MachineFrameRegenerateProgress.cs index 1abb3f72cf..425c95bc0d 100644 --- a/Content.Server/Construction/Completions/MachineFrameRegenerateProgress.cs +++ b/Content.Server/Construction/Completions/MachineFrameRegenerateProgress.cs @@ -12,7 +12,7 @@ namespace Content.Server.Construction.Completions { if (entityManager.TryGetComponent(uid, out var machineFrame)) { - EntitySystem.Get().RegenerateProgress(machineFrame); + entityManager.EntitySysManager.GetEntitySystem().RegenerateProgress(machineFrame); } } } diff --git a/Content.Server/Construction/Completions/MoveContainer.cs b/Content.Server/Construction/Completions/MoveContainer.cs index c2fdb0ae75..77d11c7e85 100644 --- a/Content.Server/Construction/Completions/MoveContainer.cs +++ b/Content.Server/Construction/Completions/MoveContainer.cs @@ -10,8 +10,8 @@ namespace Content.Server.Construction.Completions [DataDefinition] public sealed class MoveContainer : IGraphAction { - [DataField("from")] public string? FromContainer { get; } = null; - [DataField("to")] public string? ToContainer { get; } = null; + [DataField("from")] public string? FromContainer { get; } + [DataField("to")] public string? ToContainer { get; } public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager) { diff --git a/Content.Server/Construction/Completions/PlaySound.cs b/Content.Server/Construction/Completions/PlaySound.cs index 69f95ab456..28ebc2e19a 100644 --- a/Content.Server/Construction/Completions/PlaySound.cs +++ b/Content.Server/Construction/Completions/PlaySound.cs @@ -1,7 +1,6 @@ using Content.Shared.Construction; using JetBrains.Annotations; using Robust.Shared.Audio; -using Robust.Shared.Player; using Robust.Shared.Random; namespace Content.Server.Construction.Completions @@ -22,7 +21,8 @@ namespace Content.Server.Construction.Completions public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager) { var scale = (float) IoCManager.Resolve().NextGaussian(1, Variation); - SoundSystem.Play(Sound.GetSound(), Filter.Pvs(uid, entityManager: entityManager), uid, AudioParams.WithPitchScale(scale)); + entityManager.EntitySysManager.GetEntitySystem() + .PlayPvs(Sound, uid, AudioParams.WithPitchScale(scale)); } } } diff --git a/Content.Server/Construction/Completions/PopupUser.cs b/Content.Server/Construction/Completions/PopupUser.cs index 2638af23fb..f975fec3a6 100644 --- a/Content.Server/Construction/Completions/PopupUser.cs +++ b/Content.Server/Construction/Completions/PopupUser.cs @@ -9,7 +9,7 @@ namespace Content.Server.Construction.Completions [DataDefinition] public sealed class PopupUser : IGraphAction { - [DataField("cursor")] public bool Cursor { get; } = false; + [DataField("cursor")] public bool Cursor { get; } [DataField("text")] public string Text { get; } = string.Empty; public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager) diff --git a/Content.Server/Construction/Completions/RaiseEvent.cs b/Content.Server/Construction/Completions/RaiseEvent.cs index ca03de7d3d..2d28ae5c52 100644 --- a/Content.Server/Construction/Completions/RaiseEvent.cs +++ b/Content.Server/Construction/Completions/RaiseEvent.cs @@ -7,7 +7,7 @@ namespace Content.Server.Construction.Completions public sealed class RaiseEvent : IGraphAction { [DataField("event", required:true)] - public EntityEventArgs? Event { get; } = null; + public EntityEventArgs? Event { get; } [DataField("directed")] public bool Directed { get; } = true; @@ -21,7 +21,7 @@ namespace Content.Server.Construction.Completions return; if(Directed) - entityManager.EventBus.RaiseLocalEvent(uid, (object)Event, false); + entityManager.EventBus.RaiseLocalEvent(uid, (object)Event); if(Broadcast) entityManager.EventBus.RaiseEvent(EventSource.Local, (object)Event); diff --git a/Content.Server/Construction/Completions/SetStackCount.cs b/Content.Server/Construction/Completions/SetStackCount.cs index ad2242ae73..48f255102b 100644 --- a/Content.Server/Construction/Completions/SetStackCount.cs +++ b/Content.Server/Construction/Completions/SetStackCount.cs @@ -12,7 +12,7 @@ namespace Content.Server.Construction.Completions public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager) { - EntitySystem.Get().SetCount(uid, Amount); + entityManager.EntitySysManager.GetEntitySystem().SetCount(uid, Amount); } } } diff --git a/Content.Server/Construction/Completions/SnapToGrid.cs b/Content.Server/Construction/Completions/SnapToGrid.cs index ec41b13988..2ef0663972 100644 --- a/Content.Server/Construction/Completions/SnapToGrid.cs +++ b/Content.Server/Construction/Completions/SnapToGrid.cs @@ -8,7 +8,7 @@ namespace Content.Server.Construction.Completions [DataDefinition] public sealed class SnapToGrid : IGraphAction { - [DataField("southRotation")] public bool SouthRotation { get; private set; } = false; + [DataField("southRotation")] public bool SouthRotation { get; private set; } public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager) { diff --git a/Content.Server/Construction/Completions/SpriteChange.cs b/Content.Server/Construction/Completions/SpriteChange.cs index a7cc7c339b..ea42bd110a 100644 --- a/Content.Server/Construction/Completions/SpriteChange.cs +++ b/Content.Server/Construction/Completions/SpriteChange.cs @@ -14,12 +14,15 @@ namespace Content.Server.Construction.Completions public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager) { - if (SpriteSpecifier == null || SpriteSpecifier == SpriteSpecifier.Invalid) return; + if (SpriteSpecifier == null || SpriteSpecifier == SpriteSpecifier.Invalid) + return; - if (!entityManager.TryGetComponent(uid, out SpriteComponent? sprite)) return; + if (!entityManager.TryGetComponent(uid, out SpriteComponent? sprite)) + return; // That layer doesn't exist, we do nothing. - if (sprite.LayerCount <= Layer) return; + if (sprite.LayerCount <= Layer) + return; sprite.LayerSetSprite(Layer, SpriteSpecifier); } diff --git a/Content.Server/Construction/Components/WelderRefinableComponent.cs b/Content.Server/Construction/Components/WelderRefinableComponent.cs index da7160130f..a2bca0f430 100644 --- a/Content.Server/Construction/Components/WelderRefinableComponent.cs +++ b/Content.Server/Construction/Components/WelderRefinableComponent.cs @@ -11,7 +11,7 @@ namespace Content.Server.Construction.Components public sealed class WelderRefinableComponent : Component { [DataField("refineResult")] - public HashSet? RefineResult = new() { }; + public HashSet? RefineResult = new(); [DataField("refineTime")] public float RefineTime = 2f; diff --git a/Content.Server/Construction/Conditions/AirlockBolted.cs b/Content.Server/Construction/Conditions/AirlockBolted.cs index fad84c2213..4d130da573 100644 --- a/Content.Server/Construction/Conditions/AirlockBolted.cs +++ b/Content.Server/Construction/Conditions/AirlockBolted.cs @@ -30,7 +30,7 @@ namespace Content.Server.Construction.Conditions if (airlock.BoltsDown != Value) { - if (Value == true) + if (Value) args.PushMarkup(Loc.GetString("construction-examine-condition-airlock-bolt", ("entityName", entMan.GetComponent(entity).EntityName)) + "\n"); else args.PushMarkup(Loc.GetString("construction-examine-condition-airlock-unbolt", ("entityName", entMan.GetComponent(entity).EntityName)) + "\n"); diff --git a/Content.Server/Construction/Conditions/ComponentInTile.cs b/Content.Server/Construction/Conditions/ComponentInTile.cs index 5479c33081..d2f6209ca4 100644 --- a/Content.Server/Construction/Conditions/ComponentInTile.cs +++ b/Content.Server/Construction/Conditions/ComponentInTile.cs @@ -47,7 +47,8 @@ namespace Content.Server.Construction.Conditions return false; var indices = transform.Coordinates.ToVector2i(entityManager, IoCManager.Resolve()); - var entities = indices.GetEntitiesInTile(transform.GridUid.Value, LookupFlags.Approximate | LookupFlags.Anchored, EntitySystem.Get()); + var lookup = entityManager.EntitySysManager.GetEntitySystem(); + var entities = indices.GetEntitiesInTile(transform.GridUid.Value, LookupFlags.Approximate | LookupFlags.Anchored, lookup); foreach (var ent in entities) { diff --git a/Content.Server/Construction/Conditions/DoorWelded.cs b/Content.Server/Construction/Conditions/DoorWelded.cs index 648f1ad3de..3e3042e497 100644 --- a/Content.Server/Construction/Conditions/DoorWelded.cs +++ b/Content.Server/Construction/Conditions/DoorWelded.cs @@ -31,7 +31,7 @@ namespace Content.Server.Construction.Conditions var isWelded = door.State == DoorState.Welded; if (isWelded != Welded) { - if (Welded == true) + if (Welded) args.PushMarkup(Loc.GetString("construction-examine-condition-door-weld", ("entityName", entMan.GetComponent(entity).EntityName)) + "\n"); else args.PushMarkup(Loc.GetString("construction-examine-condition-door-unweld", ("entityName", entMan.GetComponent(entity).EntityName)) + "\n"); diff --git a/Content.Server/Construction/Conditions/MachineFrameComplete.cs b/Content.Server/Construction/Conditions/MachineFrameComplete.cs index af205926d6..449418d5e5 100644 --- a/Content.Server/Construction/Conditions/MachineFrameComplete.cs +++ b/Content.Server/Construction/Conditions/MachineFrameComplete.cs @@ -25,14 +25,16 @@ namespace Content.Server.Construction.Conditions if (!entityManager.TryGetComponent(uid, out MachineFrameComponent? machineFrame)) return false; - return EntitySystem.Get().IsComplete(machineFrame); + return entityManager.EntitySysManager.GetEntitySystem().IsComplete(machineFrame); } public bool DoExamine(ExaminedEvent args) { var entity = args.Examined; - if (!IoCManager.Resolve().TryGetComponent(entity, out var machineFrame)) + var entityManager = IoCManager.Resolve(); + + if (!entityManager.TryGetComponent(entity, out var machineFrame)) return false; if (!machineFrame.HasBoard) @@ -41,18 +43,20 @@ namespace Content.Server.Construction.Conditions return true; } - if (EntitySystem.Get().IsComplete(machineFrame)) return false; + if (entityManager.EntitySysManager.GetEntitySystem().IsComplete(machineFrame)) + return false; args.Message.AddMarkup(Loc.GetString("construction-condition-machine-frame-requirement-label") + "\n"); foreach (var (part, required) in machineFrame.Requirements) { var amount = required - machineFrame.Progress[part]; - if(amount == 0) continue; + if(amount == 0) + continue; args.Message.AddMarkup(Loc.GetString("construction-condition-machine-frame-required-element-entry", ("amount", amount), - ("elementName", Loc.GetString(part.ToString()))) + ("elementName", Loc.GetString(part))) + "\n"); } @@ -60,11 +64,12 @@ namespace Content.Server.Construction.Conditions { var amount = required - machineFrame.MaterialProgress[material]; - if(amount == 0) continue; + if(amount == 0) + continue; args.Message.AddMarkup(Loc.GetString("construction-condition-machine-frame-required-element-entry", ("amount", amount), - ("elementName", Loc.GetString(material.ToString()))) + ("elementName", Loc.GetString(material))) + "\n"); } @@ -72,7 +77,8 @@ namespace Content.Server.Construction.Conditions { var amount = info.Amount - machineFrame.ComponentProgress[compName]; - if(amount == 0) continue; + if(amount == 0) + continue; args.Message.AddMarkup(Loc.GetString("construction-condition-machine-frame-required-element-entry", ("amount", info.Amount), @@ -84,7 +90,8 @@ namespace Content.Server.Construction.Conditions { var amount = info.Amount - machineFrame.TagProgress[tagName]; - if(amount == 0) continue; + if(amount == 0) + continue; args.Message.AddMarkup(Loc.GetString("construction-condition-machine-frame-required-element-entry", ("amount", info.Amount), diff --git a/Content.Server/Construction/Conditions/StorageWelded.cs b/Content.Server/Construction/Conditions/StorageWelded.cs index a634db79cd..8bc54de1d2 100644 --- a/Content.Server/Construction/Conditions/StorageWelded.cs +++ b/Content.Server/Construction/Conditions/StorageWelded.cs @@ -31,7 +31,7 @@ namespace Content.Server.Construction.Conditions if (entityStorage.IsWeldedShut != Welded) { - if (Welded == true) + if (Welded) args.PushMarkup(Loc.GetString("construction-examine-condition-door-weld", ("entityName", metaData.EntityName)) + "\n"); else args.PushMarkup(Loc.GetString("construction-examine-condition-door-unweld", ("entityName", metaData.EntityName)) + "\n"); diff --git a/Content.Server/Construction/ConstructionSystem.Computer.cs b/Content.Server/Construction/ConstructionSystem.Computer.cs index f536ef8109..df96c0a6f8 100644 --- a/Content.Server/Construction/ConstructionSystem.Computer.cs +++ b/Content.Server/Construction/ConstructionSystem.Computer.cs @@ -7,6 +7,8 @@ namespace Content.Server.Construction; public sealed partial class ConstructionSystem { + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + private void InitializeComputer() { SubscribeLocalEvent(OnCompInit); @@ -19,10 +21,9 @@ public sealed partial class ConstructionSystem // Let's ensure the container manager and container are here. _container.EnsureContainer(uid, "board"); - if (TryComp(uid, out var powerReceiver) && - TryComp(uid, out var appearance)) + if (TryComp(uid, out var powerReceiver)) { - appearance.SetData(ComputerVisuals.Powered, powerReceiver.Powered); + _appearance.SetData(uid, ComputerVisuals.Powered, powerReceiver.Powered); } } @@ -33,10 +34,7 @@ public sealed partial class ConstructionSystem private void OnCompPowerChange(EntityUid uid, ComputerComponent component, ref PowerChangedEvent args) { - if (TryComp(uid, out var appearance)) - { - appearance.SetData(ComputerVisuals.Powered, args.Powered); - } + _appearance.SetData(uid, ComputerVisuals.Powered, args.Powered); } /// diff --git a/Content.Server/Construction/ConstructionSystem.Graph.cs b/Content.Server/Construction/ConstructionSystem.Graph.cs index 835dcf058e..152ae66011 100644 --- a/Content.Server/Construction/ConstructionSystem.Graph.cs +++ b/Content.Server/Construction/ConstructionSystem.Graph.cs @@ -11,8 +11,6 @@ namespace Content.Server.Construction { public sealed partial class ConstructionSystem { - [Dependency] private readonly ContainerSystem _containerSystem = default!; - private void InitializeGraphs() { } @@ -329,11 +327,11 @@ namespace Content.Server.Construction // Transfer all construction-owned containers from the old entity to the new one. foreach (var container in construction.Containers) { - if (!_containerSystem.TryGetContainer(uid, container, out var ourContainer, containerManager)) + if (!_container.TryGetContainer(uid, container, out var ourContainer, containerManager)) continue; // NOTE: Only Container is supported by Construction! - var otherContainer = _containerSystem.EnsureContainer(newUid, container, newContainerManager); + var otherContainer = _container.EnsureContainer(newUid, container, newContainerManager); for (var i = ourContainer.ContainedEntities.Count - 1; i >= 0; i--) { diff --git a/Content.Server/Construction/ConstructionSystem.Guided.cs b/Content.Server/Construction/ConstructionSystem.Guided.cs index b366705774..7e28110755 100644 --- a/Content.Server/Construction/ConstructionSystem.Guided.cs +++ b/Content.Server/Construction/ConstructionSystem.Guided.cs @@ -5,11 +5,14 @@ using Content.Shared.Construction.Steps; using Content.Shared.Examine; using Content.Shared.Popups; using Content.Shared.Verbs; +using Robust.Shared.Player; namespace Content.Server.Construction { public sealed partial class ConstructionSystem { + [Dependency] private readonly SharedPopupSystem _popup = default!; + private readonly Dictionary _guideCache = new(); private void InitializeGuided() @@ -49,11 +52,11 @@ namespace Content.Server.Construction if (component.TargetNode == null) { // Maybe check, but on the flip-side a better solution might be to not make it undeconstructible in the first place, no? - component.Owner.PopupMessage(args.User, Loc.GetString("deconstructible-verb-activate-no-target-text")); + _popup.PopupEntity(Loc.GetString("deconstructible-verb-activate-no-target-text"), uid, Filter.Entities(uid)); } else { - component.Owner.PopupMessage(args.User, Loc.GetString("deconstructible-verb-activate-text")); + _popup.PopupEntity(Loc.GetString("deconstructible-verb-activate-text"), args.User, Filter.Entities(args.User)); } }; @@ -94,7 +97,6 @@ namespace Content.Server.Construction if (!preventStepExamine && component.StepIndex < edge.Steps.Count) edge.Steps[component.StepIndex].DoExamine(args); - return; } } diff --git a/Content.Server/Construction/ConstructionSystem.Initial.cs b/Content.Server/Construction/ConstructionSystem.Initial.cs index 543a4264c9..c72140ba94 100644 --- a/Content.Server/Construction/ConstructionSystem.Initial.cs +++ b/Content.Server/Construction/ConstructionSystem.Initial.cs @@ -1,7 +1,6 @@ using System.IO; using System.Linq; using System.Threading.Tasks; -using Content.Server.Administration.Logs; using Content.Server.Construction.Components; using Content.Server.DoAfter; using Content.Server.Hands.Components; @@ -15,8 +14,8 @@ using Content.Shared.Database; using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; using Content.Shared.Inventory; -using Content.Shared.Popups; using Robust.Shared.Containers; +using Robust.Shared.Player; using Robust.Shared.Players; using Robust.Shared.Timing; @@ -82,7 +81,7 @@ namespace Content.Server.Construction foreach (var near in _lookupSystem.GetEntitiesInRange(user, 2f, LookupFlags.Approximate)) { - if (_interactionSystem.InRangeUnobstructed(pos, near, 2f) && _containerSystem.IsInSameOrParentContainer(user, near)) + if (_interactionSystem.InRangeUnobstructed(pos, near, 2f) && _container.IsInSameOrParentContainer(user, near)) yield return near; } } @@ -91,11 +90,11 @@ namespace Content.Server.Construction private async Task Construct(EntityUid user, string materialContainer, ConstructionGraphPrototype graph, ConstructionGraphEdge edge, ConstructionGraphNode targetNode) { // We need a place to hold our construction items! - var container = ContainerHelpers.EnsureContainer(user, materialContainer, out var existed); + var container = _container.EnsureContainer(user, materialContainer, out var existed); if (existed) { - user.PopupMessageCursor(Loc.GetString("construction-system-construct-cannot-start-another-construction")); + _popup.PopupCursor(Loc.GetString("construction-system-construct-cannot-start-another-construction"), Filter.Entities(user)); return null; } @@ -107,15 +106,16 @@ namespace Content.Server.Construction // But I'd rather do this shit than risk having collisions with other containers. Container GetContainer(string name) { - if (containers!.ContainsKey(name)) + if (containers.ContainsKey(name)) return containers[name]; while (true) { var random = _robustRandom.Next(); - var c = ContainerHelpers.EnsureContainer(user!, random.ToString(), out var existed); + var c = _container.EnsureContainer(user, random.ToString(), out var exists); - if (existed) continue; + if (exists) + continue; containers[name] = c; return c; @@ -124,12 +124,12 @@ namespace Content.Server.Construction void FailCleanup() { - foreach (var entity in container!.ContainedEntities.ToArray()) + foreach (var entity in container.ContainedEntities.ToArray()) { container.Remove(entity); } - foreach (var cont in containers!.Values) + foreach (var cont in containers.Values) { foreach (var entity in cont.ContainedEntities.ToArray()) { @@ -143,8 +143,8 @@ namespace Content.Server.Construction void ShutdownContainers() { - container!.Shutdown(); - foreach (var c in containers!.Values.ToArray()) + container.Shutdown(); + foreach (var c in containers.Values.ToArray()) { c.Shutdown(); } @@ -219,7 +219,7 @@ namespace Content.Server.Construction if (failed) { - user.PopupMessageCursor(Loc.GetString("construction-system-construct-no-materials")); + _popup.PopupCursor(Loc.GetString("construction-system-construct-no-materials"), Filter.Entities(user)); FailCleanup(); return null; } @@ -255,7 +255,7 @@ namespace Content.Server.Construction // We preserve the containers... foreach (var (name, cont) in containers) { - var newCont = ContainerHelpers.EnsureContainer(newEntity, name); + var newCont = _container.EnsureContainer(newEntity, name); foreach (var entity in cont.ContainedEntities.ToArray()) { @@ -306,10 +306,11 @@ namespace Content.Server.Construction var targetNode = constructionGraph.Nodes[constructionPrototype.TargetNode]; var pathFind = constructionGraph.Path(startNode.Name, targetNode.Name); - if (args.SenderSession.AttachedEntity is not {Valid: true} user || - !Get().CanInteract(user, null)) return; + if (args.SenderSession.AttachedEntity is not {Valid: true} user || _actionBlocker.CanInteract(user, null)) + return; - if (!EntityManager.TryGetComponent(user, out HandsComponent? hands)) return; + if (!HasComp(user)) + return; foreach (var condition in constructionPrototype.Conditions) { @@ -318,14 +319,18 @@ namespace Content.Server.Construction } if (pathFind == null) + { throw new InvalidDataException( $"Can't find path from starting node to target node in construction! Recipe: {ev.PrototypeName}"); + } var edge = startNode.GetEdge(pathFind[0].Name); if (edge == null) + { throw new InvalidDataException( $"Can't find edge from starting node to the next node in pathfinding! Recipe: {ev.PrototypeName}"); + } // No support for conditions here! @@ -370,9 +375,9 @@ namespace Content.Server.Construction return; } - if (user.IsInContainer()) + if (_container.IsEntityInContainer(user)) { - user.PopupMessageCursor(Loc.GetString("construction-system-inside-container")); + _popup.PopupCursor(Loc.GetString("construction-system-inside-container"), Filter.Entities(user)); return; } @@ -385,7 +390,7 @@ namespace Content.Server.Construction { if (!set.Add(ev.Ack)) { - user.PopupMessageCursor(Loc.GetString("construction-system-already-building")); + _popup.PopupCursor(Loc.GetString("construction-system-already-building"), Filter.Entities(user)); return; } } diff --git a/Content.Server/Construction/ConstructionSystem.Interactions.cs b/Content.Server/Construction/ConstructionSystem.Interactions.cs index ae3351234a..f55c8b5b77 100644 --- a/Content.Server/Construction/ConstructionSystem.Interactions.cs +++ b/Content.Server/Construction/ConstructionSystem.Interactions.cs @@ -340,7 +340,7 @@ namespace Content.Server.Construction construction.Containers.Add(store); // The container doesn't necessarily need to exist, so we ensure it. - _containerSystem.EnsureContainer(uid, store).Insert(insert); + _container.EnsureContainer(uid, store).Insert(insert); } else { diff --git a/Content.Server/Construction/ConstructionSystem.cs b/Content.Server/Construction/ConstructionSystem.cs index 677ad197b9..2de4145829 100644 --- a/Content.Server/Construction/ConstructionSystem.cs +++ b/Content.Server/Construction/ConstructionSystem.cs @@ -4,7 +4,7 @@ using Content.Server.Stack; using Content.Server.Tools; using Content.Shared.Construction; using JetBrains.Annotations; -using Robust.Shared.Containers; +using Robust.Server.Containers; using Robust.Shared.Prototypes; using Robust.Shared.Random; @@ -20,7 +20,7 @@ namespace Content.Server.Construction [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly DoAfterSystem _doAfterSystem = default!; - [Dependency] private readonly SharedContainerSystem _container = default!; + [Dependency] private readonly ContainerSystem _container = default!; [Dependency] private readonly StackSystem _stackSystem = default!; [Dependency] private readonly ToolSystem _toolSystem = default!; diff --git a/Content.Server/Construction/MachineFrameSystem.cs b/Content.Server/Construction/MachineFrameSystem.cs index 5e3a9ff09e..ef904ce784 100644 --- a/Content.Server/Construction/MachineFrameSystem.cs +++ b/Content.Server/Construction/MachineFrameSystem.cs @@ -4,12 +4,14 @@ using Content.Shared.Construction; using Content.Shared.Examine; using Content.Shared.Interaction; using Content.Shared.Tag; +using Robust.Server.GameObjects; using Robust.Shared.Containers; namespace Content.Server.Construction; public sealed class MachineFrameSystem : EntitySystem { + [Dependency] private readonly AppearanceSystem _appearance = default!; [Dependency] private readonly IComponentFactory _factory = default!; [Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly TagSystem _tag = default!; @@ -47,7 +49,7 @@ public sealed class MachineFrameSystem : EntitySystem { if (!component.HasBoard && TryComp(args.Used, out var machineBoard)) { - if (args.Used.TryRemoveFromContainer()) + if (_container.TryRemoveFromContainer(args.Used)) { // Valid board! component.BoardContainer.Insert(args.Used); @@ -55,8 +57,7 @@ public sealed class MachineFrameSystem : EntitySystem // Setup requirements and progress... ResetProgressAndRequirements(component, machineBoard); - if (TryComp(uid, out var appearance)) - appearance.SetData(MachineFrameVisuals.State, 2); + _appearance.SetData(uid, MachineFrameVisuals.State, 2); if (TryComp(uid, out ConstructionComponent? construction)) { @@ -73,7 +74,7 @@ public sealed class MachineFrameSystem : EntitySystem return; if (component.Progress[machinePart.PartType] != component.Requirements[machinePart.PartType] - && args.Used.TryRemoveFromContainer() && component.PartContainer.Insert(args.Used)) + && _container.TryRemoveFromContainer(args.Used) && component.PartContainer.Insert(args.Used)) { component.Progress[machinePart.PartType]++; args.Handled = true; @@ -127,7 +128,8 @@ public sealed class MachineFrameSystem : EntitySystem if (!HasComp(args.Used, registration.Type)) continue; - if (!args.Used.TryRemoveFromContainer() || !component.PartContainer.Insert(args.Used)) continue; + if (!_container.TryRemoveFromContainer(args.Used) || !component.PartContainer.Insert(args.Used)) + continue; component.ComponentProgress[compName]++; args.Handled = true; return; @@ -141,7 +143,8 @@ public sealed class MachineFrameSystem : EntitySystem if (!_tag.HasTag(args.Used, tagName)) continue; - if (!args.Used.TryRemoveFromContainer() || !component.PartContainer.Insert(args.Used)) continue; + if (!_container.TryRemoveFromContainer(args.Used) || !component.PartContainer.Insert(args.Used)) + continue; component.TagProgress[tagName]++; args.Handled = true; return; @@ -216,11 +219,9 @@ public sealed class MachineFrameSystem : EntitySystem public void RegenerateProgress(MachineFrameComponent component) { - AppearanceComponent? appearance; - if (!component.HasBoard) { - if (TryComp(component.Owner, out appearance)) appearance.SetData(MachineFrameVisuals.State, 1); + _appearance.SetData(component.Owner, MachineFrameVisuals.State, 1); component.TagRequirements.Clear(); component.MaterialRequirements.Clear(); @@ -239,7 +240,7 @@ public sealed class MachineFrameSystem : EntitySystem if (!TryComp(board, out var machineBoard)) return; - if (TryComp(component.Owner, out appearance)) appearance.SetData(MachineFrameVisuals.State, 2); + _appearance.SetData(component.Owner, MachineFrameVisuals.State, 2); ResetProgressAndRequirements(component, machineBoard); diff --git a/Content.Server/Construction/MachinePartSystem.cs b/Content.Server/Construction/MachinePartSystem.cs index acd6695269..b282a9a2e8 100644 --- a/Content.Server/Construction/MachinePartSystem.cs +++ b/Content.Server/Construction/MachinePartSystem.cs @@ -24,7 +24,7 @@ namespace Content.Server.Construction { args.PushMarkup(Loc.GetString("machine-board-component-required-element-entry-text", ("amount", amount), - ("requiredElement", Loc.GetString(part.ToString())))); + ("requiredElement", Loc.GetString(part)))); } foreach (var (material, amount) in component.MaterialRequirements) diff --git a/Content.Server/Construction/RefiningSystem.cs b/Content.Server/Construction/RefiningSystem.cs index 2d92c1bd80..c259837255 100644 --- a/Content.Server/Construction/RefiningSystem.cs +++ b/Content.Server/Construction/RefiningSystem.cs @@ -19,7 +19,7 @@ namespace Content.Server.Construction private async void OnInteractUsing(EntityUid uid, WelderRefinableComponent component, InteractUsingEvent args) { // check if object is welder - if (!TryComp(args.Used, out ToolComponent? tool)) + if (!HasComp(args.Used)) return; // check if someone is already welding object diff --git a/Content.Shared/Construction/Conditions/EmptyOrWindowValidInTile.cs b/Content.Shared/Construction/Conditions/EmptyOrWindowValidInTile.cs index f5a984102c..0f0852204e 100644 --- a/Content.Shared/Construction/Conditions/EmptyOrWindowValidInTile.cs +++ b/Content.Shared/Construction/Conditions/EmptyOrWindowValidInTile.cs @@ -27,9 +27,9 @@ namespace Content.Shared.Construction.Conditions return result; } - public ConstructionGuideEntry? GenerateGuideEntry() + public ConstructionGuideEntry GenerateGuideEntry() { - return new ConstructionGuideEntry() + return new ConstructionGuideEntry { Localization = "construction-guide-condition-empty-or-window-valid-in-tile" }; diff --git a/Content.Shared/Construction/Conditions/NoWindowsInTile.cs b/Content.Shared/Construction/Conditions/NoWindowsInTile.cs index 4ceb3feed7..8ee95809a0 100644 --- a/Content.Shared/Construction/Conditions/NoWindowsInTile.cs +++ b/Content.Shared/Construction/Conditions/NoWindowsInTile.cs @@ -22,9 +22,9 @@ namespace Content.Shared.Construction.Conditions return true; } - public ConstructionGuideEntry? GenerateGuideEntry() + public ConstructionGuideEntry GenerateGuideEntry() { - return new ConstructionGuideEntry() + return new ConstructionGuideEntry { Localization = "construction-step-condition-no-windows-in-tile" }; diff --git a/Content.Shared/Construction/Conditions/TileNotBlocked.cs b/Content.Shared/Construction/Conditions/TileNotBlocked.cs index 02fecafd21..cf6d3435cd 100644 --- a/Content.Shared/Construction/Conditions/TileNotBlocked.cs +++ b/Content.Shared/Construction/Conditions/TileNotBlocked.cs @@ -21,9 +21,9 @@ namespace Content.Shared.Construction.Conditions return !tileRef.Value.IsBlockedTurf(_filterMobs); } - public ConstructionGuideEntry? GenerateGuideEntry() + public ConstructionGuideEntry GenerateGuideEntry() { - return new ConstructionGuideEntry() + return new ConstructionGuideEntry { Localization = "construction-step-condition-tile-not-blocked", }; diff --git a/Content.Shared/Construction/Conditions/TileType.cs b/Content.Shared/Construction/Conditions/TileType.cs index 8a4421168e..60385b0ff3 100644 --- a/Content.Shared/Construction/Conditions/TileType.cs +++ b/Content.Shared/Construction/Conditions/TileType.cs @@ -13,15 +13,13 @@ namespace Content.Shared.Construction.Conditions public List TargetTiles { get; } = new(); [DataField("guideText")] - public string? GuideText = null; + public string? GuideText; [DataField("guideIcon")] - public SpriteSpecifier? GuideIcon = null; + public SpriteSpecifier? GuideIcon; public bool Condition(EntityUid user, EntityCoordinates location, Direction direction) { - if (TargetTiles == null) return true; - var tileFound = location.GetTileRef(); if (tileFound == null) @@ -30,9 +28,8 @@ namespace Content.Shared.Construction.Conditions var tile = tileFound.Value.Tile.GetContentTileDefinition(); foreach (var targetTile in TargetTiles) { - if (tile.ID == targetTile) { + if (tile.ID == targetTile) return true; - } } return false; } diff --git a/Content.Shared/Construction/Conditions/WallmountCondition.cs b/Content.Shared/Construction/Conditions/WallmountCondition.cs index 8639a52a35..f75b946547 100644 --- a/Content.Shared/Construction/Conditions/WallmountCondition.cs +++ b/Content.Shared/Construction/Conditions/WallmountCondition.cs @@ -51,7 +51,7 @@ namespace Content.Shared.Construction.Conditions // check that we didn't try to build wallmount that facing another adjacent wall var rAdjWall = new CollisionRay(objWorldPosition, directionWithOffset.Normalized, (int) CollisionGroup.Impassable); var adjWallRaycastResults = physics.IntersectRayWithPredicate(entManager.GetComponent(user).MapID, rAdjWall, maxLength: 0.5f, - predicate: (e) => e == targetWall.Value.HitEntity || !tagSystem.HasTag(e, "Wall")); + predicate: e => e == targetWall.Value.HitEntity || !tagSystem.HasTag(e, "Wall")); return !adjWallRaycastResults.Any(); } diff --git a/Content.Shared/Construction/EntitySystems/SharedAnchorableSystem.cs b/Content.Shared/Construction/EntitySystems/SharedAnchorableSystem.cs index 398a8c51d5..7c8a8620f9 100644 --- a/Content.Shared/Construction/EntitySystems/SharedAnchorableSystem.cs +++ b/Content.Shared/Construction/EntitySystems/SharedAnchorableSystem.cs @@ -36,6 +36,5 @@ public abstract class SharedAnchorableSystem : EntitySystem ToolComponent? usingTool = null) { // Thanks tool system. - return; } } diff --git a/Content.Shared/Construction/Steps/ArbitraryInsertConstructionGraphStep.cs b/Content.Shared/Construction/Steps/ArbitraryInsertConstructionGraphStep.cs index ff057b2ff0..a6a7719fbe 100644 --- a/Content.Shared/Construction/Steps/ArbitraryInsertConstructionGraphStep.cs +++ b/Content.Shared/Construction/Steps/ArbitraryInsertConstructionGraphStep.cs @@ -7,7 +7,7 @@ namespace Content.Shared.Construction.Steps { [DataField("name")] public string Name { get; private set; } = string.Empty; - [DataField("icon")] public SpriteSpecifier? Icon { get; private set; } = null; + [DataField("icon")] public SpriteSpecifier? Icon { get; private set; } public override void DoExamine(ExaminedEvent examinedEvent) { @@ -19,7 +19,7 @@ namespace Content.Shared.Construction.Steps public override ConstructionGuideEntry GenerateGuideEntry() { - return new ConstructionGuideEntry() + return new ConstructionGuideEntry { Localization = "construction-presenter-arbitrary-step", Arguments = new (string, object)[]{("name", Name)}, diff --git a/Content.Shared/Construction/Steps/ConstructionGraphStepTypeSerializer.cs b/Content.Shared/Construction/Steps/ConstructionGraphStepTypeSerializer.cs index 7cd2b57947..b113afe384 100644 --- a/Content.Shared/Construction/Steps/ConstructionGraphStepTypeSerializer.cs +++ b/Content.Shared/Construction/Steps/ConstructionGraphStepTypeSerializer.cs @@ -57,7 +57,8 @@ namespace Content.Shared.Construction.Steps { var type = GetType(node); - if (type == null) return new ErrorNode(node, "No construction graph step type found.", true); + if (type == null) + return new ErrorNode(node, "No construction graph step type found."); return serializationManager.ValidateNode(type, node, context); } diff --git a/Content.Shared/Construction/Steps/MultipleTagsConstructionGraphStep.cs b/Content.Shared/Construction/Steps/MultipleTagsConstructionGraphStep.cs index da55054a8e..59b371000d 100644 --- a/Content.Shared/Construction/Steps/MultipleTagsConstructionGraphStep.cs +++ b/Content.Shared/Construction/Steps/MultipleTagsConstructionGraphStep.cs @@ -25,7 +25,7 @@ namespace Content.Shared.Construction.Steps if (!entityManager.TryGetComponent(uid, out TagComponent? tags)) return false; - var tagSystem = EntitySystem.Get(); + var tagSystem = entityManager.EntitySysManager.GetEntitySystem(); if (_allTags != null && !tagSystem.HasAllTags(tags, _allTags)) return false; // We don't have all the tags needed. diff --git a/Resources/Prototypes/Entities/Structures/Machines/frame.yml b/Resources/Prototypes/Entities/Structures/Machines/frame.yml index e300a9d47b..d694aa4aa3 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/frame.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/frame.yml @@ -29,6 +29,10 @@ - type: Construction graph: Machine node: missingWires + - type: ContainerContainer + containers: + machine_board: !type:Container + machine_parts: !type:Container - type: Damageable damageContainer: Inorganic damageModifierSet: Metallic @@ -76,6 +80,7 @@ - type: Construction graph: Machine node: machineFrame + defaultTarget: machine - type: Damageable damageContainer: Inorganic damageModifierSet: Metallic @@ -90,6 +95,10 @@ - !type:DoActsBehavior acts: ["Destruction"] - type: MachineFrame + - type: ContainerContainer + containers: + machine_board: !type:Container + machine_parts: !type:Container - type: Sprite netsync: false sprite: Structures/Machines/parts.rsi