Explosion refactor TEST MERG (#6995)

* Explosions

* fix yaml typo

and prevent silly UI inputs

* oop

Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
This commit is contained in:
Moony
2022-03-04 13:48:01 -06:00
committed by GitHub
parent 4e203f49d2
commit 4a466f4927
71 changed files with 3958 additions and 760 deletions

View File

@@ -1,40 +1,8 @@
using Content.Server.Throwing;
using Content.Shared.Acts;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
namespace Content.Server.Explosion.Components
namespace Content.Server.Explosion.Components;
// TODO EXPLOSION make this a tag? or just get rid of it and launch all unanchored physics entities?
[RegisterComponent]
public sealed class ExplosionLaunchedComponent : Component
{
[RegisterComponent]
public sealed class ExplosionLaunchedComponent : Component, IExAct
{
[Dependency] private readonly IEntityManager _entMan = default!;
void IExAct.OnExplosion(ExplosionEventArgs eventArgs)
{
if (_entMan.Deleted(Owner))
return;
var sourceLocation = eventArgs.Source;
var targetLocation = _entMan.GetComponent<TransformComponent>(eventArgs.Target).Coordinates;
if (sourceLocation.Equals(targetLocation)) return;
var offset = (targetLocation.ToMapPos(_entMan) - sourceLocation.ToMapPos(_entMan));
//Don't throw if the direction is center (0,0)
if (offset == Vector2.Zero) return;
var direction = offset.Normalized;
var throwForce = eventArgs.Severity switch
{
ExplosionSeverity.Heavy => 30,
ExplosionSeverity.Light => 20,
_ => 0,
};
Owner.TryThrow(direction, throwForce);
}
}
}