Ghosts do booo (spooky) (#3363)
* Light now use visualizer * Added ghost actions * Add hotkey input for ghosts * no message * Testing blinking animation * Better animation * Better customization * No abuse * Reversed sln * No fun for ghosts * No fun for ghosts x2 * Cooldown for lights * Moved to component deps * This tollist is unnecessary * Enums to byte Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Some lights can ignore ghosts now Co-authored-by: Alex Evgrashin <evgrashin.adl@gmail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
54
Content.Server/Actions/GhostBoo.cs
Normal file
54
Content.Server/Actions/GhostBoo.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
#nullable enable
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.Observer;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.Utility;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.Actions
|
||||
{
|
||||
/// <summary>
|
||||
/// Blink lights and scare livings
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public class GhostBoo : IInstantAction
|
||||
{
|
||||
private float _radius;
|
||||
private float _cooldown;
|
||||
private int _maxTargets;
|
||||
|
||||
void IExposeData.ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
serializer.DataField(ref _radius, "radius", 3);
|
||||
serializer.DataField(ref _cooldown, "cooldown", 120);
|
||||
serializer.DataField(ref _maxTargets, "maxTargets", 3);
|
||||
}
|
||||
|
||||
public void DoInstantAction(InstantActionEventArgs args)
|
||||
{
|
||||
if (!args.Performer.TryGetComponent<SharedActionsComponent>(out var actions)) return;
|
||||
|
||||
// find all IGhostBooAffected nearby and do boo on them
|
||||
var entityMan = args.Performer.EntityManager;
|
||||
var ents = entityMan.GetEntitiesInRange(args.Performer, _radius, false);
|
||||
|
||||
var booCounter = 0;
|
||||
foreach (var ent in ents)
|
||||
{
|
||||
var boos = ent.GetAllComponents<IGhostBooAffected>().ToList();
|
||||
foreach (var boo in boos)
|
||||
{
|
||||
if (boo.AffectedByGhostBoo(args))
|
||||
booCounter++;
|
||||
}
|
||||
|
||||
if (booCounter >= _maxTargets)
|
||||
break;
|
||||
}
|
||||
|
||||
actions.Cooldown(args.ActionType, Cooldowns.SecondsFromNow(_cooldown));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user