示例#1
0
        void INotifyAddedToWorld.AddedToWorld(Actor self)
        {
            var rows         = info.HasMinibib ? 1 : 2;
            var width        = bi.Dimensions.X;
            var bibOffset    = bi.Dimensions.Y - rows;
            var centerOffset = bi.CenterOffset(self.World);
            var location     = self.Location;
            var map          = self.World.Map;

            for (var i = 0; i < rows * width; i++)
            {
                var index      = i;
                var anim       = new Animation(self.World, rs.GetImage(self));
                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 = info.Sequence + "-" + terrain;
                var sequence     = anim.HasSequence(testSequence) ? testSequence : info.Sequence;
                anim.PlayFetchIndex(sequence, () => index);
                anim.IsDecoration = true;

                // Z-order is one set to the top of the footprint
                var offset = self.World.Map.CenterOfCell(cell) - self.World.Map.CenterOfCell(location) - centerOffset;
                var awo    = new AnimationWithOffset(anim, () => offset, null, -(offset.Y + centerOffset.Y + 512));
                anims.Add(awo);
                rs.Add(awo, info.Palette);
            }
        }
示例#2
0
        public PlaceBuildingOrderGenerator(ProductionQueue queue, string name, WorldRenderer worldRenderer)
        {
            var world = queue.Actor.World;

            this.queue        = queue;
            viewport          = worldRenderer.ViewPort;
            placeBuildingInfo = queue.Actor.Owner.PlayerActor.Info.TraitInfo <PlaceBuildingInfo>();
            building          = name;


            if (WarGame.Settings.Game.UseClassicMouseStyle)
            {
                world.Selection.Clear();
            }

            var map     = world.Map;
            var tileset = world.Map.Tileset.ToLowerInvariant();

            var info = map.Rules.Actors[building];

            buildingInfo        = info.TraitInfo <BuildingInfo>();
            centerOffset        = buildingInfo.CenterOffset(world);
            topLeftScreenOffset = -worldRenderer.ScreenPxOffset(centerOffset);

            var buildableInfo      = info.TraitInfo <BuildableInfo>();
            var mostLikelyProducer = queue.MostLikelyProducer();

            faction = buildableInfo.ForceFaction ?? (mostLikelyProducer.Trait != null ? mostLikelyProducer.Trait.Faction : queue.Actor.Owner.Faction.InternalName);

            buildOk      = map.Rules.Sequences.GetSequence("overlay", "build-valid-{0}".F(tileset)).GetSprite(0);
            buildBlocked = map.Rules.Sequences.GetSequence("overlay", "build-invalid").GetSprite(0);

            buildingInfluence = world.WorldActor.Trait <BuildingInfluence>();
        }
        public BuilderUnitBuildingOrderGenerator(BuilderUnit queue, string name, WorldRenderer worldRenderer)
        {
            var world = queue.Actor.World;

            this.queue        = queue;
            viewport          = worldRenderer.Viewport;
            placeBuildingInfo = queue.Actor.Owner.PlayerActor.Info.TraitInfo <PlaceBuildingInfo>();

            // Clear selection if using Left-Click Orders
            if (Game.Settings.Game.UseClassicMouseStyle)
            {
                world.Selection.Clear();
            }

            var map     = world.Map;
            var tileset = world.Map.Tileset.ToLowerInvariant();

            actorInfo = map.Rules.Actors[name];
            footprintPlaceBuildingPreviewInfo = actorInfo.TraitInfo <FootprintPlaceBuildingPreviewInfo>();
            buildingInfo        = actorInfo.TraitInfo <BuildingInfo>();
            centerOffset        = buildingInfo.CenterOffset(world);
            topLeftScreenOffset = -worldRenderer.ScreenPxOffset(centerOffset);

            var buildableInfo      = actorInfo.TraitInfo <BuildableInfo>();
            var mostLikelyProducer = queue.MostLikelyProducer();

            faction = buildableInfo.ForceFaction
                      ?? (mostLikelyProducer.Trait != null ? mostLikelyProducer.Trait.Faction : queue.Actor.Owner.Faction.InternalName);

            if (map.Rules.Sequences.HasSequence("overlay", "build-valid-{0}".F(tileset)))
            {
                buildOk = map.Rules.Sequences.GetSequence("overlay", "build-valid-{0}".F(tileset)).GetSprite(0);
            }
            else
            {
                buildOk = map.Rules.Sequences.GetSequence("overlay", "build-valid").GetSprite(0);
            }
            buildBlocked = map.Rules.Sequences.GetSequence("overlay", "build-invalid").GetSprite(0);
        }