Пример #1
0
        public override IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            // Show a static frame instead of animating all of the fullness states
            var anim = new Animation(init.World, image, () => 0);
            anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence), () => 0);

            yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale);
        }
Пример #2
0
        public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            var body   = init.Actor.TraitInfo <BodyOrientationInfo>();
            var facing = init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : 0;
            var anim   = new Animation(init.World, image, () => facing);

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

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

            yield return(new SpriteActorPreview(anim, offset, offset.Y + offset.Z + 1, p, rs.Scale));
        }
Пример #3
0
        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);

            anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence), () => 0);

            yield return(new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p, rs.Scale));
        }
Пример #4
0
        public virtual IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            if (UpgradeMinEnabledLevel > 0)
            {
                yield break;
            }

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

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

            yield return(new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale));
        }
Пример #5
0
        public override IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, string image, int facings, PaletteReference p)
        {
            if (!EnabledByDefault)
            {
                yield break;
            }

            var anim     = new Animation(init.World, image);
            var sequence = init.World.Type == WorldType.Editor ? EditorSequence : Sequence;
            var palette  = init.World.Type == WorldType.Editor ? init.WorldRenderer.Palette(EditorPalette) : p;

            anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), sequence), () => 0);
            yield return(new SpriteActorPreview(anim, () => WVec.Zero, () => 0, palette));
        }
Пример #6
0
        public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            var facing  = 0;
            var ifacing = init.Actor.TraitInfoOrDefault <IFacingInfo>();

            if (ifacing != null)
            {
                facing = init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : ifacing.GetInitialFacing();
            }

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

            anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), StandSequences.First()));
            yield return(new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale));
        }
Пример #7
0
        public override IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, string image, int facings, PaletteReference p)
        {
            if (!EnabledByDefault)
            {
                yield break;
            }

            var t   = init.Actor.TraitInfos <TurretedInfo>().FirstOrDefault();
            var wsb = init.Actor.TraitInfos <WithSpriteBodyInfo>().FirstOrDefault();

            // Show the correct turret facing
            var anim = new Animation(init.World, image, t.WorldFacingFromInit(init));

            anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), wsb.Sequence));

            yield return(new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p));
        }
Пример #8
0
        public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            var body     = init.Actor.Traits.Get <BodyOrientationInfo>();
            var armament = init.Actor.Traits.WithInterface <ArmamentInfo>()
                           .First(a => a.Name == Armament);
            var t = init.Actor.Traits.WithInterface <TurretedInfo>()
                    .First(tt => tt.Turret == armament.Turret);

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

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

            var turretOrientation = body.QuantizeOrientation(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(t.InitialFacing)), facings);
            var turretOffset      = body.LocalToWorld(t.Offset.Rotate(turretOrientation));

            yield return(new SpriteActorPreview(anim, turretOffset, turretOffset.Y + turretOffset.Z, p, rs.Scale));
        }
Пример #9
0
        public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, string image, int facings, PaletteReference p)
        {
            if (!EnabledByDefault)
            {
                yield break;
            }

            if (Palette != null)
            {
                var ownerName = init.Get <OwnerInit>().InternalName;
                p = init.WorldRenderer.Palette(IsPlayerPalette ? Palette + ownerName : Palette);
            }

            Func <WAngle> facing;
            var           dynamicfacingInit = init.GetOrDefault <DynamicFacingInit>();

            if (dynamicfacingInit != null)
            {
                facing = dynamicfacingInit.Value;
            }
            else
            {
                var f = init.GetValue <FacingInit, WAngle>(WAngle.Zero);
                facing = () => f;
            }

            var anim = new Animation(init.World, Image ?? image, facing)
            {
                IsDecoration = IsDecoration
            };

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

            var         body        = init.Actor.TraitInfo <BodyOrientationInfo>();
            Func <WRot> orientation = () => body.QuantizeOrientation(WRot.FromYaw(facing()), facings);
            Func <WVec> offset      = () => body.LocalToWorld(Offset.Rotate(orientation()));
            Func <int>  zOffset     = () =>
            {
                var tmpOffset = offset();
                return(tmpOffset.Y + tmpOffset.Z + 1);
            };

            yield return(new SpriteActorPreview(anim, offset, zOffset, p));
        }
Пример #10
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 = init.Contains<TurretFacingInit>() ? init.Get<TurretFacingInit, int>() : t.InitialFacing;

			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);
		}
Пример #11
0
        public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            if (!EnabledByDefault)
            {
                yield break;
            }

            if (Palette != null)
            {
                p = init.WorldRenderer.Palette(Palette);
            }

            Func <WAngle> facing;
            var           dynamicfacingInit = init.GetOrDefault <DynamicFacingInit>();

            if (dynamicfacingInit != null)
            {
                var getFacing = dynamicfacingInit.Value;
                facing = () => WAngle.FromFacing(getFacing());
            }
            else
            {
                var f = WAngle.FromFacing(init.GetValue <FacingInit, int>(0));
                facing = () => f;
            }

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

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

            var         body        = init.Actor.TraitInfo <BodyOrientationInfo>();
            Func <WRot> orientation = () => body.QuantizeOrientation(WRot.FromYaw(facing()), facings);
            Func <WVec> offset      = () => body.LocalToWorld(Offset.Rotate(orientation()));
            Func <int>  zOffset     = () =>
            {
                var tmpOffset = offset();
                return(tmpOffset.Y + tmpOffset.Z + 1);
            };

            yield return(new SpriteActorPreview(anim, offset, zOffset, p, rs.Scale));
        }
Пример #12
0
        public new IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            if (!EnabledByDefault)
            {
                yield break;
            }

            if (Palette != null)
            {
                p = init.WorldRenderer.Palette(Palette);
            }

            var        idleImage = Image != null ? Image : image;
            Func <int> facing;

            if (init.Contains <DynamicFacingInit>())
            {
                facing = init.Get <DynamicFacingInit, Func <int> >();
            }
            else
            {
                var f = init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : 0;
                facing = () => f;
            }

            var anim = new Animation(init.World, idleImage, facing);

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

            var         body        = init.Actor.TraitInfo <BodyOrientationInfo>();
            Func <WRot> orientation = () => body.QuantizeOrientation(WRot.FromFacing(facing()), facings);
            Func <WVec> offset      = () => body.LocalToWorld(Offset.Rotate(orientation()));
            Func <int>  zOffset     = () =>
            {
                var tmpOffset = offset();
                return(tmpOffset.Y + tmpOffset.Z + 1);
            };

            yield return(new SpriteActorPreview(anim, offset, zOffset, p, rs.Scale));
        }
Пример #13
0
        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));
        }
Пример #14
0
        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));
        }
Пример #15
0
 public override IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
 {
     var anim = new Animation(init.World, image);
     var sequence = init.World.Type == WorldType.Editor ? EditorSequence : Sequence;
     var palette = init.World.Type == WorldType.Editor ? init.WorldRenderer.Palette(EditorPalette) : p;
     anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), sequence), () => 0);
     yield return new SpriteActorPreview(anim, () => WVec.Zero, () => 0, palette, rs.Scale);
 }
Пример #16
0
        public override IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            var anim = new Animation(init.World, image);
            anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequences.First()), () => 0);

            yield return new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p, rs.Scale);
        }
Пример #17
0
        public override IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            if (!EnabledByDefault)
            {
                yield break;
            }

            var adjacent = 0;

            if (init.Contains <RuntimeNeighbourInit>())
            {
                var location = CPos.Zero;
                if (init.Contains <LocationInit>())
                {
                    location = init.Get <LocationInit, CPos>();
                }

                var neighbours = init.Get <RuntimeNeighbourInit, Dictionary <CPos, string[]> >();
                foreach (var kv in neighbours)
                {
                    var haveNeighbour = false;
                    foreach (var n in kv.Value)
                    {
                        var rb = init.World.Map.Rules.Actors[n].TraitInfos <IWallConnectorInfo>().FirstEnabledTraitOrDefault();
                        if (rb != null && rb.GetWallConnectionType() == Type)
                        {
                            haveNeighbour = true;
                            break;
                        }
                    }

                    if (!haveNeighbour)
                    {
                        continue;
                    }

                    if (kv.Key == location + new CVec(0, -1))
                    {
                        adjacent |= 1;
                    }
                    else if (kv.Key == location + new CVec(+1, 0))
                    {
                        adjacent |= 2;
                    }
                    else if (kv.Key == location + new CVec(0, +1))
                    {
                        adjacent |= 4;
                    }
                    else if (kv.Key == location + new CVec(-1, 0))
                    {
                        adjacent |= 8;
                    }
                }
            }

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

            anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence), () => adjacent);

            yield return(new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p, rs.Scale));
        }