Example #1
0
 public MineActionReport(ILivingObject living, IntVector3 location, Direction direction, MineActionType mineActionType)
     : base(living)
 {
     this.Location       = location;
     this.Direction      = direction;
     this.MineActionType = mineActionType;
 }
Example #2
0
 public MineAssignment(IJobObserver parent, IEnvironmentObject environment, IntVector3 location, MineActionType mineActionType)
     : base(parent)
 {
     m_environment    = environment;
     m_location       = location;
     m_mineActionType = mineActionType;
 }
Example #3
0
 public MineAssignment(IJobObserver parent, IEnvironmentObject environment, IntVector3 location, MineActionType mineActionType)
     : base(parent)
 {
     m_environment = environment;
     m_location = location;
     m_mineActionType = mineActionType;
 }
        static DirectionSet GetPossiblePositioning(IEnvironmentObject env, IntPoint3 p, MineActionType mineActionType)
        {
            DirectionSet pos;

            var down = p + Direction.Down;

            switch (mineActionType)
            {
                case MineActionType.Mine:
                    pos = DirectionSet.Planar;

                    if (EnvironmentHelpers.CanMoveFrom(env, down, Direction.Up))
                        pos |= DirectionSet.Down;

                    break;

                case MineActionType.Stairs:
                    pos = DirectionSet.Planar | DirectionSet.Up;

                    if (EnvironmentHelpers.CanMoveFrom(env, down, Direction.Up))
                        pos |= DirectionSet.Down;

                    break;

                case MineActionType.Channel:
                    pos = DirectionSet.Planar;
                    break;

                default:
                    throw new Exception();
            }

            return pos;
        }
Example #5
0
        IAssignment IJobSource.FindAssignment(ILivingObject living)
        {
            var tick = this.Environment.World.TickNumber;

            var designations = m_map
                               .Where(kvp => kvp.Value.Job == null && kvp.Value.ReachableSimple && kvp.Value.NextReacahbleCheck <= tick)
                               .OrderBy(kvp => (kvp.Key - living.Location).Length);

            foreach (var d in designations)
            {
                var p  = d.Key;
                var dt = d.Value;

                var ds = GetDesignationPositioning(p, dt.Type);

                // XXX we should pass the found path to the job, to avoid re-pathing
                bool canreach = AStar.CanReach(this.Environment, living.Location, p, ds);
                if (!canreach)
                {
                    dt.NextReacahbleCheck = tick + 10;
                    continue;
                }

                IAssignment job;

                switch (dt.Type)
                {
                case DesignationType.Mine:
                case DesignationType.CreateStairs:
                    MineActionType mat = DesignationTypeToMineActionType(dt.Type);

                    job = new Jobs.AssignmentGroups.MoveMineAssignment(this, this.Environment, p, mat);

                    break;

                case DesignationType.FellTree:

                    job = new Jobs.AssignmentGroups.MoveFellTreeAssignment(this, this.Environment, p);
                    break;

                default:
                    throw new Exception();
                }

                this.Environment.World.Jobs.Add(job);
                dt.Job = job;

                return(job);
            }

            return(null);
        }
        /// <summary>
        /// Get possible positioning to perform mining to given location
        /// </summary>
        public static DirectionSet GetPossibleMiningPositioning(this IEnvironmentObject env, IntVector3 p,
                                                                MineActionType mineActionType)
        {
            DirectionSet ds;

            switch (mineActionType)
            {
            case MineActionType.Mine:
                ds = DirectionSet.Planar;

                if (env.GetTileData(p.Up).IsClear)
                {
                    ds |= DirectionSet.DownNorth |
                          DirectionSet.DownEast |
                          DirectionSet.DownSouth |
                          DirectionSet.DownWest;
                }

                break;

            case MineActionType.Stairs:
                ds = DirectionSet.Planar | DirectionSet.Down;

                if (env.CanMoveFrom(p.Down, Direction.Up))
                {
                    ds |= DirectionSet.Up;
                }

                break;

            default:
                throw new Exception();
            }

            return(ds);
        }
Example #7
0
 public MineActionReport(ILivingObject living, IntPoint3 location, Direction direction, MineActionType mineActionType)
     : base(living)
 {
     this.Location = location;
     this.Direction = direction;
     this.MineActionType = mineActionType;
 }
Example #8
0
 public MineAction(Direction dir, MineActionType mineActionType)
 {
     this.Direction      = dir;
     this.MineActionType = mineActionType;
 }
        /// <summary>
        /// Get possible positioning to perform mining to given location
        /// </summary>
        public static DirectionSet GetPossibleMiningPositioning(this IEnvironmentObject env, IntVector3 p,
			MineActionType mineActionType)
        {
            DirectionSet ds;

            switch (mineActionType)
            {
                case MineActionType.Mine:
                    ds = DirectionSet.Planar;

                    if (env.GetTileData(p.Up).IsClear)
                    {
                        ds |= DirectionSet.DownNorth |
                            DirectionSet.DownEast |
                            DirectionSet.DownSouth |
                            DirectionSet.DownWest;
                    }

                    break;

                case MineActionType.Stairs:
                    ds = DirectionSet.Planar | DirectionSet.Down;

                    if (env.CanMoveFrom(p.Down, Direction.Up))
                        ds |= DirectionSet.Up;

                    break;

                default:
                    throw new Exception();
            }

            return ds;
        }
Example #10
0
 public MineAction(Direction dir, MineActionType mineActionType)
 {
     this.Direction = dir;
     this.MineActionType = mineActionType;
 }
Example #11
0
 public MoveMineAssignment(IJobObserver parent, IEnvironmentObject environment, IntVector3 location, MineActionType mineActionType)
     : base(parent, environment, location)
 {
     m_mineActionType = mineActionType;
 }
 public MoveMineAssignment(IJobObserver parent, IEnvironmentObject environment, IntVector3 location, MineActionType mineActionType)
     : base(parent, environment, location)
 {
     m_mineActionType = mineActionType;
 }