Moves ExamineSystem to Shared & adds next step info to construction examine (#1567)
This commit is contained in:
@@ -1,15 +1,29 @@
|
|||||||
using Content.Shared.Construction;
|
using Content.Shared.Construction;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Robust.Shared.GameObjects;
|
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;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.Components.Construction
|
namespace Content.Client.GameObjects.Components.Construction
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[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";
|
public override string Name => "ConstructionGhost";
|
||||||
|
|
||||||
[ViewVariables] public ConstructionPrototype Prototype { get; set; }
|
[ViewVariables] public ConstructionPrototype Prototype { get; set; }
|
||||||
[ViewVariables] public int GhostID { 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<SharedConstructionSystem>().DoExamine(message, Prototype, 0, inDetailsRange);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
/// The client-side implementation of the construction system, which is used for constructing entities in game.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class ConstructionSystem : Shared.GameObjects.EntitySystems.ConstructionSystem
|
public class ConstructionSystem : Shared.GameObjects.EntitySystems.SharedConstructionSystem
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private readonly IGameHud _gameHud;
|
[Dependency] private readonly IGameHud _gameHud;
|
||||||
|
|||||||
@@ -106,10 +106,13 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
|
|
||||||
_examineTooltipOpen.Open(UIBox2.FromDimensions(popupPos, size));
|
_examineTooltipOpen.Open(UIBox2.FromDimensions(popupPos, size));
|
||||||
|
|
||||||
|
FormattedMessage message;
|
||||||
if (entity.Uid.IsClientSide())
|
if (entity.Uid.IsClientSide())
|
||||||
{
|
{
|
||||||
return;
|
message = ExamineSystem.GetExamineText(entity, _playerManager.LocalPlayer.ControlledEntity);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
// Ask server for extra examine info.
|
// Ask server for extra examine info.
|
||||||
RaiseNetworkEvent(new ExamineSystemMessages.RequestExamineInfoMessage(entity.Uid));
|
RaiseNetworkEvent(new ExamineSystemMessages.RequestExamineInfoMessage(entity.Uid));
|
||||||
@@ -131,12 +134,15 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
_requestCancelTokenSource = null;
|
_requestCancelTokenSource = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var msg in response.Message.Tags.OfType<FormattedMessage.TagText>())
|
message = response.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var msg in message.Tags.OfType<FormattedMessage.TagText>())
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(msg.Text))
|
if (!string.IsNullOrWhiteSpace(msg.Text))
|
||||||
{
|
{
|
||||||
var richLabel = new RichTextLabel();
|
var richLabel = new RichTextLabel();
|
||||||
richLabel.SetMessage(response.Message);
|
richLabel.SetMessage(message);
|
||||||
vBox.AddChild(richLabel);
|
vBox.AddChild(richLabel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
using Robust.Shared.GameObjects.Systems;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Construction
|
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.
|
/// Holds data about an entity that is in the process of being constructed or destructed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class ConstructionComponent : Component
|
public class ConstructionComponent : Component, IExamine
|
||||||
{
|
{
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private readonly ILocalizationManager _loc;
|
||||||
|
#pragma warning restore 649
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Construction";
|
public override string Name => "Construction";
|
||||||
|
|
||||||
@@ -37,5 +46,10 @@ namespace Content.Server.GameObjects.Components.Construction
|
|||||||
serializer.DataReadWriteFunction("stage", 0,
|
serializer.DataReadWriteFunction("stage", 0,
|
||||||
value => Stage = value, () => Stage);
|
value => Stage = value, () => Stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
|
||||||
|
{
|
||||||
|
EntitySystem.Get<SharedConstructionSystem>().DoExamine(message, Prototype, Stage, inDetailsRange);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ using Robust.Shared.Serialization;
|
|||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using Timer = Robust.Shared.Timers.Timer;
|
using Timer = Robust.Shared.Timers.Timer;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Fluids
|
namespace Content.Server.GameObjects.Components.Fluids
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ using Robust.Shared.Localization;
|
|||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Interactable
|
namespace Content.Server.GameObjects.Components.Interactable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Server.GameObjects.EntitySystems.Click;
|
using Content.Server.GameObjects.EntitySystems.Click;
|
||||||
using Content.Shared.Audio;
|
using Content.Shared.Audio;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.GameObjects.EntitySystems;
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Content.Server.GameObjects.EntitySystems.Click;
|
using Content.Server.GameObjects.EntitySystems.Click;
|
||||||
using Content.Server.Interfaces;
|
using Content.Server.Interfaces;
|
||||||
using Content.Server.Utility;
|
using Content.Server.Utility;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Content.Shared.Maps;
|
using Content.Shared.Maps;
|
||||||
using Robust.Server.GameObjects.EntitySystems;
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Server.GameObjects.EntitySystems.Click;
|
using Content.Server.GameObjects.EntitySystems.Click;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using Robust.Shared.Serialization;
|
|||||||
using Robust.Shared.Timers;
|
using Robust.Shared.Timers;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Mobs
|
namespace Content.Server.GameObjects.Components.Mobs
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Content.Server.Interfaces.GameObjects.Components.Interaction;
|
|||||||
using Content.Shared.Audio;
|
using Content.Shared.Audio;
|
||||||
using Content.Shared.Chemistry;
|
using Content.Shared.Chemistry;
|
||||||
using Content.Shared.GameObjects.Components.Nutrition;
|
using Content.Shared.GameObjects.Components.Nutrition;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
@@ -26,7 +27,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
[ComponentReference(typeof(IAfterInteract))]
|
[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
|
#pragma warning disable 649
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Server.GameObjects.EntitySystems.Click;
|
using Content.Server.GameObjects.EntitySystems.Click;
|
||||||
using Content.Shared.GameObjects.Components;
|
using Content.Shared.GameObjects.Components;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.GameObjects.Components.UserInterface;
|
using Robust.Server.GameObjects.Components.UserInterface;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using Content.Server.GameObjects.EntitySystems.Click;
|
|||||||
using Robust.Shared.GameObjects.Components;
|
using Robust.Shared.GameObjects.Components;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Server.GameObjects.EntitySystems.Click;
|
using Content.Server.GameObjects.EntitySystems.Click;
|
||||||
using Content.Shared.GameObjects.Components;
|
using Content.Shared.GameObjects.Components;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
|||||||
using Content.Server.GameObjects.EntitySystems.Click;
|
using Content.Server.GameObjects.EntitySystems.Click;
|
||||||
using Content.Server.Interfaces.GameObjects.Components.Interaction;
|
using Content.Server.Interfaces.GameObjects.Components.Interaction;
|
||||||
using Content.Shared.GameObjects.Components.VendingMachines;
|
using Content.Shared.GameObjects.Components.VendingMachines;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Content.Shared.VendingMachines;
|
using Content.Shared.VendingMachines;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Content.Server.GameObjects.Components.Mobs;
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
using Content.Server.GameObjects.EntitySystems.Click;
|
using Content.Server.GameObjects.EntitySystems.Click;
|
||||||
using Content.Shared.GameObjects.Components.Mobs;
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ using Robust.Shared.Random;
|
|||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using Content.Server.Interfaces;
|
using Content.Server.Interfaces;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,16 +9,6 @@ using Robust.Shared.Utility;
|
|||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems.Click
|
namespace Content.Server.GameObjects.EntitySystems.Click
|
||||||
{
|
{
|
||||||
public interface IExamine
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a status examine value for components appended to the end of the description of the entity
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message">The message to append to which will be displayed.</param>
|
|
||||||
/// <param name="inDetailsRange">Whether the examiner is within the 'Details' range, allowing you to show information logically only availabe when close to the examined entity.</param>
|
|
||||||
void Examine(FormattedMessage message, bool inDetailsRange);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ExamineSystem : ExamineSystemShared
|
public class ExamineSystem : ExamineSystemShared
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
@@ -27,8 +17,6 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
|||||||
|
|
||||||
private static readonly FormattedMessage _entityNotFoundMessage;
|
private static readonly FormattedMessage _entityNotFoundMessage;
|
||||||
|
|
||||||
private const float ExamineDetailsRange = 3f;
|
|
||||||
|
|
||||||
static ExamineSystem()
|
static ExamineSystem()
|
||||||
{
|
{
|
||||||
_entityNotFoundMessage = new FormattedMessage();
|
_entityNotFoundMessage = new FormattedMessage();
|
||||||
@@ -44,45 +32,6 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
|||||||
IoCManager.InjectDependencies(this);
|
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<SharedInteractionSystem>()
|
|
||||||
.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<IExamine>())
|
|
||||||
{
|
|
||||||
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)
|
private void ExamineInfoRequest(ExamineSystemMessages.RequestExamineInfoMessage request, EntitySessionEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
var player = (IPlayerSession) eventArgs.SenderSession;
|
var player = (IPlayerSession) eventArgs.SenderSession;
|
||||||
|
|||||||
@@ -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.
|
/// The server-side implementation of the construction system, which is used for constructing entities in game.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
internal class ConstructionSystem : Shared.GameObjects.EntitySystems.ConstructionSystem
|
internal class ConstructionSystem : Shared.GameObjects.EntitySystems.SharedConstructionSystem
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
||||||
|
|||||||
@@ -1,14 +1,26 @@
|
|||||||
using Content.Shared.GameObjects.Components.Mobs;
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Shared.GameObjects.EntitySystems
|
namespace Content.Shared.GameObjects.EntitySystems
|
||||||
{
|
{
|
||||||
|
public interface IExamine
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a status examine value for components appended to the end of the description of the entity
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The message to append to which will be displayed.</param>
|
||||||
|
/// <param name="inDetailsRange">Whether the examiner is within the 'Details' range, allowing you to show information logically only availabe when close to the examined entity.</param>
|
||||||
|
void Examine(FormattedMessage message, bool inDetailsRange);
|
||||||
|
}
|
||||||
public abstract class ExamineSystemShared : EntitySystem
|
public abstract class ExamineSystemShared : EntitySystem
|
||||||
{
|
{
|
||||||
public const float ExamineRange = 16f;
|
public const float ExamineRange = 16f;
|
||||||
public const float ExamineRangeSquared = ExamineRange * ExamineRange;
|
public const float ExamineRangeSquared = ExamineRange * ExamineRange;
|
||||||
|
protected const float ExamineDetailsRange = 3f;
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
protected static bool CanExamine(IEntity examiner, IEntity examined)
|
protected static bool CanExamine(IEntity examiner, IEntity examined)
|
||||||
@@ -32,5 +44,44 @@ namespace Content.Shared.GameObjects.EntitySystems
|
|||||||
.InRangeUnobstructed(examiner.Transform.MapPosition, examined.Transform.MapPosition,
|
.InRangeUnobstructed(examiner.Transform.MapPosition, examined.Transform.MapPosition,
|
||||||
ExamineRange, predicate: entity => entity == examiner || entity == examined, ignoreInsideBlocker:true);
|
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<SharedInteractionSystem>()
|
||||||
|
.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<IExamine>())
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Content.Shared.Construction;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Shared.GameObjects.EntitySystems
|
namespace Content.Shared.GameObjects.EntitySystems
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
public class SharedConstructionSystem : EntitySystem
|
||||||
public class ConstructionSystem : EntitySystem
|
|
||||||
{
|
{
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private readonly ILocalizationManager _loc;
|
||||||
|
#pragma warning restore 649
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sent client -> server to to tell the server that we started building
|
/// Sent client -> server to to tell the server that we started building
|
||||||
/// a structure-construction.
|
/// a structure-construction.
|
||||||
@@ -75,5 +81,28 @@ namespace Content.Shared.GameObjects.EntitySystems
|
|||||||
GhostId = ghostId;
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user