Inheritance: IRenderActorPreviewInfo, ITraitInfo
コード例 #1
0
        public override IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            var t = init.Actor.Traits.WithInterface <TurretedInfo>()
                    .FirstOrDefault();

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

            anim.PlayRepeating("idle");

            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 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));
        }
コード例 #3
0
        public override IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            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>().FirstOrDefault(Exts.IsTraitEnabled);
                        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));
        }
コード例 #4
0
        public override IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            foreach (var orig in base.RenderPreviewSprites(init, rs, image, facings, p))
            {
                yield return(orig);
            }

            // Show additional roof overlay
            var anim = new Animation(init.World, image, () => 0);

            anim.PlayRepeating("idle-top");

            var bi     = init.Actor.Traits.Get <BuildingInfo>();
            var offset = FootprintUtils.CenterOffset(init.World, bi).Y + 512;

            yield return(new SpriteActorPreview(anim, WVec.Zero, offset, p, rs.Scale));
        }
コード例 #5
0
 public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
 {
     this.info = info;
     faction   = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : init.Self.Owner.Faction.InternalName;
 }
コード例 #6
0
        public override IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            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.InitialFacing);

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

            yield return(new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale));
        }
コード例 #7
0
        public IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            if (init.Contains <HideBibPreviewInit>() && init.Get <HideBibPreviewInit, bool>())
            {
                yield break;
            }

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

            var bi = init.Actor.TraitInfo <BuildingInfo>();

            var width        = bi.Dimensions.X;
            var bibOffset    = bi.Dimensions.Y - 1;
            var centerOffset = FootprintUtils.CenterOffset(init.World, bi);
            var rows         = HasMinibib ? 1 : 2;
            var map          = init.World.Map;
            var location     = CPos.Zero;

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

            for (var i = 0; i < rows * width; i++)
            {
                var index      = i;
                var anim       = new Animation(init.World, image);
                var cellOffset = new CVec(i % width, i / width + bibOffset);
                var cell       = location + cellOffset;

                // Some mods may define terrain-specific bibs
                var terrain      = map.GetTerrainInfo(cell).Type;
                var testSequence = Sequence + "-" + terrain;
                var sequence     = anim.HasSequence(testSequence) ? testSequence : Sequence;
                anim.PlayFetchIndex(sequence, () => index);
                anim.IsDecoration = true;

                // Z-order is one set to the top of the footprint
                var offset = map.CenterOfCell(cell) - map.CenterOfCell(location) - centerOffset;
                yield return(new SpriteActorPreview(anim, offset, -(offset.Y + centerOffset.Y + 512), p, rs.Scale));
            }
        }
コード例 #8
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 wall states
            var anim = new Animation(init.World, image, () => 0);

            anim.PlayFetchIndex("idle", () => 0);

            yield return(new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale));
        }
コード例 #9
0
        public virtual IEnumerable <IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
        {
            var ifacing = init.Actor.Traits.GetOrDefault <IFacingInfo>();
            var facing  = ifacing != null?init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : ifacing.GetInitialFacing() : 0;

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

            anim.PlayRepeating("idle");
            yield return(new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale));
        }
コード例 #10
0
 public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
 {
     this.info = info;
     race      = init.Contains <RaceInit>() ? init.Get <RaceInit, string>() : init.Self.Owner.Country.Race;
 }
コード例 #11
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(), Sequence), () => 0);

            yield return(new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale));
        }
コード例 #12
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 armament = init.Actor.TraitInfos <ArmamentInfo>()
                           .First(a => a.Name == Armament);
            var t = init.Actor.TraitInfos <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));
        }