ThereDrD кастомгост (#634)

* add null name support for customghost

* add custom ghost
This commit is contained in:
ThereDrD
2024-08-18 00:17:13 +03:00
committed by GitHub
parent 6dffd325d3
commit 9a3b515776
3 changed files with 25 additions and 28 deletions

View File

@@ -1,7 +1,5 @@
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;
@@ -19,12 +17,13 @@ public sealed class CustomGhostSpriteSystem : EntitySystem
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))
if (!_playerManager.TryGetSessionByEntity(uid, out var session))
return;
TrySetCustomSprite(uid, session.Name);
@@ -37,32 +36,22 @@ public sealed class CustomGhostSpriteSystem : EntitySystem
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 (!string.Equals(customGhostPrototype.Ckey, ckey, StringComparison.CurrentCultureIgnoreCase))
continue;
if(customGhostPrototype.AlphaOverride > 0)
{
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.AlphaOverride, customGhostPrototype.AlphaOverride);
}
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.Sprite, customGhostPrototype.CustomSpritePath.ToString());
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.SizeOverride, customGhostPrototype.SizeOverride);
if (customGhostPrototype.GhostName != string.Empty)
{
_metaData.SetEntityName(ghostUid, customGhostPrototype.GhostName);
}
if (customGhostPrototype.AlphaOverride > 0)
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.AlphaOverride, customGhostPrototype.AlphaOverride);
if (customGhostPrototype.GhostDescription != string.Empty)
{
_metaData.SetEntityDescription(ghostUid, customGhostPrototype.GhostDescription);
}
if (customGhostPrototype.GhostName != string.Empty)
_metaData.SetEntityName(ghostUid, customGhostPrototype.GhostName ?? "null");
if (customGhostPrototype.GhostDescription != string.Empty)
_metaData.SetEntityDescription(ghostUid, customGhostPrototype.GhostDescription);
return;
}
return;
}
}
}

View File

@@ -25,7 +25,7 @@ public sealed class CustomGhostPrototype : IPrototype
public float AlphaOverride { get; } = -1;
[DataField("ghostName")]
public string GhostName = string.Empty;
public string? GhostName = string.Empty;
[DataField("ghostDescription")]
public string GhostDescription = string.Empty;

View File

@@ -22,13 +22,21 @@
ghostName: Winter's Scar
ghostDescription: ...
#- type: customGhost
# id: animeshka-ghost
# ckey: animeshka
# sprite: White/Ghosts/animeshka-ghost.rsi
# alpha: 0.7
# ghostName: Грабля
# ghostDescription: Ну привет уебан!
- type: customGhost
id: animeshka-ghost
ckey: animeshka
ckey: theredrd
sprite: White/Ghosts/animeshka-ghost.rsi
alpha: 0.7
ghostName: Грабля
ghostDescription: Ну привет уебан!
ghostName: null
ghostDescription: ...
- type: customGhost
id: shelupon-ghost