* upload all textures
finished easiest part - TeslaGenerator

* Added Tesla energy logic

* add lightning pulse priority

* work

* optimise lightning arc system

* now tesla moving to LightningTarget entity and consume it

* some audio work
add airlock and computers to the LightningTarget

* add nice visual and explosions
add crashing to game

* rsi meta fix

* disabling explosions (crashing server)
I'll get back to that problem later.

* adding important admin logging

* a little bit of cleaning and documentation

* Persistent attempts to fix the server crashing on explosions. Accidental cleaning of everything I see.

* now the tesla incinerates everything it touches except the containment field.

* colliders work

* fix falling tesla on ground after being exploded

* add consume sound, add spawn and collapses sound

* added TeslaGenerator to cargo trading console

* add all tesla part to cargo trading console

* Tesla coils: Turn on and off, get energy from lightning, give energy to the grid.

* tesla coil is ready

* tesla grounding rod is ready

* clean up

* clean up 2

* grounding rods now working without power

* add LightningResistance parameter for LightningTarget Component

* add chaotic teleport

* eletrocution remove?

* deltanedas fix pack

* more fixes

* FIXES

* FIIIXEEES

* The "Grounding Rod" component is removed, and replaced with "LightiningSparking", which is responsible for changing the visuals when hit by lightning. Duplicate code from the coil is removed.

* ops

* fix

* nah, is escaped anyway

* increase tesla collider size

* keron bb

* try fix test?

* fix

* bruh

* check turn off sus comp

* prototype cleaning

* FIIX

* return and fix sus component

* fix tesla eating lightnings, now mini tesla is electrocuted

* commented some issues

* remove linq sorting
fix jumping system
minor fixes

* fix second Linq

* fix tesla colliders! Yeah, it works

* fix componentregistration

* Just retests

* not fix

* FIX TESLA

* fixes

* store targets

* back

* make dictionary of hashsets

* some sloth fixes

* stump

* playtest balance energy generation, return to unpotimized (but working) lightning shoot

* parity

* work on

* some new fix, some new bug (chasingComponent not chasing)

* comment

* fix ChasingWalkSystem

* fix collider tesla problem

* revert old unoptimized shoot lightning

* new fix pack

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Ed
2023-12-28 16:11:50 +03:00
committed by GitHub
parent 06719a3232
commit 88d7cfb4c0
51 changed files with 1374 additions and 90 deletions

View File

@@ -0,0 +1,55 @@
using Content.Server.Lightning;
using Content.Server.Tesla.Components;
using Robust.Shared.Random;
using Robust.Shared.Timing;
namespace Content.Server.Tesla.EntitySystems;
/// <summary>
/// Fires electric arcs at surrounding objects.
/// </summary>
public sealed class LightningArcShooterSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly LightningSystem _lightning = default!;
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<LightningArcShooterComponent, MapInitEvent>(OnShooterMapInit);
SubscribeLocalEvent<LightningArcShooterComponent, EntityUnpausedEvent>(OnShooterUnpaused);
}
private void OnShooterMapInit(EntityUid uid, LightningArcShooterComponent component, ref MapInitEvent args)
{
component.NextShootTime = _gameTiming.CurTime;
}
private void OnShooterUnpaused(EntityUid uid, LightningArcShooterComponent component, ref EntityUnpausedEvent args)
{
component.NextShootTime += args.PausedTime;
}
public override void Update(float frameTime)
{
base.Update(frameTime);
var query = EntityQueryEnumerator<LightningArcShooterComponent>();
while (query.MoveNext(out var uid, out var arcShooter))
{
if (arcShooter.NextShootTime > _gameTiming.CurTime)
continue;
ArcShoot(uid, arcShooter);
var delay = TimeSpan.FromSeconds(_random.NextFloat(arcShooter.ShootMinInterval, arcShooter.ShootMaxInterval));
arcShooter.NextShootTime += delay;
}
}
private void ArcShoot(EntityUid uid, LightningArcShooterComponent component)
{
var arcs = _random.Next(1, component.MaxLightningArc);
_lightning.ShootRandomLightnings(uid, component.ShootRange, arcs, component.LightningPrototype, component.ArcDepth);
}
}

View File

@@ -0,0 +1,53 @@
using Content.Server.Tesla.Components;
using Content.Server.Lightning;
using Content.Shared.Power;
using Robust.Shared.Timing;
namespace Content.Server.Tesla.EntitySystems;
/// <summary>
/// The component changes the visual of an object after it is struck by lightning
/// </summary>
public sealed class LightningSparkingSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<LightningSparkingComponent, HitByLightningEvent>(OnHitByLightning);
SubscribeLocalEvent<LightningSparkingComponent, EntityUnpausedEvent>(OnLightningUnpaused);
}
private void OnLightningUnpaused(EntityUid uid, LightningSparkingComponent component, ref EntityUnpausedEvent args)
{
component.LightningEndTime += args.PausedTime;
}
private void OnHitByLightning(Entity<LightningSparkingComponent> uid, ref HitByLightningEvent args)
{
_appearance.SetData(uid.Owner, TeslaCoilVisuals.Lightning, true);
uid.Comp.LightningEndTime = _gameTiming.CurTime + TimeSpan.FromSeconds(uid.Comp.LightningTime);
uid.Comp.IsSparking = true;
}
public override void Update(float frameTime)
{
base.Update(frameTime);
var query = EntityQueryEnumerator<LightningSparkingComponent>();
while (query.MoveNext(out var uid, out var component))
{
if (!component.IsSparking)
continue;
if (component.LightningEndTime < _gameTiming.CurTime)
{
_appearance.SetData(uid, TeslaCoilVisuals.Lightning, false);
component.IsSparking = false;
}
}
}
}

View File

@@ -0,0 +1,32 @@
using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Tesla.Components;
using Content.Server.Lightning;
using Robust.Shared.Timing;
namespace Content.Server.Tesla.EntitySystems;
/// <summary>
/// Generates electricity from lightning bolts
/// </summary>
public sealed class TeslaCoilSystem : EntitySystem
{
[Dependency] private readonly BatterySystem _battery = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<TeslaCoilComponent, HitByLightningEvent>(OnHitByLightning);
}
//When struck by lightning, charge the internal battery
private void OnHitByLightning(Entity<TeslaCoilComponent> coil, ref HitByLightningEvent args)
{
if (!TryComp<BatteryComponent>(coil, out var batteryComponent))
return;
_battery.SetCharge(coil, batteryComponent.CurrentCharge + coil.Comp.ChargeFromLightning);
}
}

View File

@@ -0,0 +1,51 @@
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);
}
}
}