Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion code/entity/Mote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Mote : ModelEntity
{
[BindComponent] public SelfDestruct SelfDestruct { get; }

private Particles MoteBeam;

public override void Spawn()
{
Model = Cloud.Model( "destiny.gambit_mote" );
Expand All @@ -36,7 +38,13 @@ public override void Spawn()
moteGlow.Parent = this;
moteGlow.Brightness = 0.1f;
moteGlow.Range = 128f;
moteGlow.Color = GameConfig.RainbowMotes ? new ColorHsv(Random.Shared.NextSingle() * 360, 1, 1).ToColor() : Color.White;
var col = GameConfig.RainbowMotes ? new ColorHsv( Random.Shared.NextSingle() * 360, 1, 1 ).ToColor() : Color.White;
moteGlow.Color = col;

// cant parent to self because the beam should face up not sideways
MoteBeam = Particles.Create( "particles/mote_beam.vpcf" );
Vector3 rgb = new( col.r, col.g, col.b );
MoteBeam.Set( "BeamColor", rgb );
}

[Sandbox.GameEvent.PreRender]
Expand All @@ -51,5 +59,23 @@ public void BeforeRender()
EnableDrawing = true;
}
}

// have to override delete because self destruct doesnt catch the beam
public new virtual void Delete()
{
MoteBeam.Destroy();
base.Delete();
}

[GameEvent.Tick.Server]
private void UpdateBeam()
{
if ( SelfDestruct.Lifetime.Relative <= 5 ) {
MoteBeam.EnableDrawing = (SelfDestruct.Lifetime.Relative % 0.25) > 0.125;
}
var beamPos = Position + new Vector3( 0, 0, 30 );
MoteBeam.SetPosition( 0, beamPos );
MoteBeam.SetOrientation( 0, new Angles( 90, 0, 0 ) );
}
}
}
Loading