public new IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, string image, int facings, PaletteReference p) { if (!this.EnabledByDefault) { yield break; } var body = init.Actor.TraitInfoOrDefault <BodyOrientationInfo>(); var turretedInfo = init.Actor.TraitInfos <TurretedInfo>().FirstOrDefault(tt => tt.Turret == this.Turret); if (turretedInfo == null) { yield break; } var facing = init.GetFacing(); var offset = new Func <WVec>(() => body.LocalToWorld(turretedInfo.Offset.Rotate(body.QuantizeOrientation(WRot.FromYaw(facing()), facings)))); var bodyAnim = new Animation(init.World, image, init.GetFacing()); bodyAnim.PlayRepeating(RenderSprites.NormalizeSequence(bodyAnim, init.GetDamageState(), "idle")); if (bodyAnim.CurrentSequence is OffsetsSpriteSequence bodySequence && bodySequence.EmbeddedOffsets.TryGetValue(bodyAnim.Image, out var imageOffset)) { var point = imageOffset.FirstOrDefault(p1 => p1.Id == 0); if (point != null) { offset = () => new(point.X * 32, point.Y * 32, 0); } } if (this.IsPlayerPalette) { p = init.WorldRenderer.Palette(this.Palette + init.Get <OwnerInit>().InternalName); } else if (this.Palette != null) { p = init.WorldRenderer.Palette(this.Palette); } var turretFacing = turretedInfo.WorldFacingFromInit(init); var anim = new Animation(init.World, image, turretFacing); anim.Play(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), this.Sequence)); yield return(new SpriteActorPreview( anim, offset, () => { var tmpOffset = offset(); return -(tmpOffset.Y + tmpOffset.Z) + 1; }, p )); }
public new IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, string image, int facings, PaletteReference p) { if (!EnabledByDefault) { yield break; } var body = init.Actor.TraitInfo <BodyOrientationInfo>(); var t = init.Actor.TraitInfos <TurretedInfo>() .First(tt => tt.Turret == Turret); var bodyAnim = new Animation(init.World, image, init.GetFacing()); bodyAnim.PlayRepeating(RenderSprites.NormalizeSequence(bodyAnim, init.GetDamageState(), "idle")); var bodySequence = bodyAnim.CurrentSequence as OffsetsSpriteSequence; Func <WVec> offset = null; if (bodySequence != null && bodySequence.EmbeddedOffsets.ContainsKey(bodyAnim.Image) && bodySequence.EmbeddedOffsets[bodyAnim.Image] != null) { var point = bodySequence.EmbeddedOffsets[bodyAnim.Image].FirstOrDefault(p1 => p1.Id == 0); if (point != null) { offset = () => new WVec(point.X * 32, point.Y * 32, 0); } } var turretFacing = t.WorldFacingFromInit(init); var anim = new Animation(init.World, image, turretFacing); anim.Play(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); if (offset == null) { var facing = init.GetFacing(); Func <WRot> orientation = () => body.QuantizeOrientation(WRot.FromYaw(facing()), facings); offset = () => body.LocalToWorld(t.Offset.Rotate(orientation())); } Func <int> zOffset = () => { var tmpOffset = offset(); return(-(tmpOffset.Y + tmpOffset.Z) + 1); }; if (IsPlayerPalette) { p = init.WorldRenderer.Palette(Palette + init.Get <OwnerInit>().InternalName); } else if (Palette != null) { p = init.WorldRenderer.Palette(Palette); } yield return(new SpriteActorPreview(anim, offset, zOffset, p)); }
public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { if (!EnabledByDefault) { yield break; } var body = init.Actor.TraitInfo <BodyOrientationInfo>(); var armament = init.Actor.TraitInfos <ArmamentInfo>() .First(a => a.Name == Armament); var t = init.Actor.TraitInfos <TurretedInfo>() .First(tt => tt.Turret == armament.Turret); var turretFacing = Turreted.TurretFacingFromInit(init, t); var anim = new Animation(init.World, image, turretFacing); anim.Play(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); var facing = init.GetFacing(); Func <WRot> orientation = () => body.QuantizeOrientation(WRot.FromYaw(facing()), facings); Func <WVec> turretOffset = () => body.LocalToWorld(t.Offset.Rotate(orientation())); Func <int> zOffset = () => { var tmpOffset = turretOffset(); return(-(tmpOffset.Y + tmpOffset.Z) + 1); }; yield return(new SpriteActorPreview(anim, turretOffset, zOffset, p, rs.Scale)); }
public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { var anim = new Animation(init.World, image, init.GetFacing()); anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), StandSequences.First())); yield return(new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p, rs.Scale)); }
public override IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { if (!EnabledByDefault) { yield break; } var anim = new Animation(init.World, image, init.GetFacing()); anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); yield return(new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p, rs.Scale)); }
public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { if (!EnabledByDefault) { yield break; } var anim = new Animation(init.World, image, init.GetFacing()); anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), StandSequences.First())); if (IsPlayerPalette) { p = init.WorldRenderer.Palette(Palette + init.Get <OwnerInit>().InternalName); } else if (Palette != null) { p = init.WorldRenderer.Palette(Palette); } yield return(new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p, rs.Scale)); }
public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, string image, int facings, PaletteReference p) { if (!EnabledByDefault) { yield break; } var body = init.Actor.TraitInfo <BodyOrientationInfo>(); var t = init.Actor.TraitInfos <TurretedInfo>() .First(tt => tt.Turret == Turret); var turretFacing = t.WorldFacingFromInit(init); var anim = new Animation(init.World, image, turretFacing); anim.Play(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); var facing = init.GetFacing(); Func <WRot> orientation = () => body.QuantizeOrientation(WRot.FromYaw(facing()), facings); Func <WVec> offset = () => body.LocalToWorld(t.Offset.Rotate(orientation())); Func <int> zOffset = () => { var tmpOffset = offset(); return(-(tmpOffset.Y + tmpOffset.Z) + 1); }; if (IsPlayerPalette) { p = init.WorldRenderer.Palette(Palette + init.Get <OwnerInit>().InternalName); } else if (Palette != null) { p = init.WorldRenderer.Palette(Palette); } yield return(new SpriteActorPreview(anim, offset, zOffset, p)); }