コード例 #1
0
 public static Color GetCurrentParticleColor(SeekerBarrier barrier)
 {
     if (barrier is CustomSeekerBarrier customBarrier)
     {
         return(customBarrier.particleColor);
     }
     return(getAndLerp(controller => controller.particleColor, Color.White, Color.Lerp));
 }
コード例 #2
0
 public static float GetCurrentParticleTransparency(SeekerBarrier barrier)
 {
     if (barrier is CustomSeekerBarrier customBarrier)
     {
         return(customBarrier.particleTransparency);
     }
     return(getAndLerp(controller => controller.particleTransparency, 0.5f, MathHelper.Lerp));
 }
コード例 #3
0
        private static void hookSeekerBarrierParticles(On.Celeste.SeekerBarrier.orig_Update orig, SeekerBarrier self)
        {
            float particleDirection = controllerOnScreen?.particleDirection ?? 0f;

            if (self is CustomSeekerBarrier customBarrier)
            {
                particleDirection = customBarrier.particleDirection;
            }

            // no need to account for screen transitions: particles are frozen during them.
            if (particleDirection == 0f)
            {
                // default settings: do nothing
                orig(self);
                return;
            }

            // save all particles
            DynData <SeekerBarrier> selfData  = new DynData <SeekerBarrier>(self);
            List <Vector2>          particles = new List <Vector2>(selfData.Get <List <Vector2> >("particles"));

            float[] speeds = selfData.Get <float[]>("speeds");

            // run vanilla code
            orig(self);

            // move particles again ourselves, except on the direction we want.
            for (int i = 0; i < particles.Count; i++)
            {
                // compute new position
                Vector2 newPosition = particles[i] + Vector2.UnitY.Rotate((float)(particleDirection * Math.PI / 180)) * speeds[i % speeds.Length] * Engine.DeltaTime;

                // make sure it stays in bounds
                while (newPosition.X < 0)
                {
                    newPosition.X += self.Width;
                }
                while (newPosition.Y < 0)
                {
                    newPosition.Y += self.Height;
                }
                newPosition.X %= self.Width;
                newPosition.Y %= self.Height;

                // replace the particle position
                particles[i] = newPosition;
            }

            // replace them.
            selfData["particles"] = particles;
        }