Construction warning cleanup (#12256)

This commit is contained in:
Nemanja
2022-10-30 02:48:53 -04:00
committed by GitHub
parent 1a6d084c4d
commit b6135d3be5
47 changed files with 166 additions and 146 deletions

View File

@@ -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
{

View File

@@ -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
/// <summary>
/// Constructs a new instance of <see cref="ConstructionMenuPresenter" />.
/// </summary>
/// <param name="gameHud">GUI that is being presented to.</param>
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<SpriteSystem>();
_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<SpriteSystem>();
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<ConstructionSystem>();
var constructSystem = _systemManager.GetEntitySystem<ConstructionSystem>();
_placementManager.BeginPlacing(new PlacementInformation()
{

View File

@@ -103,7 +103,6 @@ public sealed class PrototypeSaveTest
"CrateArtifactContainer",
"CloningPod",
"DrinkColaCan",
"MachineFrame",
"WeaponImprovisedPneumaticCannon",
"LauncherCreamPie",
"GravityGenerator",

View File

@@ -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;
}
/// <summary>

View File

@@ -63,7 +63,7 @@ namespace Content.Server.Construction.Commands
}
var changed = 0;
var tagSystem = EntitySystem.Get<TagSystem>();
var tagSystem = entityManager.EntitySysManager.GetEntitySystem<TagSystem>();
foreach (var child in xformQuery.GetComponent(grid.GridEntityId).ChildEntities)
{

View File

@@ -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<IEntityManager>();
EntityUid? gridId;
string tileIdA = "";
string tileIdB = "";
string tileIdA;
string tileIdB;
switch (args.Length)
{

View File

@@ -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} <gridId> | {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<ITileDefinitionManager>();
var tagSystem = EntitySystem.Get<TagSystem>();
var underplating = tileDefinitionManager[TilePrototypeID];
var tagSystem = entityManager.EntitySysManager.GetEntitySystem<TagSystem>();
var underplating = tileDefinitionManager[TilePrototypeId];
var underplatingTile = new Tile(underplating.TileId);
var changed = 0;
foreach (var child in entityManager.GetComponent<TransformComponent>(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;
}

View File

@@ -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)
{

View File

@@ -11,7 +11,7 @@ namespace Content.Server.Construction.Completions
if (userUid == null)
return;
EntitySystem.Get<ElectrocutionSystem>().TryDoElectrifiedAct(uid, userUid.Value);
entityManager.EntitySysManager.GetEntitySystem<ElectrocutionSystem>().TryDoElectrifiedAct(uid, userUid.Value);
}
}
}

View File

@@ -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<MachineFrameSystem>().IsComplete(machineFrame))
if (!entityManager.EntitySysManager.GetEntitySystem<MachineFrameSystem>().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<ContainerSystem>();
var transform = entityManager.GetComponent<TransformComponent>(uid);
var machine = entityManager.SpawnEntity(boardComponent.Prototype, transform.Coordinates);
entityManager.GetComponent<TransformComponent>(machine).LocalRotation = transform.LocalRotation;
var boardContainer = machine.EnsureContainer<Container>(MachineFrameComponent.BoardContainerName, out var existed);
var boardContainer = containerSys.EnsureContainer<Container>(machine, MachineFrameComponent.BoardContainerName, out var existed);
if (existed)
{
// Clean that up...
boardContainer.CleanContainer();
containerSys.CleanContainer(boardContainer);
}
var partContainer = machine.EnsureContainer<Container>(MachineFrameComponent.PartContainerName, out existed);
var partContainer = containerSys.EnsureContainer<Container>(machine, MachineFrameComponent.PartContainerName, out existed);
if (existed)
{
// Clean that up, too...
partContainer.CleanContainer();
containerSys.CleanContainer(partContainer);
}
boardContainer.Insert(board);

View File

@@ -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)
{

View File

@@ -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<ContainerSystem>();
if (!containerSys.TryGetContainer(uid, Container, out var container))
return;
foreach (var contained in container.ContainedEntities.ToArray())
{

View File

@@ -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<TransformComponent>(uid);
var containerSys = entityManager.EntitySysManager.GetEntitySystem<ContainerSystem>();
foreach (var container in containerManager.GetAllContainers())
{
container.EmptyContainer(true, transform.Coordinates);
containerSys.EmptyContainer(container, true, transform.Coordinates);
}
}
}

View File

@@ -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<ContainerSystem>();
var transform = entityManager.GetComponent<TransformComponent>(uid);
foreach (var contained in container.ContainedEntities.ToArray())
{
container.ForceRemove(contained);
var cTransform = entityManager.GetComponent<TransformComponent>(contained);
cTransform.Coordinates = transform.Coordinates;
cTransform.AttachToGridOrMap();
}
containerSys.EmptyContainer(container, true, transform.Coordinates, true);
}
}
}

View File

@@ -12,7 +12,7 @@ namespace Content.Server.Construction.Completions
{
if (entityManager.TryGetComponent<MachineFrameComponent>(uid, out var machineFrame))
{
EntitySystem.Get<MachineFrameSystem>().RegenerateProgress(machineFrame);
entityManager.EntitySysManager.GetEntitySystem<MachineFrameSystem>().RegenerateProgress(machineFrame);
}
}
}

View File

@@ -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)
{

View File

@@ -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<IRobustRandom>().NextGaussian(1, Variation);
SoundSystem.Play(Sound.GetSound(), Filter.Pvs(uid, entityManager: entityManager), uid, AudioParams.WithPitchScale(scale));
entityManager.EntitySysManager.GetEntitySystem<SharedAudioSystem>()
.PlayPvs(Sound, uid, AudioParams.WithPitchScale(scale));
}
}
}

View File

@@ -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)

View File

@@ -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);

View File

@@ -12,7 +12,7 @@ namespace Content.Server.Construction.Completions
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
EntitySystem.Get<StackSystem>().SetCount(uid, Amount);
entityManager.EntitySysManager.GetEntitySystem<StackSystem>().SetCount(uid, Amount);
}
}
}

View File

@@ -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)
{

View File

@@ -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);
}

View File

@@ -11,7 +11,7 @@ namespace Content.Server.Construction.Components
public sealed class WelderRefinableComponent : Component
{
[DataField("refineResult")]
public HashSet<string>? RefineResult = new() { };
public HashSet<string>? RefineResult = new();
[DataField("refineTime")]
public float RefineTime = 2f;

View File

@@ -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<MetaDataComponent>(entity).EntityName)) + "\n");
else
args.PushMarkup(Loc.GetString("construction-examine-condition-airlock-unbolt", ("entityName", entMan.GetComponent<MetaDataComponent>(entity).EntityName)) + "\n");

View File

@@ -47,7 +47,8 @@ namespace Content.Server.Construction.Conditions
return false;
var indices = transform.Coordinates.ToVector2i(entityManager, IoCManager.Resolve<IMapManager>());
var entities = indices.GetEntitiesInTile(transform.GridUid.Value, LookupFlags.Approximate | LookupFlags.Anchored, EntitySystem.Get<EntityLookupSystem>());
var lookup = entityManager.EntitySysManager.GetEntitySystem<EntityLookupSystem>();
var entities = indices.GetEntitiesInTile(transform.GridUid.Value, LookupFlags.Approximate | LookupFlags.Anchored, lookup);
foreach (var ent in entities)
{

View File

@@ -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<MetaDataComponent>(entity).EntityName)) + "\n");
else
args.PushMarkup(Loc.GetString("construction-examine-condition-door-unweld", ("entityName", entMan.GetComponent<MetaDataComponent>(entity).EntityName)) + "\n");

View File

@@ -25,14 +25,16 @@ namespace Content.Server.Construction.Conditions
if (!entityManager.TryGetComponent(uid, out MachineFrameComponent? machineFrame))
return false;
return EntitySystem.Get<MachineFrameSystem>().IsComplete(machineFrame);
return entityManager.EntitySysManager.GetEntitySystem<MachineFrameSystem>().IsComplete(machineFrame);
}
public bool DoExamine(ExaminedEvent args)
{
var entity = args.Examined;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<MachineFrameComponent?>(entity, out var machineFrame))
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetComponent<MachineFrameComponent?>(entity, out var machineFrame))
return false;
if (!machineFrame.HasBoard)
@@ -41,18 +43,20 @@ namespace Content.Server.Construction.Conditions
return true;
}
if (EntitySystem.Get<MachineFrameSystem>().IsComplete(machineFrame)) return false;
if (entityManager.EntitySysManager.GetEntitySystem<MachineFrameSystem>().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),

View File

@@ -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");

View File

@@ -7,6 +7,8 @@ namespace Content.Server.Construction;
public sealed partial class ConstructionSystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
private void InitializeComputer()
{
SubscribeLocalEvent<ComputerComponent, ComponentInit>(OnCompInit);
@@ -19,10 +21,9 @@ public sealed partial class ConstructionSystem
// Let's ensure the container manager and container are here.
_container.EnsureContainer<Container>(uid, "board");
if (TryComp<ApcPowerReceiverComponent>(uid, out var powerReceiver) &&
TryComp<AppearanceComponent>(uid, out var appearance))
if (TryComp<ApcPowerReceiverComponent>(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<AppearanceComponent>(uid, out var appearance))
{
appearance.SetData(ComputerVisuals.Powered, args.Powered);
}
_appearance.SetData(uid, ComputerVisuals.Powered, args.Powered);
}
/// <summary>

View File

@@ -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<Container>(newUid, container, newContainerManager);
var otherContainer = _container.EnsureContainer<Container>(newUid, container, newContainerManager);
for (var i = ourContainer.ContainedEntities.Count - 1; i >= 0; i--)
{

View File

@@ -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<ConstructionPrototype, ConstructionGuide> _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;
}
}

View File

@@ -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<EntityUid?> Construct(EntityUid user, string materialContainer, ConstructionGraphPrototype graph, ConstructionGraphEdge edge, ConstructionGraphNode targetNode)
{
// We need a place to hold our construction items!
var container = ContainerHelpers.EnsureContainer<Container>(user, materialContainer, out var existed);
var container = _container.EnsureContainer<Container>(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<Container>(user!, random.ToString(), out var existed);
var c = _container.EnsureContainer<Container>(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<Container>(newEntity, name);
var newCont = _container.EnsureContainer<Container>(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<ActionBlockerSystem>().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<HandsComponent>(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;
}
}

View File

@@ -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<Container>(uid, store).Insert(insert);
_container.EnsureContainer<Container>(uid, store).Insert(insert);
}
else
{

View File

@@ -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!;

View File

@@ -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<MachineBoardComponent?>(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<AppearanceComponent?>(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<MachineBoardComponent>(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);

View File

@@ -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)

View File

@@ -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<ToolComponent>(args.Used))
return;
// check if someone is already welding object

View File

@@ -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"
};

View File

@@ -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"
};

View File

@@ -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",
};

View File

@@ -13,15 +13,13 @@ namespace Content.Shared.Construction.Conditions
public List<string> 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;
}

View File

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

View File

@@ -36,6 +36,5 @@ public abstract class SharedAnchorableSystem : EntitySystem
ToolComponent? usingTool = null)
{
// Thanks tool system.
return;
}
}

View File

@@ -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)},

View File

@@ -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);
}

View File

@@ -25,7 +25,7 @@ namespace Content.Shared.Construction.Steps
if (!entityManager.TryGetComponent(uid, out TagComponent? tags))
return false;
var tagSystem = EntitySystem.Get<TagSystem>();
var tagSystem = entityManager.EntitySysManager.GetEntitySystem<TagSystem>();
if (_allTags != null && !tagSystem.HasAllTags(tags, _allTags))
return false; // We don't have all the tags needed.

View File

@@ -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