Пример #1
0
        public Rider Simulate(
            ISimulationGrid grid,
            Bone[] bones,
            ref int activetriggers,
            LinkedList <int> collisions,
            int maxiteration = 6,
            bool stepscarf   = true,
            int frameid      = 0)
        {
            SimulationPoint[] body = Body.Step();
            int      bodylen       = Body.Length;
            bool     dead          = Crashed;
            bool     sledbroken    = SledBroken;
            RectLRTB phys          = new RectLRTB(ref body[0]);

            using (grid.Sync.AcquireRead())
            {
                for (int i = 0; i < maxiteration; i++)
                {
                    ProcessBones(bones, body, ref dead);
                    ProcessLines(grid, body, ref phys, ref activetriggers, collisions);
                }
            }
            if (maxiteration == 6)
            {
                var nose = body[RiderConstants.SledTR].Location - body[RiderConstants.SledTL].Location;
                var tail = body[RiderConstants.SledBL].Location - body[RiderConstants.SledTL].Location;
                var head = body[RiderConstants.BodyShoulder].Location - body[RiderConstants.BodyButt].Location;
                if ((nose.X * tail.Y) - (nose.Y * tail.X) < 0 || // tail fakie
                    (nose.X * head.Y) - (nose.Y * head.X) > 0)   // head fakie
                {
                    dead       = true;
                    sledbroken = true;
                }
            }
            SimulationPoint[] scarf;
            if (stepscarf)
            {
                scarf    = Scarf.Step(friction: true);
                scarf[0] = body[RiderConstants.BodyShoulder];
                FlutterScarf(scarf, frameid, Utility.LengthFast(scarf[0].Momentum));
                ProcessScarfBones(RiderConstants.ScarfBones, scarf);
            }
            else
            {
                scarf = new SimulationPoint[Scarf.Length];
            }
            return(new Rider(body, scarf, phys, dead, sledbroken));
        }
Пример #2
0
        public Rider Simulate(
            ISimulationGrid grid,
            Bone[] bones,
            LinkedList <int> collisions,
            int maxiteration = 6,
            bool stepscarf   = true,
            int frameid      = 0)
        {
            SimulationPoint[] body = Body.Step();
            int      bodylen       = Body.Length;
            bool     dead          = Crashed;
            bool     sledbroken    = SledBroken;
            int      rState        = remountState;
            int      rTimer        = remountTimer;
            RectLRTB phys          = new RectLRTB(ref body[0]);

            using (grid.Sync.AcquireRead())
            {
                for (int i = 0; i < maxiteration; i++)
                {
                    ProcessBones(bones, body, ref dead, ref rState);
                    ProcessLines(grid, body, ref phys, collisions);
                }
            }
            if (maxiteration == 6)
            {
                var nose = body[RiderConstants.SledTR].Location - body[RiderConstants.SledTL].Location;
                var tail = body[RiderConstants.SledBL].Location - body[RiderConstants.SledTL].Location;
                var head = body[RiderConstants.BodyShoulder].Location - body[RiderConstants.BodyButt].Location;
                if (!dead && ((nose.X * tail.Y) - (nose.Y * tail.X) < 0 || // tail fakie
                              (nose.X * head.Y) - (nose.Y * head.X) > 0))  // head fakie
                {
                    dead       = true;
                    sledbroken = true;
                }
            }

            if (UseRemount)
            {
                ProcessRemount(bones, body, ref dead, ref sledbroken, ref rState, ref rTimer);
            }

            SimulationPoint[] scarf;
            if (stepscarf)
            {
                scarf = Scarf.Step(friction: true);

                if (Settings.multiScarfAmount * Settings.multiScarfSegments > RiderConstants.ScarfBones.Length)
                {
                    Settings.multiScarfAmount = 1;
                }                                  //if too big set to zero

                if (Settings.multiScarfAmount > 1) //If using dual scarf
                {
                    List <SimulationPoint>[] scarves    = new List <SimulationPoint> [Settings.multiScarfAmount];
                    List <SimulationPoint>   finalScarf = new List <SimulationPoint>();

                    for (int i = 0; i < Settings.multiScarfAmount; i++)
                    {
                        scarf[i * Settings.multiScarfSegments] = body[RiderConstants.BodyShoulder];
                        scarves[i] = new List <SimulationPoint>();

                        if (i != Settings.multiScarfAmount - 1)
                        {
                            for (int k = 0; k < Settings.multiScarfSegments; k++)
                            {
                                scarves[i].Add(scarf[k + (i * Settings.multiScarfSegments)]);
                            }
                        }
                        else
                        {
                            for (int k = 0; k < scarf.Length - (i * Settings.multiScarfSegments); k++)
                            {
                                scarves[i].Add(scarf[k + (i * Settings.multiScarfSegments)]);
                            }
                        }

                        SimulationPoint[] scarfArr = scarves[i].ToArray();

                        FlutterScarf(scarfArr, frameid, Utility.LengthFast(scarf[i * Settings.multiScarfSegments].Momentum) + (i * 5));
                        ProcessScarfBones(RiderConstants.ScarfBones, scarfArr);

                        for (int j = 0; j < scarfArr.Length; j++)
                        {
                            finalScarf.Add(scarfArr[j]);
                        }
                    }

                    scarf = finalScarf.ToArray();
                }
                else
                {
                    scarf[0] = body[RiderConstants.BodyShoulder];
                    FlutterScarf(scarf, frameid, Utility.LengthFast(scarf[0].Momentum));
                    ProcessScarfBones(RiderConstants.ScarfBones, scarf);
                }
            }
            else
            {
                scarf = new SimulationPoint[Scarf.Length];
            }
            return(new Rider(body, scarf, phys, dead, sledbroken, UseRemount, rState, rTimer));
        }