static IEnumerable <IFinalizedRenderable> DrawZapWandering(WorldRenderer wr, float2 from, float2 to, ISpriteSequence s, string pal) { var z = float2.Zero; /* hack */ var dist = to - from; var norm = (1f / dist.Length) * new float2(-dist.Y, dist.X); var renderables = new List <IFinalizedRenderable>(); if (Game.CosmeticRandom.Next(2) != 0) { var p1 = from + (1 / 3f) * dist + WRange.FromPDF(Game.CosmeticRandom, 2).Range *dist.Length / 4096 * norm; var p2 = from + (2 / 3f) * dist + WRange.FromPDF(Game.CosmeticRandom, 2).Range *dist.Length / 4096 * norm; renderables.AddRange(DrawZap(wr, from, p1, s, out p1, pal)); renderables.AddRange(DrawZap(wr, p1, p2, s, out p2, pal)); renderables.AddRange(DrawZap(wr, p2, to, s, out z, pal)); } else { var p1 = from + (1 / 2f) * dist + WRange.FromPDF(Game.CosmeticRandom, 2).Range *dist.Length / 4096 * norm; renderables.AddRange(DrawZap(wr, from, p1, s, out p1, pal)); renderables.AddRange(DrawZap(wr, p1, to, s, out z, pal)); } return(renderables); }
public ThrowsParticle(ActorInitializer init, ThrowsParticleInfo info) { var self = init.self; var rs = self.Trait <RenderSimple>(); var body = self.Trait <IBodyOrientation>(); // TODO: Carry orientation over from the parent instead of just facing var bodyFacing = init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : 0; facing = Turreted.GetInitialTurretFacing(init, 0); // Calculate final position var throwRotation = WRot.FromFacing(Game.CosmeticRandom.Next(1024)); var throwDistance = Game.CosmeticRandom.Next(info.MinThrowRange.Range, info.MaxThrowRange.Range); initialPos = pos = info.Offset.Rotate(body.QuantizeOrientation(self, WRot.FromFacing(bodyFacing))); finalPos = initialPos + new WVec(throwDistance, 0, 0).Rotate(throwRotation); angle = new WAngle(Game.CosmeticRandom.Next(info.MinThrowAngle.Angle, info.MaxThrowAngle.Angle)); length = (finalPos - initialPos).Length / info.Velocity; // Facing rotation rotation = WRange.FromPDF(Game.CosmeticRandom, 2).Range *info.ROT / 1024; var anim = new Animation(init.world, rs.GetImage(self), () => (int)facing); anim.PlayRepeating(info.Anim); rs.Add(info.Anim, new AnimationWithOffset(anim, () => pos, null)); }