Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colorful ghosts #734

Merged
merged 7 commits into from
May 6, 2024
Merged
Changes from 6 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
46 changes: 44 additions & 2 deletions Content.Client/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Prototypes;
using System.Linq;
using System.Threading.Tasks;
using Content.Shared.Sprite;

namespace Content.Client.Ghost
{
Expand All @@ -18,6 +21,7 @@ public sealed class GhostSystem : SharedGhostSystem
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly ContentEyeSystem _contentEye = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;

public int AvailableGhostRoleCount { get; private set; }

Expand Down Expand Up @@ -93,6 +97,31 @@ private void OnToggleLighting(EntityUid uid, EyeComponent component, ToggleLight

private void OnToggleFoV(EntityUid uid, EyeComponent component, ToggleFoVActionEvent args)
{
if (TryComp<SpriteComponent>(uid, out var sprite))
{
var _random = new Random();
var color = new Color(_random.Next(1, 255), _random.Next(1, 255), _random.Next(1, 255));

// sprite.Color = color;

sprite.Rotation += Angle.FromDegrees(180.0f);

sprite.Color = sprite.Color.WithBlue(10);
//var t = sprite.GetType();

//var pr = t.GetProperties();

//var col = pr.FirstOrDefault(x => x.Name == "Color");

//if (col is not null)
//{

// col.GetSetMethod(true)!.Invoke(sprite, new object[] { color });
//}

// sprite.
// PlayerUpdated?.Invoke(Player);
}
if (args.Handled)
return;

Expand Down Expand Up @@ -158,6 +187,21 @@ private void OnGhostRemove(EntityUid uid, GhostComponent component, ComponentRem

private void OnGhostPlayerAttach(EntityUid uid, GhostComponent component, LocalPlayerAttachedEvent localPlayerAttachedEvent)
{
// SS220 colorful ghost begin
if (TryComp<SpriteComponent>(uid, out var sprite))
{
var random = new Random();

var color = new Color(
(float) random.Next(1, 255) / byte.MaxValue,
(float) random.Next(1, 255) / byte.MaxValue,
(float) random.Next(1, 255) / byte.MaxValue,
sprite.Color.A);

sprite.Color = color;
}
// SS220 colorful ghost end

GhostVisibility = true;
PlayerAttached?.Invoke(component);
}
Expand All @@ -166,8 +210,6 @@ private void OnGhostState(EntityUid uid, GhostComponent component, ref AfterAuto
{
if (TryComp<SpriteComponent>(uid, out var sprite))
{
sprite.LayerSetColor(0, component.color);

//SS220-ghost-hats
SetBodyVisuals(uid, sprite, component.BodyVisible);
}
Expand Down
Loading