diff --git a/Content.Server/Construction/Conditions/AirlockBolted.cs b/Content.Server/Construction/Conditions/AirlockBolted.cs index 7da5dc5073..29b4e75d64 100644 --- a/Content.Server/Construction/Conditions/AirlockBolted.cs +++ b/Content.Server/Construction/Conditions/AirlockBolted.cs @@ -6,6 +6,7 @@ using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Utility; using System.Threading.Tasks; using Content.Server.Doors.Components; +using Content.Shared.Examine; namespace Content.Server.Construction.Conditions { @@ -23,16 +24,18 @@ namespace Content.Server.Construction.Conditions return airlock.BoltsDown == Value; } - public bool DoExamine(IEntity entity, FormattedMessage message, bool inDetailsRange) + public bool DoExamine(ExaminedEvent args) { + var entity = args.Examined; + if (!entity.TryGetComponent(out AirlockComponent? airlock)) return false; if (airlock.BoltsDown != Value) { if (Value == true) - message.AddMarkup(Loc.GetString("construction-condition-airlock-bolt", ("entityName", entity.Name)) + "\n"); + args.PushMarkup(Loc.GetString("construction-condition-airlock-bolt", ("entityName", entity.Name)) + "\n"); else - message.AddMarkup(Loc.GetString("construction-condition-airlock-unbolt", ("entityName", entity.Name)) + "\n"); + args.PushMarkup(Loc.GetString("construction-condition-airlock-unbolt", ("entityName", entity.Name)) + "\n"); return true; } diff --git a/Content.Server/Construction/Conditions/AllConditions.cs b/Content.Server/Construction/Conditions/AllConditions.cs index 21db036f0f..c63b3efbe3 100644 --- a/Content.Server/Construction/Conditions/AllConditions.cs +++ b/Content.Server/Construction/Conditions/AllConditions.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Content.Shared.Construction; +using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; @@ -24,5 +25,17 @@ namespace Content.Server.Construction.Conditions return true; } + + public bool DoExamine(ExaminedEvent args) + { + var ret = false; + + foreach (var condition in Conditions) + { + ret |= condition.DoExamine(args); + } + + return ret; + } } } diff --git a/Content.Server/Construction/Conditions/AllWiresCut.cs b/Content.Server/Construction/Conditions/AllWiresCut.cs index 0137c057fc..7ec60c9aaa 100644 --- a/Content.Server/Construction/Conditions/AllWiresCut.cs +++ b/Content.Server/Construction/Conditions/AllWiresCut.cs @@ -2,6 +2,7 @@ using Content.Server.GameObjects.Components; using Content.Server.WireHacking; using Content.Shared.Construction; +using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; @@ -38,5 +39,7 @@ namespace Content.Server.Construction.Conditions return true; } + + // TODO CONSTRUCTION: Examine for this condition. } } diff --git a/Content.Server/Construction/Conditions/AnyConditions.cs b/Content.Server/Construction/Conditions/AnyConditions.cs index b8fe9a51f2..2aa9fc96c6 100644 --- a/Content.Server/Construction/Conditions/AnyConditions.cs +++ b/Content.Server/Construction/Conditions/AnyConditions.cs @@ -24,5 +24,7 @@ namespace Content.Server.Construction.Conditions return false; } + + // TODO CONSTRUCTION: Examine for this condition. } } diff --git a/Content.Server/Construction/Conditions/ComponentInTile.cs b/Content.Server/Construction/Conditions/ComponentInTile.cs index 40c50cc265..50692b3bd1 100644 --- a/Content.Server/Construction/Conditions/ComponentInTile.cs +++ b/Content.Server/Construction/Conditions/ComponentInTile.cs @@ -55,5 +55,7 @@ namespace Content.Server.Construction.Conditions return !HasEntity; } + + // TODO CONSTRUCTION: Custom examine for this condition. } } diff --git a/Content.Server/Construction/Conditions/ContainerEmpty.cs b/Content.Server/Construction/Conditions/ContainerEmpty.cs index 88ca0ba042..8bfc1878ab 100644 --- a/Content.Server/Construction/Conditions/ContainerEmpty.cs +++ b/Content.Server/Construction/Conditions/ContainerEmpty.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Content.Shared.Construction; +using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.Containers; using Robust.Shared.GameObjects; @@ -23,15 +24,17 @@ namespace Content.Server.Construction.Conditions return container.ContainedEntities.Count == 0; } - public bool DoExamine(IEntity entity, FormattedMessage message, bool inDetailsRange) + public bool DoExamine(ExaminedEvent args) { + var entity = args.Examined; + if (!entity.TryGetComponent(out ContainerManagerComponent? containerManager) || !containerManager.TryGetContainer(Container, out var container)) return false; if (container.ContainedEntities.Count == 0) return false; - message.AddMarkup(Text); + args.PushMarkup(Text); return true; } diff --git a/Content.Server/Construction/Conditions/ContainerNotEmpty.cs b/Content.Server/Construction/Conditions/ContainerNotEmpty.cs index 13c129fdf7..15e3a6c5c2 100644 --- a/Content.Server/Construction/Conditions/ContainerNotEmpty.cs +++ b/Content.Server/Construction/Conditions/ContainerNotEmpty.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Content.Shared.Construction; +using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.Containers; using Robust.Shared.GameObjects; @@ -23,15 +24,17 @@ namespace Content.Server.Construction.Conditions return container.ContainedEntities.Count != 0; } - public bool DoExamine(IEntity entity, FormattedMessage message, bool inDetailsRange) + public bool DoExamine(ExaminedEvent args) { + var entity = args.Examined; + if (!entity.TryGetComponent(out ContainerManagerComponent? containerManager) || !containerManager.TryGetContainer(Container, out var container)) return false; if (container.ContainedEntities.Count != 0) return false; - message.AddMarkup(Text); + args.PushMarkup(Text); return true; } diff --git a/Content.Server/Construction/Conditions/DoorWelded.cs b/Content.Server/Construction/Conditions/DoorWelded.cs index 6d51f2d3b1..89e7fd0fe5 100644 --- a/Content.Server/Construction/Conditions/DoorWelded.cs +++ b/Content.Server/Construction/Conditions/DoorWelded.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Content.Server.Doors.Components; using Content.Shared.Construction; +using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.Localization; @@ -24,16 +25,18 @@ namespace Content.Server.Construction.Conditions return doorComponent.IsWeldedShut == Welded; } - public bool DoExamine(IEntity entity, FormattedMessage message, bool inDetailsRange) + public bool DoExamine(ExaminedEvent args) { + var entity = args.Examined; + if (!entity.TryGetComponent(out ServerDoorComponent? door)) return false; if (door.IsWeldedShut != Welded) { if (Welded == true) - message.AddMarkup(Loc.GetString("construction-condition-door-weld", ("entityName", entity.Name)) + "\n"); + args.PushMarkup(Loc.GetString("construction-condition-door-weld", ("entityName", entity.Name)) + "\n"); else - message.AddMarkup(Loc.GetString("construction-condition-door-unweld", ("entityName", entity.Name)) + "\n"); + args.PushMarkup(Loc.GetString("construction-condition-door-unweld", ("entityName", entity.Name)) + "\n"); return true; } diff --git a/Content.Server/Construction/Conditions/EntityAnchored.cs b/Content.Server/Construction/Conditions/EntityAnchored.cs index 74128dc611..09f8e39ba7 100644 --- a/Content.Server/Construction/Conditions/EntityAnchored.cs +++ b/Content.Server/Construction/Conditions/EntityAnchored.cs @@ -1,10 +1,10 @@ using System.Threading.Tasks; using Content.Shared.Construction; +using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.Physics; using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.Utility; namespace Content.Server.Construction.Conditions { @@ -21,17 +21,17 @@ namespace Content.Server.Construction.Conditions return (physics.BodyType == BodyType.Static && Anchored) || (physics.BodyType != BodyType.Static && !Anchored); } - public bool DoExamine(IEntity entity, FormattedMessage message, bool inDetailsRange) + public bool DoExamine(ExaminedEvent args) { - if (!entity.TryGetComponent(out IPhysBody? physics)) return false; + var entity = args.Examined; switch (Anchored) { - case true when physics.BodyType != BodyType.Static: - message.AddMarkup("First, anchor it.\n"); + case true when !entity.Transform.Anchored: + args.PushMarkup("First, anchor it."); return true; - case false when physics.BodyType == BodyType.Static: - message.AddMarkup("First, unanchor it.\n"); + case false when entity.Transform.Anchored: + args.PushMarkup("First, unanchor it."); return true; } diff --git a/Content.Server/Construction/Conditions/MachineFrameComplete.cs b/Content.Server/Construction/Conditions/MachineFrameComplete.cs index ebb0fb7bf7..7ffb8a8ee7 100644 --- a/Content.Server/Construction/Conditions/MachineFrameComplete.cs +++ b/Content.Server/Construction/Conditions/MachineFrameComplete.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Content.Server.Construction.Components; using Content.Shared.Construction; +using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.Localization; @@ -24,30 +25,32 @@ namespace Content.Server.Construction.Conditions return machineFrame.IsComplete; } - public bool DoExamine(IEntity entity, FormattedMessage message, bool inDetailsRange) + public bool DoExamine(ExaminedEvent args) { + var entity = args.Examined; + if (!entity.TryGetComponent(out var machineFrame)) return false; if (!machineFrame.HasBoard) { - message.AddMarkup(Loc.GetString("construction-condition-machine-frame-insert-circuit-board-message")); + args.PushMarkup(Loc.GetString("construction-condition-machine-frame-insert-circuit-board-message")); return true; } if (machineFrame.IsComplete) return false; - message.AddMarkup(Loc.GetString("construction-condition-machine-frame-requirement-label") + "\n"); + 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; - message.AddMarkup(Loc.GetString("construction-condition-machine-frame-required-element-entry", - ("amount", amount), - ("elementName", Loc.GetString(part.ToString()))) - + "\n"); + args.Message.AddMarkup(Loc.GetString("construction-condition-machine-frame-required-element-entry", + ("amount", amount), + ("elementName", Loc.GetString(part.ToString()))) + + "\n"); } foreach (var (material, required) in machineFrame.MaterialRequirements) @@ -56,10 +59,10 @@ namespace Content.Server.Construction.Conditions if(amount == 0) continue; - message.AddMarkup(Loc.GetString("construction-condition-machine-frame-required-element-entry", - ("amount", amount), - ("elementName", Loc.GetString(material.ToString()))) - + "\n"); + args.Message.AddMarkup(Loc.GetString("construction-condition-machine-frame-required-element-entry", + ("amount", amount), + ("elementName", Loc.GetString(material.ToString()))) + + "\n"); } foreach (var (compName, info) in machineFrame.ComponentRequirements) @@ -68,7 +71,7 @@ namespace Content.Server.Construction.Conditions if(amount == 0) continue; - message.AddMarkup(Loc.GetString("construction-condition-machine-frame-required-element-entry", + args.Message.AddMarkup(Loc.GetString("construction-condition-machine-frame-required-element-entry", ("amount", info.Amount), ("elementName", Loc.GetString(info.ExamineName))) + "\n"); @@ -80,10 +83,10 @@ namespace Content.Server.Construction.Conditions if(amount == 0) continue; - message.AddMarkup(Loc.GetString("construction-condition-machine-frame-required-element-entry", - ("amount", info.Amount), - ("elementName", Loc.GetString(info.ExamineName))) - + "\n"); + args.Message.AddMarkup(Loc.GetString("construction-condition-machine-frame-required-element-entry", + ("amount", info.Amount), + ("elementName", Loc.GetString(info.ExamineName))) + + "\n"); } return true; diff --git a/Content.Server/Construction/Conditions/ToiletLidClosed.cs b/Content.Server/Construction/Conditions/ToiletLidClosed.cs index 2f9cba7506..6671868c77 100644 --- a/Content.Server/Construction/Conditions/ToiletLidClosed.cs +++ b/Content.Server/Construction/Conditions/ToiletLidClosed.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Content.Server.Toilet; using Content.Shared.Construction; +using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.Localization; @@ -19,12 +20,14 @@ namespace Content.Server.Construction.Conditions return !toilet.LidOpen; } - public bool DoExamine(IEntity entity, FormattedMessage message, bool inExamineRange) + public bool DoExamine(ExaminedEvent args) { + var entity = args.Examined; + if (!entity.TryGetComponent(out ToiletComponent? toilet)) return false; if (!toilet.LidOpen) return false; - message.AddMarkup(Loc.GetString("construction-condition-toilet-lid-closed") + "\n"); + args.PushMarkup(Loc.GetString("construction-condition-toilet-lid-closed") + "\n"); return true; } } diff --git a/Content.Server/Construction/Conditions/WirePanel.cs b/Content.Server/Construction/Conditions/WirePanel.cs index c443506a2e..66920d2354 100644 --- a/Content.Server/Construction/Conditions/WirePanel.cs +++ b/Content.Server/Construction/Conditions/WirePanel.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using Content.Server.GameObjects.Components; using Content.Server.WireHacking; using Content.Shared.Construction; +using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.Localization; @@ -23,17 +24,19 @@ namespace Content.Server.Construction.Conditions return wires.IsPanelOpen == Open; } - public bool DoExamine(IEntity entity, FormattedMessage message, bool inDetailsRange) + public bool DoExamine(ExaminedEvent args) { + var entity = args.Examined; + if (!entity.TryGetComponent(out WiresComponent? wires)) return false; switch (Open) { case true when !wires.IsPanelOpen: - message.AddMarkup(Loc.GetString("construction-condition-wire-panel-open") + "\n"); + args.PushMarkup(Loc.GetString("construction-condition-wire-panel-open")); return true; case false when wires.IsPanelOpen: - message.AddMarkup(Loc.GetString("construction-condition-wire-panel-close") + "\n"); + args.PushMarkup(Loc.GetString("construction-condition-wire-panel-close")); return true; } diff --git a/Content.Server/Construction/ConstructionSystem.cs b/Content.Server/Construction/ConstructionSystem.cs index 6269a06862..e45f840309 100644 --- a/Content.Server/Construction/ConstructionSystem.cs +++ b/Content.Server/Construction/ConstructionSystem.cs @@ -59,7 +59,7 @@ namespace Content.Server.Construction { args.PushMarkup(Loc.GetString( "construction-component-to-create-header", - ("targetName", component.Target.Name))); + ("targetName", component.Target.Name)) + "\n"); } if (component.Edge == null && component.TargetNextEdge != null) diff --git a/Content.Shared/Construction/IGraphCondition.cs b/Content.Shared/Construction/IGraphCondition.cs index ee6f929f0d..edbd0433bd 100644 --- a/Content.Shared/Construction/IGraphCondition.cs +++ b/Content.Shared/Construction/IGraphCondition.cs @@ -7,6 +7,6 @@ namespace Content.Shared.Construction public interface IGraphCondition { Task Condition(IEntity entity); - bool DoExamine(ExaminedEvent examinedEvent) { return false; } + bool DoExamine(ExaminedEvent args) { return false; } } } diff --git a/Resources/Changelog/Parts/constructionExamine.yml b/Resources/Changelog/Parts/constructionExamine.yml new file mode 100644 index 0000000000..44aaf992fd --- /dev/null +++ b/Resources/Changelog/Parts/constructionExamine.yml @@ -0,0 +1,4 @@ +author: Zumorica +changes: + - type: Fix # One of the following: Add, Remove, Tweak, Fix + message: Fix examine not showing the correct construction steps in certain cases.