Add FTL arrival visuals (#29402)

* Add FTL arrival visuals

* weh

* Update Content.Shared/Shuttles/Components/FTLComponent.cs

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>

---------

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
This commit is contained in:
metalgearsloth
2024-07-01 16:11:30 +10:00
committed by GitHub
parent 5543689c14
commit b6cf2ce524
10 changed files with 196 additions and 9 deletions

View File

@@ -82,6 +82,8 @@ public sealed partial class ShuttleSystem
private void InitializeFTL()
{
SubscribeLocalEvent<StationPostInitEvent>(OnStationPostInit);
SubscribeLocalEvent<FTLComponent, ComponentShutdown>(OnFtlShutdown);
_bodyQuery = GetEntityQuery<BodyComponent>();
_buckleQuery = GetEntityQuery<BuckleComponent>();
_beaconQuery = GetEntityQuery<FTLBeaconComponent>();
@@ -98,6 +100,12 @@ public sealed partial class ShuttleSystem
_cfg.OnValueChanged(CCVars.HyperspaceKnockdownTime, time => _hyperspaceKnockdownTime = TimeSpan.FromSeconds(time), true);
}
private void OnFtlShutdown(Entity<FTLComponent> ent, ref ComponentShutdown args)
{
Del(ent.Comp.VisualizerEntity);
ent.Comp.VisualizerEntity = null;
}
private void OnStationPostInit(ref StationPostInitEvent ev)
{
// Add all grid maps as ftl destinations that anyone can FTL to.
@@ -422,8 +430,16 @@ public sealed partial class ShuttleSystem
var comp = entity.Comp1;
comp.StateTime = StartEndTime.FromCurTime(_gameTiming, DefaultArrivalTime);
comp.State = FTLState.Arriving;
// TODO: Arrival effects
// For now we'll just use the ss13 bubbles but we can do fancier.
if (entity.Comp1.VisualizerProto != null)
{
comp.VisualizerEntity = SpawnAtPosition(entity.Comp1.VisualizerProto, entity.Comp1.TargetCoordinates);
var visuals = Comp<FtlVisualizerComponent>(comp.VisualizerEntity.Value);
visuals.Grid = entity.Owner;
Dirty(comp.VisualizerEntity.Value, visuals);
_transform.SetLocalRotation(comp.VisualizerEntity.Value, entity.Comp1.TargetAngle);
_pvs.AddGlobalOverride(comp.VisualizerEntity.Value);
}
_thruster.DisableLinearThrusters(shuttle);
_thruster.EnableLinearThrustDirection(shuttle, DirectionFlag.South);