Skip to content

Commit

Permalink
RSI
Browse files Browse the repository at this point in the history
  • Loading branch information
RedBurningPhoenix committed Aug 30, 2024
1 parent 94e6b2e commit eeb3570
Show file tree
Hide file tree
Showing 52 changed files with 98 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ protected override void OnAppearanceChange(EntityUid uid, GhostComponent compone
{
base.OnAppearanceChange(uid, component, ref args);

if(args.Sprite == null) return;
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))
if (AppearanceSystem.TryGetData<float>(uid, CustomGhostAppearance.AlphaOverride, out var alpha, args.Component))
{
args.Sprite.Color = args.Sprite.Color.WithAlpha(alpha);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,47 @@ public sealed class CustomGhostSpriteSystem : EntitySystem
[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);
SubscribeLocalEvent<GhostComponent, PlayerAttachedEvent>(OnChangeAppearance);
}

private void OnShit(EntityUid uid, GhostComponent component, PlayerAttachedEvent args)
private void OnChangeAppearance(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);
}

if (!string.Equals(customGhostPrototype.Ckey, ckey, StringComparison.CurrentCultureIgnoreCase))
continue;
_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);
}

return;
if (customGhostPrototype.GhostDescription != string.Empty)
{
_metaData.SetEntityDescription(ghostUid, customGhostPrototype.GhostDescription);
}

return;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
namespace Content.Shared._White.CustomGhostSystem;

/// <summary>
/// This is a prototype for...
/// Use this for custom ghost's
/// </summary>
[Prototype("customGhost")]
public sealed class CustomGhostPrototype : IPrototype
{
/// <inheritdoc/>
[IdDataField]
public string ID { get; } = default!;

[DataField("ckey", required: true)]
[DataField(required: true)]
public string Ckey { get; } = default!;

[DataField("sprite", required: true)]
Expand Down
2 changes: 1 addition & 1 deletion Resources/Textures/_White/Ghosts/17shu-ghost.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "17shu",
"size": {
"x": 40,
Expand Down
4 changes: 2 additions & 2 deletions Resources/Textures/_White/Ghosts/4abere1-ghost.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "https://github.com/frosty-dev/white",
"license": "CC-BY-SA-4.0",
"copyright": "4abere1",
"size": {
"x": 32,
"y": 32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": null,
"copyright": null,
"license": "CC-BY-SA-4.0",
"copyright": "aeonsthorn",
"size": {
"x": 64,
"y": 64
Expand Down
4 changes: 2 additions & 2 deletions Resources/Textures/_White/Ghosts/afanasy-ghost.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "https://github.com/tgstation/tgstation",
"license": "CC-BY-SA-4.0",
"copyright": "afanasy",
"size": {
"x": 32,
"y": 32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "mama",
"size": {
"x": 32,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "Created by MOYAMAMA",
"size": {
"x": 64,
Expand Down
4 changes: 2 additions & 2 deletions Resources/Textures/_White/Ghosts/dageff-ghost.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "Dageff",
"size": {
"x": 128,
Expand Down Expand Up @@ -46,4 +46,4 @@
]
}
]
}
}
4 changes: 2 additions & 2 deletions Resources/Textures/_White/Ghosts/deadisko-ghost.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "https://github.com/frosty-dev/white",
"license": "CC-BY-SA-4.0",
"copyright": "deadisko",
"size": {
"x": 64,
"y": 64
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "Created by Pierre Chevreul",
"size": {
"x": 32,
Expand Down
2 changes: 1 addition & 1 deletion Resources/Textures/_White/Ghosts/felix-ghost.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "felix",
"size": {
"x": 64,
Expand Down
4 changes: 2 additions & 2 deletions Resources/Textures/_White/Ghosts/fjor-ghost.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "",
"license": "CC-BY-SA-4.0",
"copyright": "fjor",
"size": {
"x": 128,
"y": 128
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"x": 128,
"y": 128
},
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "Nair Sark",
"states": [
{
Expand Down Expand Up @@ -42,4 +42,4 @@
]
}
]
}
}
6 changes: 3 additions & 3 deletions Resources/Textures/_White/Ghosts/hayras-ghost.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "https://github.com/tgstation/tgstation",
"license": "CC-BY-SA-4.0",
"copyright": "hayras",
"size": {
"x": 32,
"y": 32
Expand All @@ -12,4 +12,4 @@
"directions": 4
}
]
}
}
4 changes: 2 additions & 2 deletions Resources/Textures/_White/Ghosts/hitpanda_ghost.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "https://github.com/frosty-dev/white",
"license": "CC-BY-SA-4.0",
"copyright": "hitpanda",
"size": {
"x": 32,
"y": 32
Expand Down
4 changes: 2 additions & 2 deletions Resources/Textures/_White/Ghosts/hskveez-ghost.rsi/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"x": 32,
"y": 32
},
"license": "CC-BY-SA-3.0",
"copyright": "Poxuy",
"license": "CC-BY-SA-4.0",
"copyright": "hskveez",
"states": [
{
"name": "animated",
Expand Down
4 changes: 2 additions & 2 deletions Resources/Textures/_White/Ghosts/joulerk-ghost.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "https://github.com/frosty-dev/white",
"license": "CC-BY-SA-4.0",
"copyright": "joulerk",
"size": {
"x": 64,
"y": 64
Expand Down
4 changes: 2 additions & 2 deletions Resources/Textures/_White/Ghosts/kreses-ghost.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "White Dream",
"license": "CC-BY-SA-4.0",
"copyright": "kreses",
"size": {
"x": 64,
"y": 64
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Valtos",
"license": "CC-BY-SA-4.0",
"copyright": "krokozyabra",
"size": {
"x": 32,
"y": 32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "Created by cry_prism",
"size": {
"x": 128,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "Created by MOYAMAMA",
"size": {
"x": 32,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "mikvisan",
"size": {
"x": 64,
Expand Down
4 changes: 2 additions & 2 deletions Resources/Textures/_White/Ghosts/mr_regari.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "https://github.com/tgstation/tgstation",
"license": "CC-BY-SA-4.0",
"copyright": "mr_regari",
"size": {
"x": 64,
"y": 64
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "Created by MOYAMAMA",
"size": {
"x": 48,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "felix",
"size": {
"x": 64,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Copyright https://github.com/frosty-dev/white",
"license": "CC-BY-SA-4.0",
"copyright": "nosireapo",
"size": {
"x": 32,
"y": 32
Expand Down
4 changes: 2 additions & 2 deletions Resources/Textures/_White/Ghosts/omntns-ghost.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "https://github.com/frosty-dev/white",
"license": "CC-BY-SA-4.0",
"copyright": "omntns",
"size": {
"x": 64,
"y": 64
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "Persikvin",
"size": {
"x": 64,
Expand All @@ -11,4 +11,4 @@
"name": "animated"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"license": "CC-BY-SA-4.0",
"copyright": "Created by @baohe",
"size": {
"x": 32,
Expand Down
Loading

0 comments on commit eeb3570

Please sign in to comment.