[feat] Custom ghost sprite
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using Content.Client.Ghost;
|
||||
using Content.Shared.White.CustomGhostSystem;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.White.CustomGhostSpriteSystem;
|
||||
|
||||
public sealed class CustomGhostVisualizer : VisualizerSystem<GhostComponent>
|
||||
{
|
||||
protected override void OnAppearanceChange(EntityUid uid, GhostComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
base.OnAppearanceChange(uid, component, ref args);
|
||||
|
||||
if(args.Sprite == null) return;
|
||||
|
||||
if (AppearanceSystem.TryGetData<string>(uid, CustomGhostAppearance.Sprite, out var rsiPath, args.Component))
|
||||
{
|
||||
args.Sprite.LayerSetRSI(0, rsiPath);
|
||||
}
|
||||
|
||||
if(AppearanceSystem.TryGetData<float>(uid, CustomGhostAppearance.AlphaOverride, out var alpha, args.Component))
|
||||
{
|
||||
args.Sprite.Color = args.Sprite.Color.WithAlpha(alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using Content.Server.Ghost.Components;
|
||||
using Content.Shared.White.CustomGhostSystem;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.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!;
|
||||
|
||||
|
||||
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());
|
||||
|
||||
if(customGhostPrototype.AlphaOverride > 0)
|
||||
{
|
||||
_appearanceSystem.SetData(ghostUid, CustomGhostAppearance.AlphaOverride, customGhostPrototype.AlphaOverride);
|
||||
}
|
||||
|
||||
if (customGhostPrototype.GhostName != string.Empty)
|
||||
{
|
||||
MetaData(ghostUid).EntityName = customGhostPrototype.GhostName;
|
||||
}
|
||||
|
||||
if (customGhostPrototype.GhostDescription != string.Empty)
|
||||
{
|
||||
MetaData(ghostUid).EntityDescription = customGhostPrototype.GhostDescription;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.White.CustomGhostSystem;
|
||||
|
||||
/// <summary>
|
||||
/// This is a prototype for...
|
||||
/// </summary>
|
||||
[Prototype("customGhost")]
|
||||
public sealed class CustomGhostPrototype : IPrototype
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
[DataField("ckey", required: true)]
|
||||
public string Ckey { get; } = default!;
|
||||
|
||||
[DataField("sprite", required: true)]
|
||||
public ResPath CustomSpritePath { get; } = default!;
|
||||
|
||||
[DataField("alpha")]
|
||||
public float AlphaOverride { get; } = -1;
|
||||
|
||||
[DataField("ghostName")]
|
||||
public string GhostName = string.Empty;
|
||||
|
||||
[DataField("ghostDescription")]
|
||||
public string GhostDescription = string.Empty;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum CustomGhostAppearance
|
||||
{
|
||||
Sprite,
|
||||
AlphaOverride
|
||||
}
|
||||
@@ -7,6 +7,15 @@ using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.White.Sponsors;
|
||||
|
||||
public enum WhiteSponsorTier
|
||||
{
|
||||
DJ = 5,
|
||||
ROBUSTER = 4,
|
||||
CLOWN = 3,
|
||||
PRIKOLIST = 2,
|
||||
MEATYORE = 1
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class SponsorInfo
|
||||
{
|
||||
|
||||
23
Resources/Prototypes/White/Ghosts/custom_ghosts.yml
Normal file
23
Resources/Prototypes/White/Ghosts/custom_ghosts.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
- type: customGhost
|
||||
id: ravmorgan-ghost
|
||||
ckey: ravmorgan
|
||||
sprite: White/Ghosts/ravmorgan-ghost.rsi
|
||||
alpha: 0.9
|
||||
ghostName: Яйцо
|
||||
ghostDescription: Большое...
|
||||
|
||||
- type: customGhost
|
||||
id: merkkaa-ghost
|
||||
ckey: merkkaa
|
||||
sprite: White/Ghosts/merkkaa-ghost.rsi
|
||||
alpha: 0.9
|
||||
ghostName: Мурка
|
||||
ghostDescription: Ня...
|
||||
|
||||
- type: customGhost
|
||||
id: nairsark-ghost
|
||||
ckey: nairsark
|
||||
sprite: White/Ghosts/nairsark-ghost.rsi
|
||||
alpha: 1
|
||||
ghostName: Maid
|
||||
ghostDescription: Not a fucking fumo
|
||||
BIN
Resources/Textures/White/Ghosts/merkkaa-ghost.rsi/animated.png
Normal file
BIN
Resources/Textures/White/Ghosts/merkkaa-ghost.rsi/animated.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
32
Resources/Textures/White/Ghosts/merkkaa-ghost.rsi/meta.json
Normal file
32
Resources/Textures/White/Ghosts/merkkaa-ghost.rsi/meta.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"version": 1,
|
||||
"license": "CC-BY-SA-3.0",
|
||||
"copyright": "Created by MOYAMAMA",
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 64
|
||||
},
|
||||
"states": [
|
||||
{
|
||||
"name": "animated",
|
||||
"delays": [
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Resources/Textures/White/Ghosts/nairsark-ghost.rsi/animated.png
Normal file
BIN
Resources/Textures/White/Ghosts/nairsark-ghost.rsi/animated.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
57
Resources/Textures/White/Ghosts/nairsark-ghost.rsi/meta.json
Normal file
57
Resources/Textures/White/Ghosts/nairsark-ghost.rsi/meta.json
Normal file
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"version": 1,
|
||||
"license": "CC-BY-SA-3.0",
|
||||
"copyright": "Created by MOYAMAMA",
|
||||
"size": {
|
||||
"x": 48,
|
||||
"y": 64
|
||||
},
|
||||
"states": [
|
||||
{
|
||||
"name": "animated",
|
||||
"directions": 4,
|
||||
"delays": [
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.3,
|
||||
0.2,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.3,
|
||||
0.2,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.3,
|
||||
0.2,
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.3,
|
||||
0.2,
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Resources/Textures/White/Ghosts/ravmorgan-ghost.rsi/animated.png
Normal file
BIN
Resources/Textures/White/Ghosts/ravmorgan-ghost.rsi/animated.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"version": 1,
|
||||
"license": "CC-BY-SA-3.0",
|
||||
"copyright": "Created by MOYAMAMA",
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 40
|
||||
},
|
||||
"states": [
|
||||
{
|
||||
"name": "animated"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user