-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a625d9e
commit 94e6b2e
Showing
102 changed files
with
2,263 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
Content.Client/_White/CustomGhostSpriteSystem/CustomGhostVisualizer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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; | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
Content.Server/_White/CustomGhostSpriteSystem/CustomGhostSpriteSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
Content.Shared/_White/CustomGhostSystem/CustomGhostPrototype.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Numerics; | ||
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; | ||
|
||
[DataField("size")] | ||
public Vector2 SizeOverride = Vector2.One; | ||
} | ||
|
||
[Serializable, NetSerializable] | ||
public enum CustomGhostAppearance | ||
{ | ||
Sprite, | ||
AlphaOverride, | ||
SizeOverride | ||
} |
Oops, something went wrong.