forked from Lost-Paradise-Project/Lost-Paradise
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/BL02DL/BL-CORP
- Loading branch information
Showing
16 changed files
with
3,481 additions
and
2,695 deletions.
There are no files selected for viewing
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
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
32 changes: 32 additions & 0 deletions
32
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,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; | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
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,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; | ||
} | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
Content.Shared/_White/CustomGhostSpriteSystem/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,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 | ||
} |
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
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
Oops, something went wrong.