перенос файлов сервера из папки White в _White
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using Content.Server.Ghost.Components;
|
||||
using Content.Shared.Ghost;
|
||||
using Content.Shared.White.CustomGhostSystem;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server._White.CustomGhostSpriteSystem;
|
||||
|
||||
public sealed class CustomGhostSpriteSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
||||
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<GhostComponent, PlayerAttachedEvent>(OnShit);
|
||||
}
|
||||
|
||||
private void OnShit(EntityUid uid, GhostComponent component, PlayerAttachedEvent args)
|
||||
{
|
||||
if(!_playerManager.TryGetSessionByEntity(uid, out var session))
|
||||
return;
|
||||
|
||||
TrySetCustomSprite(uid, session.Name);
|
||||
}
|
||||
|
||||
|
||||
public void TrySetCustomSprite(EntityUid ghostUid, string ckey)
|
||||
{
|
||||
var prototypes = _prototypeManager.EnumeratePrototypes<CustomGhostPrototype>();
|
||||
|
||||
foreach (var customGhostPrototype in prototypes)
|
||||
{
|
||||
if (string.Equals(customGhostPrototype.Ckey, ckey, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.Sprite, customGhostPrototype.CustomSpritePath.ToString());
|
||||
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.SizeOverride, customGhostPrototype.SizeOverride);
|
||||
|
||||
if(customGhostPrototype.AlphaOverride > 0)
|
||||
{
|
||||
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.AlphaOverride, customGhostPrototype.AlphaOverride);
|
||||
}
|
||||
|
||||
if (customGhostPrototype.GhostName != string.Empty)
|
||||
{
|
||||
_metaData.SetEntityName(ghostUid, customGhostPrototype.GhostName);
|
||||
}
|
||||
|
||||
if (customGhostPrototype.GhostDescription != string.Empty)
|
||||
{
|
||||
_metaData.SetEntityDescription(ghostUid, customGhostPrototype.GhostDescription);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user