FootballWorldPanel.LegendaryEffects.cs

Search for context on these helpers

Rough Code
using Sandbox;
using Socer;

public sealed partial class FootballWorldPanel
{
    void DrawLegendaryRunWake(int player,Point centre,Point target)
    {
        var forward=(target-centre).Unit;var side=new Point(-forward.Y,forward.X);
        for(int segment=0;segment<LegendaryVisuals.MaximumStrokes;segment++)
        {
            var beam=uniqueTrailObjects[player,segment];
            if(segment>=3){if(beam!=null)beam.Enabled=false;continue;}
            if(beam==null)beam=uniqueTrailObjects[player,segment]=Create(sphere,"Legendary coordinated run");
            var tip=centre+forward*.75f;
            var start=segment==0?centre-forward*.38f:centre+forward*.43f+side*(segment==1?-.23f:.23f);
            SetPart(beam,start,.08f,tip,.08f,.037f,"#dac08a");beam.Enabled=true;
        }
    }
    void DrawLegendaryWake(int player,LegendaryAbility ability,Point centre,float facing,float age,int kickFoot)
    {
        for(int segment=0;segment<LegendaryVisuals.MaximumStrokes;segment++)
        {
            var beam=uniqueTrailObjects[player,segment];
            if(beam==null)beam=uniqueTrailObjects[player,segment]=Create(MatchWakeModel,"Legendary signature wake");
            if(beam.Model!=MatchWakeModel)beam.Model=MatchWakeModel;
            Point anchor=centre;float height=0;
            if(ability==LegendaryAbility.NotToday)
            {
                // Attach the effect to the rendered hands, including during a
                // dive and interpolated replay, rather than to a standing pose.
                var glove=actors[player][segment<4?9:12].WorldTransform.Position/Units;
                anchor=new Point(glove.x,-glove.y);height=glove.z;
            }
            else if(ability is LegendaryAbility.RoyalReception or LegendaryAbility.LaserFinish)
            {
                // Anchor the accent to the rendered striking boot. It follows
                // native and replay poses, rather than floating above a fall.
                var left=actors[player][2].WorldTransform.Position/Units;
                var right=actors[player][5].WorldTransform.Position/Units;
                var boot=ability==LegendaryAbility.RoyalReception?(left.z>right.z?left:right):
                    (kickFoot<0?left:right);
                anchor=new Point(boot.x,-boot.y);height=boot.z;
            }
            float envelope=LegendaryVisuals.Envelope(ability,age);
            var stroke=LegendaryVisuals.Get(ability,segment,anchor,facing,age);
            beam.Enabled=stroke.Color!=null && envelope>.01f;
            if(beam.Enabled)
            {
                SetPart(beam,stroke.A,stroke.ZA+height,stroke.B,stroke.ZB+height,stroke.Width*(.45f+.55f*envelope),stroke.Color);
                beam.Tint=beam.Tint.WithAlpha(envelope*.85f);
            }
        }
    }
}