Skip to content

Commit

Permalink
fix set ghost color
Browse files Browse the repository at this point in the history
  • Loading branch information
Werzet committed May 6, 2024
1 parent 3501a78 commit d955c3b
Showing 1 changed file with 43 additions and 6 deletions.
49 changes: 43 additions & 6 deletions Content.Client/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
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 @@ -19,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 @@ -94,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 @@ -159,20 +187,29 @@ 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);
}

private void OnGhostState(EntityUid uid, GhostComponent component, ref AfterAutoHandleStateEvent args)
{
// ��� ������ �������� ����� � sprite.LayerSetColor ���� �����������, ���� ��� ������ ����� ������������ (���� ���� ���� ������� ������������ � ��� ����� � ��������)...
// ...����� ����������� ����, ���
var _random = new Random();
var color = new Color(_random.Next(1, 255), _random.Next(1, 255), _random.Next(1, 255));
if (TryComp<SpriteComponent>(uid, out var sprite))
{
sprite.LayerSetColor(0, color);

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

0 comments on commit d955c3b

Please sign in to comment.