* InitialCommit (Broken) * Fixes compile errors * PR comments. More doc comments. Fixes * Makes a singularity/event horizon without radiation/physics a valid state to be in * VV 'fake' setters, fixes the visualizer, fixes the singularity trying to eat itself instead of nearby things. * Removes unused dependency from Content.Client.GravityWellSystem * Testing containment and fake VV setters for SingularityGeneratorComponent * Fixes gravity wells (broken due to LookupFlags.None). Adds recursive Event Horizon consumption * Fix merge skew * Fixes for the master merge * Fix engine commit * Dirty is obsolete * Switch over dirty * Fix requested changes * ambiant -> ambient * Moves EventHorionComponent to Shared * Proper container handling * Fixes master merge. Fixes post insertion assertions for singularities. Extends proper container handling to gravity wells and the distortion shader. * Better support for admemes throwing singularities. * Moves update timing from accumulators to target times * Update doc comments
52 lines
1.9 KiB
C#
52 lines
1.9 KiB
C#
using Content.Server.Popups;
|
|
using Content.Server.Shuttles.Components;
|
|
using Content.Server.Singularity.Components;
|
|
using Content.Server.Singularity.EntitySystems;
|
|
using Content.Server.Singularity.Events;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Throwing;
|
|
using Robust.Shared.Physics.Components;
|
|
using Robust.Shared.Physics.Events;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Server.Singularity.EntitySystems;
|
|
|
|
public sealed class ContainmentFieldSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly ThrowingSystem _throwing = default!;
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ContainmentFieldComponent, StartCollideEvent>(HandleFieldCollide);
|
|
SubscribeLocalEvent<ContainmentFieldComponent, EventHorizonAttemptConsumeEntityEvent>(HandleEventHorizon);
|
|
}
|
|
|
|
private void HandleFieldCollide(EntityUid uid, ContainmentFieldComponent component, ref StartCollideEvent args)
|
|
{
|
|
var otherBody = args.OtherFixture.Body.Owner;
|
|
|
|
if (TryComp<SpaceGarbageComponent>(otherBody, out var garbage))
|
|
{
|
|
_popupSystem.PopupEntity(Loc.GetString("comp-field-vaporized", ("entity", otherBody)), component.Owner, PopupType.LargeCaution);
|
|
QueueDel(garbage.Owner);
|
|
}
|
|
|
|
if (TryComp<PhysicsComponent>(otherBody, out var physics) && physics.Mass <= component.MaxMass && physics.Hard)
|
|
{
|
|
var fieldDir = Transform(component.Owner).WorldPosition;
|
|
var playerDir = Transform(otherBody).WorldPosition;
|
|
|
|
_throwing.TryThrow(otherBody, playerDir-fieldDir, strength: component.ThrowForce);
|
|
}
|
|
}
|
|
|
|
private void HandleEventHorizon(EntityUid uid, ContainmentFieldComponent component, EventHorizonAttemptConsumeEntityEvent args)
|
|
{
|
|
if(!args.Cancelled && !args.EventHorizon.CanBreachContainment)
|
|
args.Cancel();
|
|
}
|
|
}
|