Example #1
0
        public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            if (UpgradeMinEnabledLevel > 0)
            {
                yield break;
            }

            var body = init.Actor.TraitInfo <BodyOrientationInfo>();
            var t    = init.Actor.TraitInfos <TurretedInfo>()
                       .First(tt => tt.Turret == Turret);

            var ifacing    = init.Actor.TraitInfoOrDefault <IFacingInfo>();
            var bodyFacing = ifacing != null?init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : ifacing.GetInitialFacing() : 0;

            var turretFacing = Turreted.GetInitialTurretFacing(init, t.InitialFacing, Turret);

            var anim = new Animation(init.World, image, () => turretFacing);

            anim.Play(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence));

            var orientation = body.QuantizeOrientation(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(bodyFacing)), facings);
            var offset      = body.LocalToWorld(t.Offset.Rotate(orientation));

            yield return(new SpriteActorPreview(anim, offset, -(offset.Y + offset.Z) + 1, p, rs.Scale));
        }
Example #2
0
        public IEnumerable <VoxelAnimation> RenderPreviewVoxels(ActorPreviewInitializer init, RenderVoxelsInfo rv, string image, WRot orientation, int facings, PaletteReference p)
        {
            if (UpgradeMinEnabledLevel > 0)
            {
                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 voxel = VoxelProvider.GetVoxel(image, Sequence);

            var turretFacing      = Turreted.GetInitialTurretFacing(init, t.InitialFacing, t.Turret);
            var turretOrientation = body.QuantizeOrientation(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(turretFacing) - orientation.Yaw), facings);

            var quantizedTurret = body.QuantizeOrientation(turretOrientation, facings);
            var quantizedBody   = body.QuantizeOrientation(orientation, facings);
            var barrelOffset    = body.LocalToWorld((t.Offset + LocalOffset.Rotate(quantizedTurret)).Rotate(quantizedBody));

            yield return(new VoxelAnimation(voxel, () => barrelOffset, () => new[] { turretOrientation, orientation },
                                            () => false, () => 0));
        }