public WithSpriteTurret(Actor self, WithSpriteTurretInfo info) : base(info) { rs = self.Trait <RenderSprites>(); body = self.Trait <BodyOrientation>(); Attack = self.TraitOrDefault <AttackBase>(); t = self.TraitsImplementing <Turreted>().First(tt => tt.Name == Info.Turret); arms = self.TraitsImplementing <Armament>().Where(w => w.Info.Turret == info.Turret).ToArray(); buildComplete = !self.Info.HasTraitInfo <BuildingInfo>(); DefaultAnimation = new Animation(self.World, rs.GetImage(self), () => t.TurretFacing); DefaultAnimation.PlayRepeating(NormalizeSequence(self, info.Sequence)); rs.Add(new AnimationWithOffset(DefaultAnimation, () => TurretOffset(self), () => IsTraitDisabled || !buildComplete, p => RenderUtils.ZOffsetFromCenter(self, p, 1))); t.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings; }
public WithIdleOverlay(Actor self, WithIdleOverlayInfo info) : base(info) { var rs = self.Trait <RenderSprites>(); var body = self.Trait <BodyOrientation>(); buildComplete = !self.Info.HasTraitInfo <BuildingInfo>();//always render instantly for units. overlay = new Animation(self.World, rs.GetImage(self), () => IsTraitPaused || (!info.RenderBeforeBuildComplete && !buildComplete)); if (info.StartSequence != null) { overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.StartSequence), () => overlay.PlayRepeating(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence))); } else { overlay.PlayRepeating(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence)); } var anim = new AnimationWithOffset(overlay, () => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))), () => IsTraitDisabled || (!info.RenderBeforeBuildComplete && !buildComplete), p => RenderUtils.ZOffsetFromCenter(self, p, 1)); rs.Add(anim, info.Palette, info.IsPlayerPalette); }