Files
tbd-station-14/Content.Server/Tesla/EntitySystem/TeslaEnergyBallSystem.cs
Ed 0f8c004a2f Teslaloose and Singuloose counterplay (#23444)
* add tesla dissapear mechanic
add field holobarrier

* add PD

* add crafting

* spacing

* added to cargo

* Fix

* resprite + damageable

* oopsie

* Update Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml

Co-authored-by: Kara <lunarautomaton6@gmail.com>

* Update Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml

Co-authored-by: Kara <lunarautomaton6@gmail.com>

* Update Resources/Locale/en-US/research/technologies.ftl

Co-authored-by: Kara <lunarautomaton6@gmail.com>

---------

Co-authored-by: Kara <lunarautomaton6@gmail.com>
2024-01-04 18:48:09 -08:00

57 lines
1.9 KiB
C#

using Content.Server.Administration.Logs;
using Content.Server.Singularity.Components;
using Content.Server.Tesla.Components;
using Content.Shared.Database;
using Content.Shared.Singularity.Components;
using Content.Shared.Mind.Components;
using Content.Shared.Tag;
using Robust.Shared.Physics.Events;
using Content.Server.Lightning.Components;
using Robust.Server.Audio;
using Content.Server.Singularity.Events;
namespace Content.Server.Tesla.EntitySystems;
/// <summary>
/// A component that tracks an entity's saturation level from absorbing other creatures by touch, and spawns new entities when the saturation limit is reached.
/// </summary>
public sealed class TeslaEnergyBallSystem : EntitySystem
{
[Dependency] private readonly AudioSystem _audio = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<TeslaEnergyBallComponent, EntityConsumedByEventHorizonEvent>(OnConsumed);
}
private void OnConsumed(Entity<TeslaEnergyBallComponent> tesla, ref EntityConsumedByEventHorizonEvent args)
{
Spawn(tesla.Comp.ConsumeEffectProto, Transform(args.Entity).Coordinates);
if (TryComp<SinguloFoodComponent>(args.Entity, out var singuloFood))
{
AdjustEnergy(tesla, tesla.Comp, singuloFood.Energy);
} else
{
AdjustEnergy(tesla, tesla.Comp, tesla.Comp.ConsumeStuffEnergy);
}
}
public void AdjustEnergy(EntityUid uid, TeslaEnergyBallComponent component, float delta)
{
component.Energy += delta;
if (component.Energy > component.NeedEnergyToSpawn)
{
component.Energy -= component.NeedEnergyToSpawn;
Spawn(component.SpawnProto, Transform(uid).Coordinates);
}
if (component.Energy < component.EnergyToDespawn)
{
_audio.PlayPvs(component.SoundCollapse, uid);
QueueDel(uid);
}
}
}