Exemplo n.º 1
0
        public static bool CreateSafeMineJob(Map map, Vector3 position, Character character = null)
        {
            // Is this a valid mining location?
            MapCell mapCell = map.GetCell(position);
            if (!mapCell.HasNaturalWall())
                return false;

            // Make sure surrounding cells are safe
            if (!IsSafeMiningLocation(map, position, character))
                return false;

            GnomanEmpire.Instance.Fortress.JobBoard.AddJob(new MineJob(position));
            return true;
        }
Exemplo n.º 2
0
 private static bool IsSafeMiningLocation(Map map, Vector3 position, Character character = null)
 {
     return GetSurroundingPositions(map, position)
         .All(surroundingPosition =>
             map.GetCell(surroundingPosition).HasNaturalWall()
             || (character != null && character.CanReach(surroundingPosition, false)));
 }
Exemplo n.º 3
0
        private static void RemoveTorch(Vector3 selectionStartPosition, Map map, int startY, int startX, int x, int y)
        {
            int deltaX = Math.Abs(x - startX);
            int deltaY = Math.Abs(y - startY);

            if (deltaX == 0 && deltaY == 0)
            {
                return;
            }

            int stepsX = deltaX / (MiningImprovements.SafeTorchDistance);
            int stepsY = deltaY / (MiningImprovements.SafeTorchDistance);

            bool evenX = stepsX % 2 == 0;
            bool evenY = stepsY % 2 == 0;

            if (evenX != evenY)
            {
                Vector3 torchRemovalPosition = new Vector3(x, y, selectionStartPosition.Z);
                MapCell mapCell = map.GetCell(torchRemovalPosition);
                if (!(mapCell.EmbeddedWall is Torch))
                {
                    return;
                }

                // TODO: Ensure all four cardinal directions have complete visibility to another block that is SafeTorchDistance away

                GnomanEmpire.Instance.Fortress.JobBoard.AddJob(new DeconstructJob(torchRemovalPosition));
            }
        }
Exemplo n.º 4
0
        private static void CheckBuildTorch(Vector3 jobPosition, Vector3 torchPosition, Map map)
        {
            MapCell cell = map.GetCell(torchPosition);
            if (!(cell.EmbeddedWall is Torch))
                return;

            BuildConstructionJobData data = new BuildConstructionJobData(ConstructionID.Torch);
            BuildConstructionJob buildConstructionJob = new BuildConstructionJob(jobPosition, data);
            buildConstructionJob.RequiredComponents.Add(new JobComponent(ItemID.Torch, (int)Material.Count));
            GnomanEmpire.Instance.Fortress.JobBoard.AddJob(buildConstructionJob);
        }