IEnumerable<Order> InnerOrder(World world, int2 xy, MouseInput mi)
        {
            if (mi.Button == MouseButton.Left)
            {
                var topLeft = xy - Footprint.AdjustForBuildingSize( BuildingInfo );
                if (!world.CanPlaceBuilding( Building, BuildingInfo, topLeft, null)
                    || !world.IsCloseEnoughToBase(Producer.Owner, Building, BuildingInfo, topLeft))
                {
                    var eva = world.WorldActor.Info.Traits.Get<EvaAlertsInfo>();
                    Sound.Play(eva.BuildingCannotPlaceAudio);
                    yield break;
                }

                if (Rules.Info[ Building ].Traits.Contains<LineBuildInfo>())
                    yield return new Order("LineBuild", Producer.Owner.PlayerActor, topLeft, Building);
                else
                    yield return new Order("PlaceBuilding", Producer.Owner.PlayerActor, topLeft, Building);
            }
        }
示例#2
0
        public void DrawBuildingGrid( World world, string name, BuildingInfo bi )
        {
            var position = Game.controller.MousePosition.ToInt2();
            var topLeft = position - Footprint.AdjustForBuildingSize( bi );

            // Linebuild for walls.
            // Assumes a 1x1 footprint; weird things will happen for other footprints
            if (Rules.Info[name].Traits.Contains<LineBuildInfo>())
            {
                foreach (var t in LineBuildUtils.GetLineBuildCells(world, topLeft, name, bi))
                    spriteRenderer.DrawSprite(world.IsCloseEnoughToBase(world.LocalPlayer, name, bi, t)
                        ? buildOk : buildBlocked, Game.CellSize * t, "terrain");
            }
            else
            {
                var res = world.WorldActor.traits.Get<ResourceLayer>();
                var isCloseEnough = world.IsCloseEnoughToBase(world.LocalPlayer, name, bi, topLeft);
                foreach (var t in Footprint.Tiles(name, bi, topLeft))
                    spriteRenderer.DrawSprite((isCloseEnough && world.IsCellBuildable(t, bi.WaterBound) && res.GetResource(t) == null)
                        ? buildOk : buildBlocked, Game.CellSize * t, "terrain");
            }

            spriteRenderer.Flush();
        }