Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

[Port] Custom Ghost #19

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Numerics;
using Content.Shared.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);
}

if (AppearanceSystem.TryGetData<Vector2>(uid, CustomGhostAppearance.SizeOverride, out var size, args.Component))
{
args.Sprite.Scale = size;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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>(OnChangeAppearance);
}

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))
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);
}

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

return;
}
}
}
42 changes: 42 additions & 0 deletions Content.Shared/_White/CustomGhostSystem/CustomGhostPrototype.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Numerics;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;

namespace Content.Shared._White.CustomGhostSystem;

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

[DataField(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;

[DataField("size")]
public Vector2 SizeOverride = Vector2.One;
}

[Serializable, NetSerializable]
public enum CustomGhostAppearance
{
Sprite,
AlphaOverride,
SizeOverride
}
91 changes: 91 additions & 0 deletions Resources/Prototypes/_Ataraxia/Ghosts/ataraxia.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# PuroSlavKing
- type: customGhost
id: puroslavking-ghost
ckey: PuroSlavKing
sprite: _Ataraxia/Ghosts/PuroSlavKing.rsi
ghostName: PuroSlavKing
ghostDescription: Hello world!

# yourmommy
- type: customGhost
id: yourmommy-ghost
ckey: yourmommy
sprite: _Ataraxia/Ghosts/yourmommy-ghost.rsi
alpha: 1
ghostName: yourmommy
ghostDescription: Самая праздничная киса на диком западе.

# GodFace
- type: customGhost
id: godface-ghost
ckey: GodFace
sprite: _Ataraxia/Ghosts/GodFace.rsi
ghostName: GodFace
ghostDescription: В рамке явно должны оказаться вы!

# LIZARDWIZARD
- type: customGhost
id: LIZARDWIZARD-ghost
ckey: LIZARDWIZARD
sprite: _Ataraxia/Ghosts/LIZARDWIZARD.rsi
ghostName: LIZARDWIZARD
ghostDescription: Фр-Йиф.

# idoffront
- type: customGhost
id: idoffront-ghost
ckey: idoffront
sprite: _Ataraxia/Ghosts/idoffront.rsi
alpha: 0.8
ghostName: idoffront
ghostDescription: 1000-7.

# trest100
- type: customGhost
id: Trest100-ghost
ckey: trest100
sprite: _Ataraxia/Ghosts/trest100-ghost.rsi
alpha: 0.8
ghostName: Трести
ghostDescription: на что пялишся?

# Vetochka
- type: customGhost
id: Veta-ghost
ckey: Vetochka
sprite: _Ataraxia/Ghosts/Vetochka-ghost.rsi
ghostName: Vetochka
ghostDescription: Она могла быть твоей мамой, но увы...

# Boroven
- type: customGhost
id: kor-ghost
ckey: Boroven
sprite: _Ataraxia/Ghosts/Boroven-ghost.rsi
ghostName: Выживший
ghostDescription: Щупальца отдают химикатами, а крест слился с телом

# Spac__
- type: customGhost
id: Spac-ghost
ckey: Spac__
sprite: _Ataraxia/Ghosts/spac-ghost.rsi
ghostName: Шпаки
ghostDescription: я конечно не свитер, но меня тоже можно связать и натянуть

# kreses
- type: customGhost
id: kreses-ghost
ckey: kreses
sprite: _Ataraxia/Ghosts/kreses-ghost.rsi
alpha: 0.8
ghostName: Дракон сингулярности
ghostDescription: Владыка сингулярности

# joulerk
- type: customGhost
id: joulerk-ghost
ckey: Joulerk
sprite: _Ataraxia/Ghosts/joulerk-ghost.rsi
ghostName: ЛЕРК
ghostDescription: Летающее бирюзовое существо, напоминающее кота, с пушистым телом, грациозными движениями и глазами, сверкающими с загадочным блеском.
36 changes: 36 additions & 0 deletions Resources/Prototypes/_White/Ghosts/custom_ghosts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#scituzer2
- type: customGhost
id: scituzer2-ghost
ckey: scituzer2
sprite: _White/Ghosts/scituzer2-ghost.rsi
ghostName: Black Harpy
ghostDescription: A race of harpies that have charming onyx wings. Although they are a clever race, particularly having the highest intelligence of all harpies, on the other hand, they are exceedingly belligerent and ferocious. This one specifically used to be project lead of this project - but all she saw is world on fire.

#warete
- type: customGhost
id: warete-ghost
ckey: warete
sprite: _White/Ghosts/warete-ghost.rsi
alpha: 0.8
ghostName: Fiammetta
ghostDescription: Горничная под своим кодовым именем. Следит за порядком в кафе Мастера.
size: 0.7, 0.7

#pointpng
- type: customGhost
id: cheeseCheese-ghost
ckey: cheese_cheese
sprite: _White/Ghosts/cheese_cheese-ghost.rsi
alpha: 0.8
ghostName: Фырчало
ghostDescription: Инженерный борг

#mapperian
- type: customGhost
id: mapperian-ghost
ckey: mapperian
sprite: _White/Ghosts/mapperian-ghost.rsi
alpha: 0.9
ghostName: Alice Liddell
ghostDescription: found you found you found you found you found you found you found you found you found you found you found you found you found you found you found you found you found you found you found you found you found you found you found you
size: 0.7, 0.7
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Resources/Textures/_Ataraxia/Ghosts/Boroven-ghost.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "https://github.com/tgstation/tgstation/blob/f80e7ba62d27c77cfeac709dd71033744d0015c4/icons/mob/mob.dmi",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "animated",
"directions": 4
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Resources/Textures/_Ataraxia/Ghosts/GodFace.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": 1,
"license": "CC BY-NC-SA 4.0",
"copyright": "Sprited by PuroSlavKing (Github)",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "animated",
"directions": 4
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions Resources/Textures/_Ataraxia/Ghosts/LIZARDWIZARD.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "animated",
"directions": 4
},
{
"name": "icon"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions Resources/Textures/_Ataraxia/Ghosts/PuroSlavKing.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Edited by SShved, made by borkroman",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "animated",
"directions": 4,
"delays": [
[
0.2,
0.2,
0.2,
0.2,
0.2,
0.2
],
[
0.2,
0.2,
0.2,
0.2,
0.2,
0.2
],
[
0.2,
0.2,
0.2,
0.2,
0.2,
0.2
],
[
0.2,
0.2,
0.2,
0.2,
0.2,
0.2
]
]
},
{
"name": "icon"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Sprited by vetochka_igrit (Discord)",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "animated",
"directions": 4
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading