Files
tbd-station-14/Content.Server/GameObjects/EntitySystems/Click/ExamineSystem.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

53 lines
1.9 KiB
C#

using Content.Shared.GameObjects.EntitySystemMessages;
using Content.Shared.GameObjects.EntitySystems;
using JetBrains.Annotations;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.EntitySystems.Click
{
[UsedImplicitly]
public class ExamineSystem : ExamineSystemShared
{
private static readonly FormattedMessage _entityNotFoundMessage;
static ExamineSystem()
{
_entityNotFoundMessage = new FormattedMessage();
_entityNotFoundMessage.AddText(Loc.GetString("That entity doesn't exist"));
}
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<ExamineSystemMessages.RequestExamineInfoMessage>(ExamineInfoRequest);
IoCManager.InjectDependencies(this);
}
private void ExamineInfoRequest(ExamineSystemMessages.RequestExamineInfoMessage request, EntitySessionEventArgs eventArgs)
{
var player = (IPlayerSession) eventArgs.SenderSession;
var session = eventArgs.SenderSession;
var playerEnt = session.AttachedEntity;
var channel = player.ConnectedClient;
if (playerEnt == null
|| !EntityManager.TryGetEntity(request.EntityUid, out var entity)
|| !CanExamine(playerEnt, entity))
{
RaiseNetworkEvent(new ExamineSystemMessages.ExamineInfoResponseMessage(
request.EntityUid, _entityNotFoundMessage), channel);
return;
}
var text = GetExamineText(entity, player.AttachedEntity);
RaiseNetworkEvent(new ExamineSystemMessages.ExamineInfoResponseMessage(request.EntityUid, text), channel);
}
}
}