diff --git a/Content.Client/GameObjects/Components/Construction/ConstructionGhostComponent.cs b/Content.Client/GameObjects/Components/Construction/ConstructionGhostComponent.cs index 17cbb51629..11fd598acf 100644 --- a/Content.Client/GameObjects/Components/Construction/ConstructionGhostComponent.cs +++ b/Content.Client/GameObjects/Components/Construction/ConstructionGhostComponent.cs @@ -1,15 +1,29 @@ using Content.Shared.Construction; +using Content.Shared.GameObjects.EntitySystems; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Systems; +using Robust.Shared.IoC; +using Robust.Shared.Localization; +using Robust.Shared.Utility; using Robust.Shared.ViewVariables; namespace Content.Client.GameObjects.Components.Construction { [RegisterComponent] - public class ConstructionGhostComponent : Component + public class ConstructionGhostComponent : Component, IExamine { +#pragma warning disable 649 + [Dependency] private readonly ILocalizationManager _loc; +#pragma warning restore 649 public override string Name => "ConstructionGhost"; [ViewVariables] public ConstructionPrototype Prototype { get; set; } [ViewVariables] public int GhostID { get; set; } + + void IExamine.Examine(FormattedMessage message, bool inDetailsRange) + { + message.AddText(_loc.GetString("Building: {0}\n", Prototype.Name)); + EntitySystem.Get().DoExamine(message, Prototype, 0, inDetailsRange); + } } } diff --git a/Content.Client/GameObjects/EntitySystems/ConstructionSystem.cs b/Content.Client/GameObjects/EntitySystems/ConstructionSystem.cs index d776eaf167..57537e8a5b 100644 --- a/Content.Client/GameObjects/EntitySystems/ConstructionSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/ConstructionSystem.cs @@ -21,7 +21,7 @@ namespace Content.Client.GameObjects.EntitySystems /// The client-side implementation of the construction system, which is used for constructing entities in game. /// [UsedImplicitly] - public class ConstructionSystem : Shared.GameObjects.EntitySystems.ConstructionSystem + public class ConstructionSystem : Shared.GameObjects.EntitySystems.SharedConstructionSystem { #pragma warning disable 649 [Dependency] private readonly IGameHud _gameHud; diff --git a/Content.Client/GameObjects/EntitySystems/ExamineSystem.cs b/Content.Client/GameObjects/EntitySystems/ExamineSystem.cs index f799ffa00a..79d297bd34 100644 --- a/Content.Client/GameObjects/EntitySystems/ExamineSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/ExamineSystem.cs @@ -106,37 +106,43 @@ namespace Content.Client.GameObjects.EntitySystems _examineTooltipOpen.Open(UIBox2.FromDimensions(popupPos, size)); + FormattedMessage message; if (entity.Uid.IsClientSide()) { - return; + message = ExamineSystem.GetExamineText(entity, _playerManager.LocalPlayer.ControlledEntity); + } + else + { + + // Ask server for extra examine info. + RaiseNetworkEvent(new ExamineSystemMessages.RequestExamineInfoMessage(entity.Uid)); + + ExamineSystemMessages.ExamineInfoResponseMessage response; + try + { + _requestCancelTokenSource = new CancellationTokenSource(); + response = + await AwaitNetworkEvent(_requestCancelTokenSource + .Token); + } + catch (TaskCanceledException) + { + return; + } + finally + { + _requestCancelTokenSource = null; + } + + message = response.Message; } - // Ask server for extra examine info. - RaiseNetworkEvent(new ExamineSystemMessages.RequestExamineInfoMessage(entity.Uid)); - - ExamineSystemMessages.ExamineInfoResponseMessage response; - try - { - _requestCancelTokenSource = new CancellationTokenSource(); - response = - await AwaitNetworkEvent(_requestCancelTokenSource - .Token); - } - catch (TaskCanceledException) - { - return; - } - finally - { - _requestCancelTokenSource = null; - } - - foreach (var msg in response.Message.Tags.OfType()) + foreach (var msg in message.Tags.OfType()) { if (!string.IsNullOrWhiteSpace(msg.Text)) { var richLabel = new RichTextLabel(); - richLabel.SetMessage(response.Message); + richLabel.SetMessage(message); vBox.AddChild(richLabel); break; } diff --git a/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs b/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs index 1eb9cad50e..49cd4cbeb8 100644 --- a/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs +++ b/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs @@ -1,6 +1,12 @@ -using Content.Shared.Construction; +using Content.Server.GameObjects.EntitySystems.Click; +using Content.Shared.Construction; +using Content.Shared.GameObjects.EntitySystems; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Systems; +using Robust.Shared.IoC; +using Robust.Shared.Localization; using Robust.Shared.Serialization; +using Robust.Shared.Utility; using Robust.Shared.ViewVariables; namespace Content.Server.GameObjects.Components.Construction @@ -9,8 +15,11 @@ namespace Content.Server.GameObjects.Components.Construction /// Holds data about an entity that is in the process of being constructed or destructed. /// [RegisterComponent] - public class ConstructionComponent : Component + public class ConstructionComponent : Component, IExamine { +#pragma warning disable 649 + [Dependency] private readonly ILocalizationManager _loc; +#pragma warning restore 649 /// public override string Name => "Construction"; @@ -37,5 +46,10 @@ namespace Content.Server.GameObjects.Components.Construction serializer.DataReadWriteFunction("stage", 0, value => Stage = value, () => Stage); } + + void IExamine.Examine(FormattedMessage message, bool inDetailsRange) + { + EntitySystem.Get().DoExamine(message, Prototype, Stage, inDetailsRange); + } } } diff --git a/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs b/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs index 92b8dbc5cb..8b89efc673 100644 --- a/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs +++ b/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs @@ -24,6 +24,7 @@ using Robust.Shared.Serialization; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; using Timer = Robust.Shared.Timers.Timer; +using Content.Shared.GameObjects.EntitySystems; namespace Content.Server.GameObjects.Components.Fluids { diff --git a/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs b/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs index 39aadea5ae..46e13cd038 100644 --- a/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs @@ -18,6 +18,7 @@ using Robust.Shared.Localization; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; using Robust.Shared.Serialization; +using Content.Shared.GameObjects.EntitySystems; namespace Content.Server.GameObjects.Components.Interactable { diff --git a/Content.Server/GameObjects/Components/Items/DiceComponent.cs b/Content.Server/GameObjects/Components/Items/DiceComponent.cs index 11d0aadd21..f916f15464 100644 --- a/Content.Server/GameObjects/Components/Items/DiceComponent.cs +++ b/Content.Server/GameObjects/Components/Items/DiceComponent.cs @@ -1,5 +1,6 @@ using Content.Server.GameObjects.EntitySystems.Click; using Content.Shared.Audio; +using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces.GameObjects.Components; using Robust.Server.GameObjects; using Robust.Server.GameObjects.EntitySystems; diff --git a/Content.Server/GameObjects/Components/Items/RCDComponent.cs b/Content.Server/GameObjects/Components/Items/RCDComponent.cs index a126e6adff..59dbc706c8 100644 --- a/Content.Server/GameObjects/Components/Items/RCDComponent.cs +++ b/Content.Server/GameObjects/Components/Items/RCDComponent.cs @@ -2,6 +2,7 @@ using Content.Server.GameObjects.EntitySystems.Click; using Content.Server.Interfaces; using Content.Server.Utility; +using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces.GameObjects.Components; using Content.Shared.Maps; using Robust.Server.GameObjects.EntitySystems; diff --git a/Content.Server/GameObjects/Components/Markers/WarpPointComponent.cs b/Content.Server/GameObjects/Components/Markers/WarpPointComponent.cs index 4003e64a19..6301aa67dd 100644 --- a/Content.Server/GameObjects/Components/Markers/WarpPointComponent.cs +++ b/Content.Server/GameObjects/Components/Markers/WarpPointComponent.cs @@ -1,4 +1,5 @@ using Content.Server.GameObjects.EntitySystems.Click; +using Content.Shared.GameObjects.EntitySystems; using Robust.Shared.GameObjects; using Robust.Shared.Localization; using Robust.Shared.Serialization; diff --git a/Content.Server/GameObjects/Components/Mobs/MindComponent.cs b/Content.Server/GameObjects/Components/Mobs/MindComponent.cs index b066d162ed..1528b37615 100644 --- a/Content.Server/GameObjects/Components/Mobs/MindComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/MindComponent.cs @@ -13,6 +13,7 @@ using Robust.Shared.Serialization; using Robust.Shared.Timers; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; +using Content.Shared.GameObjects.EntitySystems; namespace Content.Server.GameObjects.Components.Mobs { diff --git a/Content.Server/GameObjects/Components/Nutrition/DrinkComponent.cs b/Content.Server/GameObjects/Components/Nutrition/DrinkComponent.cs index 0f919c7228..49e2b8b03b 100644 --- a/Content.Server/GameObjects/Components/Nutrition/DrinkComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/DrinkComponent.cs @@ -5,6 +5,7 @@ using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Shared.Audio; using Content.Shared.Chemistry; using Content.Shared.GameObjects.Components.Nutrition; +using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces; using Content.Shared.Interfaces.GameObjects.Components; using Robust.Server.GameObjects; @@ -26,7 +27,7 @@ namespace Content.Server.GameObjects.Components.Nutrition { [RegisterComponent] [ComponentReference(typeof(IAfterInteract))] - public class DrinkComponent : Component, IUse, IAfterInteract, ISolutionChange,IExamine, ILand + public class DrinkComponent : Component, IUse, IAfterInteract, ISolutionChange, IExamine, ILand { #pragma warning disable 649 [Dependency] private readonly IPrototypeManager _prototypeManager; diff --git a/Content.Server/GameObjects/Components/Paper/PaperComponent.cs b/Content.Server/GameObjects/Components/Paper/PaperComponent.cs index b025eff162..025df877c9 100644 --- a/Content.Server/GameObjects/Components/Paper/PaperComponent.cs +++ b/Content.Server/GameObjects/Components/Paper/PaperComponent.cs @@ -1,5 +1,6 @@ using Content.Server.GameObjects.EntitySystems.Click; using Content.Shared.GameObjects.Components; +using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces.GameObjects.Components; using Robust.Server.GameObjects; using Robust.Server.GameObjects.Components.UserInterface; diff --git a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs index c54a753d8a..bcc67552e2 100644 --- a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs +++ b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs @@ -12,6 +12,7 @@ using Content.Server.GameObjects.EntitySystems.Click; using Robust.Shared.GameObjects.Components; using Robust.Shared.Localization; using Robust.Shared.Utility; +using Content.Shared.GameObjects.EntitySystems; namespace Content.Server.GameObjects.Components.Power.ApcNetComponents { diff --git a/Content.Server/GameObjects/Components/Stack/StackComponent.cs b/Content.Server/GameObjects/Components/Stack/StackComponent.cs index d62efca2c7..4fe5350c49 100644 --- a/Content.Server/GameObjects/Components/Stack/StackComponent.cs +++ b/Content.Server/GameObjects/Components/Stack/StackComponent.cs @@ -1,6 +1,7 @@ using System; using Content.Server.GameObjects.EntitySystems.Click; using Content.Shared.GameObjects.Components; +using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces; using Content.Shared.Interfaces.GameObjects.Components; using Robust.Shared.GameObjects; diff --git a/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs b/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs index ca73bd3f5e..b395675156 100644 --- a/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs +++ b/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs @@ -5,6 +5,7 @@ using Content.Server.GameObjects.Components.Power.ApcNetComponents; using Content.Server.GameObjects.EntitySystems.Click; using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Shared.GameObjects.Components.VendingMachines; +using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces.GameObjects.Components; using Content.Shared.VendingMachines; using Robust.Server.GameObjects; diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs index 9f7da86092..ab46cf1139 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs @@ -2,6 +2,7 @@ using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.EntitySystems.Click; using Content.Shared.GameObjects.Components.Mobs; +using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces; using Content.Shared.Interfaces.GameObjects.Components; using Robust.Server.GameObjects; diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs index 907557534d..ff8cc75244 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs @@ -28,6 +28,7 @@ using Robust.Shared.Random; using Robust.Shared.Serialization; using Robust.Shared.Utility; using Content.Server.Interfaces; +using Content.Shared.GameObjects.EntitySystems; namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels { diff --git a/Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs index 609328c29a..cec72d8508 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs @@ -9,16 +9,6 @@ using Robust.Shared.Utility; namespace Content.Server.GameObjects.EntitySystems.Click { - public interface IExamine - { - /// - /// Returns a status examine value for components appended to the end of the description of the entity - /// - /// The message to append to which will be displayed. - /// Whether the examiner is within the 'Details' range, allowing you to show information logically only availabe when close to the examined entity. - void Examine(FormattedMessage message, bool inDetailsRange); - } - public class ExamineSystem : ExamineSystemShared { #pragma warning disable 649 @@ -27,8 +17,6 @@ namespace Content.Server.GameObjects.EntitySystems.Click private static readonly FormattedMessage _entityNotFoundMessage; - private const float ExamineDetailsRange = 3f; - static ExamineSystem() { _entityNotFoundMessage = new FormattedMessage(); @@ -44,45 +32,6 @@ namespace Content.Server.GameObjects.EntitySystems.Click IoCManager.InjectDependencies(this); } - private static FormattedMessage GetExamineText(IEntity entity, IEntity examiner) - { - var message = new FormattedMessage(); - - var doNewline = false; - - //Add an entity description if one is declared - if (!string.IsNullOrEmpty(entity.Description)) - { - message.AddText(entity.Description); - doNewline = true; - } - - message.PushColor(Color.DarkGray); - - var inDetailsRange = Get() - .InRangeUnobstructed(examiner.Transform.MapPosition, entity.Transform.MapPosition, - ExamineDetailsRange, predicate: entity0 => entity0 == examiner || entity0 == entity, ignoreInsideBlocker: true); - - //Add component statuses from components that report one - foreach (var examineComponent in entity.GetAllComponents()) - { - var subMessage = new FormattedMessage(); - examineComponent.Examine(subMessage, inDetailsRange); - if (subMessage.Tags.Count == 0) - continue; - - if (doNewline) - message.AddText("\n"); - - message.AddMessage(subMessage); - doNewline = true; - } - - message.Pop(); - - return message; - } - private void ExamineInfoRequest(ExamineSystemMessages.RequestExamineInfoMessage request, EntitySessionEventArgs eventArgs) { var player = (IPlayerSession) eventArgs.SenderSession; diff --git a/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs b/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs index 82490e89ad..8b7c7ddeb5 100644 --- a/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs @@ -32,7 +32,7 @@ namespace Content.Server.GameObjects.EntitySystems /// The server-side implementation of the construction system, which is used for constructing entities in game. /// [UsedImplicitly] - internal class ConstructionSystem : Shared.GameObjects.EntitySystems.ConstructionSystem + internal class ConstructionSystem : Shared.GameObjects.EntitySystems.SharedConstructionSystem { #pragma warning disable 649 [Dependency] private readonly IPrototypeManager _prototypeManager; diff --git a/Content.Shared/GameObjects/EntitySystems/ExamineSystemShared.cs b/Content.Shared/GameObjects/EntitySystems/ExamineSystemShared.cs index 9b1946fc6f..10aba7551f 100644 --- a/Content.Shared/GameObjects/EntitySystems/ExamineSystemShared.cs +++ b/Content.Shared/GameObjects/EntitySystems/ExamineSystemShared.cs @@ -1,14 +1,26 @@ -using Content.Shared.GameObjects.Components.Mobs; +using Content.Shared.GameObjects.Components.Mobs; using JetBrains.Annotations; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Maths; +using Robust.Shared.Utility; namespace Content.Shared.GameObjects.EntitySystems { + public interface IExamine + { + /// + /// Returns a status examine value for components appended to the end of the description of the entity + /// + /// The message to append to which will be displayed. + /// Whether the examiner is within the 'Details' range, allowing you to show information logically only availabe when close to the examined entity. + void Examine(FormattedMessage message, bool inDetailsRange); + } public abstract class ExamineSystemShared : EntitySystem { public const float ExamineRange = 16f; public const float ExamineRangeSquared = ExamineRange * ExamineRange; + protected const float ExamineDetailsRange = 3f; [Pure] protected static bool CanExamine(IEntity examiner, IEntity examined) @@ -32,5 +44,44 @@ namespace Content.Shared.GameObjects.EntitySystems .InRangeUnobstructed(examiner.Transform.MapPosition, examined.Transform.MapPosition, ExamineRange, predicate: entity => entity == examiner || entity == examined, ignoreInsideBlocker:true); } + + public static FormattedMessage GetExamineText(IEntity entity, IEntity examiner) + { + var message = new FormattedMessage(); + + var doNewline = false; + + //Add an entity description if one is declared + if (!string.IsNullOrEmpty(entity.Description)) + { + message.AddText(entity.Description); + doNewline = true; + } + + message.PushColor(Color.DarkGray); + + var inDetailsRange = Get() + .InRangeUnobstructed(examiner.Transform.MapPosition, entity.Transform.MapPosition, + ExamineDetailsRange, predicate: entity0 => entity0 == examiner || entity0 == entity, ignoreInsideBlocker: true); + + //Add component statuses from components that report one + foreach (var examineComponent in entity.GetAllComponents()) + { + var subMessage = new FormattedMessage(); + examineComponent.Examine(subMessage, inDetailsRange); + if (subMessage.Tags.Count == 0) + continue; + + if (doNewline) + message.AddText("\n"); + + message.AddMessage(subMessage); + doNewline = true; + } + + message.Pop(); + + return message; + } } } diff --git a/Content.Shared/GameObjects/EntitySystems/ConstructionSystem.cs b/Content.Shared/GameObjects/EntitySystems/SharedConstructionSystem.cs similarity index 64% rename from Content.Shared/GameObjects/EntitySystems/ConstructionSystem.cs rename to Content.Shared/GameObjects/EntitySystems/SharedConstructionSystem.cs index c03e1dc632..1a3ddb7f6e 100644 --- a/Content.Shared/GameObjects/EntitySystems/ConstructionSystem.cs +++ b/Content.Shared/GameObjects/EntitySystems/SharedConstructionSystem.cs @@ -1,16 +1,22 @@ using System; +using Content.Shared.Construction; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; +using Robust.Shared.IoC; +using Robust.Shared.Localization; using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Serialization; +using Robust.Shared.Utility; namespace Content.Shared.GameObjects.EntitySystems { - [UsedImplicitly] - public class ConstructionSystem : EntitySystem + public class SharedConstructionSystem : EntitySystem { +#pragma warning disable 649 + [Dependency] private readonly ILocalizationManager _loc; +#pragma warning restore 649 /// /// Sent client -> server to to tell the server that we started building /// a structure-construction. @@ -75,5 +81,28 @@ namespace Content.Shared.GameObjects.EntitySystems GhostId = ghostId; } } + + public void DoExamine(FormattedMessage message, ConstructionPrototype prototype, int stage, bool inDetailRange) + { + var stages = prototype.Stages; + if (stage >= 0 && stage < stages.Count) + { + var curStage = stages[stage]; + if (curStage.Backward != null && curStage.Backward is ConstructionStepTool) + { + var backward = (ConstructionStepTool) curStage.Backward; + message.AddText(_loc.GetString("To deconstruct: {0}x {1} Tool", backward.Amount, backward.ToolQuality)); + } + if (curStage.Forward != null && curStage.Forward is ConstructionStepMaterial) + { + if (curStage.Backward != null) + { + message.AddText("\n"); + } + var forward = (ConstructionStepMaterial) curStage.Forward; + message.AddText(_loc.GetString("To construct: {0}x {1}", forward.Amount, forward.Material)); + } + } + } } }