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)); }
public ThrowsParticle(ActorInitializer init, ThrowsParticleInfo info) { this.info = info; var self = init.self; var rs = self.Trait <RenderSimple>(); // 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 throwOffset = new WVec((int)(Game.CosmeticRandom.Gauss1D(1) * info.ThrowRange.Range), 0, 0).Rotate(throwRotation); initialPos = pos = info.Offset.Rotate(rs.QuantizeOrientation(self, WRot.FromFacing(bodyFacing))); finalPos = initialPos + throwOffset; // Facing rotation rotation = Game.CosmeticRandom.Gauss1D(2) * info.ROT; var anim = new Animation(rs.GetImage(self), () => (int)facing); anim.PlayRepeating(info.Anim); rs.anims.Add(info.Anim, new AnimationWithOffset(anim, wr => wr.ScreenPxOffset(pos), null)); }
public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info) : base(init.self, info) { this.info = info; turret = turrets.FirstOrDefault(); rb = init.self.Trait <RenderBuilding>(); skippedMakeAnimation = init.Contains <SkipMakeAnimsInit>(); }
public ThrowsParticle(ActorInitializer init, ThrowsParticleInfo info) { var self = init.self; var ifacing = self.Trait <IFacing>(); var ru = self.Trait <RenderUnit>(); alt = 0; facing = Turreted.GetInitialTurretFacing(init, 0); pos = Combat.GetTurretPosition(self, ifacing, new Turret(info.Offset)).ToFloat2(); v = Game.CosmeticRandom.Gauss2D(1) * info.Spread.RelOffset(); dfacing = Game.CosmeticRandom.Gauss1D(2) * info.ROT; va = info.Speed; var anim = new Animation(ru.GetImage(self), () => (int)facing); anim.PlayRepeating(info.Anim); ru.anims.Add(info.AnimKey, new AnimationWithOffset( anim, () => pos - new float2(0, alt), null)); }
public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info) : base(init.self) { Info = info; buildComplete = init.Contains <SkipMakeAnimsInit>(); turret = turrets.FirstOrDefault(); }
public AttackTurreted(Actor self) : base(self) { turret = self.Trait <Turreted>(); }