Skip to content

Commit

Permalink
Pass ShadowKinPowerSystem Blackeye methods to Blackeye system
Browse files Browse the repository at this point in the history
  • Loading branch information
vaketola committed Apr 27, 2024
1 parent d07db68 commit fe60220
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public sealed class ShadowkinPowerSystem : EntitySystem
{
[Dependency] private readonly IEntityManager _entity = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly ShadowkinBlackeyeSystem _blackeye = default!;

private readonly Dictionary<ShadowkinPowerThreshold, string> _powerDictionary;

Expand Down Expand Up @@ -198,34 +199,15 @@ public void SetPowerLevel(EntityUid uid, float newPowerLevel)
/// </summary>
public bool TryBlackeye(EntityUid uid)
{
var ent = _entity.GetNetEntity(uid);
// Raise an attempted blackeye event
var ev = new ShadowkinBlackeyeAttemptEvent(ent);
RaiseLocalEvent(ev);
if (ev.Cancelled)
return false;

Blackeye(uid);
return true;
return _blackeye.TryBlackeye(uid);
}

/// <summary>
/// Blackeyes a shadowkin
/// </summary>
public void Blackeye(EntityUid uid)
{
var ent = _entity.GetNetEntity(uid);

// Get shadowkin component
if (!_entity.TryGetComponent<ShadowkinComponent>(uid, out var component))
{
DebugTools.Assert("Tried to blackeye entity without shadowkin component.");
return;
}

component.Blackeye = true;
RaiseNetworkEvent(new ShadowkinBlackeyeEvent(ent));
RaiseLocalEvent(new ShadowkinBlackeyeEvent(ent));
_blackeye.Blackeye(uid);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Shared.Parkstation.Species.Shadowkin.Events;
using Content.Shared.Popups;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

namespace Content.Server.Parkstation.Species.Shadowkin.Systems;

Expand Down Expand Up @@ -92,4 +93,40 @@ private void OnBlackeye(ShadowkinBlackeyeEvent ev)
null,
null);
}


/// <summary>
/// Tries to blackeye a shadowkin
/// </summary>
public bool TryBlackeye(EntityUid uid)
{
var ent = _entity.GetNetEntity(uid);
// Raise an attempted blackeye event
var ev = new ShadowkinBlackeyeAttemptEvent(ent);
RaiseLocalEvent(ev);
if (ev.Cancelled)
return false;

Blackeye(uid);
return true;
}

/// <summary>
/// Blackeyes a shadowkin
/// </summary>
public void Blackeye(EntityUid uid)
{
var ent = _entity.GetNetEntity(uid);

// Get shadowkin component
if (!_entity.TryGetComponent<ShadowkinComponent>(uid, out var component))
{
DebugTools.Assert("Tried to blackeye entity without shadowkin component.");
return;
}

component.Blackeye = true;
RaiseNetworkEvent(new ShadowkinBlackeyeEvent(ent));
RaiseLocalEvent(new ShadowkinBlackeyeEvent(ent));
}
}

0 comments on commit fe60220

Please sign in to comment.