//
        // Static Methods
        //
        public static Building_BaseRobotRechargeStation TryFindRechargeStation(ArcBaseRobot bot, Map map)
        {
            if (map == null && bot.rechargeStation != null)
            {
                map = bot.rechargeStation.Map;
            }
            if (map == null)
            {
                map = bot.Map;
            }

            Building_BaseRobotRechargeStation result;

            if (map == null)
            {
                result = null;
            }
            else
            {
                IEnumerable <Building_BaseRobotRechargeStation> enumerable = map.listerBuildings.AllBuildingsColonistOfClass <Building_BaseRobotRechargeStation> ();
                if (enumerable == null)
                {
                    result = null;
                }
                else
                {
                    Building_BaseRobotRechargeStation Building_BaseRobotRechargeStation = (from t in enumerable
                                                                                           where t.robot == bot
                                                                                           select t).FirstOrDefault <Building_BaseRobotRechargeStation> ();
                    result = Building_BaseRobotRechargeStation;
                }
            }
            return(result);
        }
        public static Building_BaseRobotRechargeStation FindRechargeStationFor(ArcBaseRobot sleeper, ArcBaseRobot traveler, bool sleeperWillBePrisoner, bool checkSocialProperness, bool medicalBedNeeded = false)
        {
            Predicate <Thing> predicate = delegate(Thing t) {
                bool flag3 = !ReservationUtility.CanReserveAndReach(traveler, t, PathEndMode.OnCell, Danger.Some, 1, -1, null, false);
                bool result2;
                if (flag3)
                {
                    result2 = false;
                }
                else
                {
                    Building_BaseRobotRechargeStation rechargeStation = t as Building_BaseRobotRechargeStation;
                    bool flag4 = rechargeStation == null;
                    if (flag4)
                    {
                        result2 = false;
                    }
                    else
                    {
                        bool flag5 = rechargeStation.robot != null && rechargeStation.robot != sleeper;
                        if (flag5)
                        {
                            result2 = false;
                        }
                        else
                        {
                            bool flag6 = ForbidUtility.IsForbidden(rechargeStation, traveler);
                            if (flag6)
                            {
                                result2 = false;
                            }
                            else
                            {
                                bool flag7 = FireUtility.IsBurning(rechargeStation);
                                result2 = !flag7;
                            }
                        }
                    }
                }
                return(result2);
            };
            bool flag = sleeper.rechargeStation != null && predicate(sleeper.rechargeStation);
            Building_BaseRobotRechargeStation result;

            if (flag)
            {
                Building_BaseRobotRechargeStation rechargeStation = sleeper.rechargeStation;
                bool flag2 = rechargeStation != null;
                if (flag2)
                {
                    result = rechargeStation;
                    return(result);
                }
            }
            result = null;
            return(result);
        }
Beispiel #3
0
        private void Button_SpawnAllAvailableBots()
        {
            List <Building_BaseRobotRechargeStation> list = base.Map.listerThings.AllThings.OfType <Building_BaseRobotRechargeStation> ().ToList <Building_BaseRobotRechargeStation> ();

            for (int i = list.Count; i > 0; i--)
            {
                Building_BaseRobotRechargeStation x2_Building_AIRobotRechargeStation = list [i - 1];
                x2_Building_AIRobotRechargeStation.Notify_SpawnBot();
            }
        }
Beispiel #4
0
        private void Button_CallAllBotsForShutdown()
        {
            List <Building_BaseRobotRechargeStation> list = base.Map.listerThings.AllThings.OfType <Building_BaseRobotRechargeStation> ().ToList <Building_BaseRobotRechargeStation> ();

            for (int i = list.Count; i > 0; i--)
            {
                Building_BaseRobotRechargeStation Building_BaseRobotRechargeStation = list [i - 1];
                Building_BaseRobotRechargeStation.Notify_CallBotForShutdown();
            }
        }
        public override void Tick()
        {
            base.Tick();

            // Not sure why this is here - robots don't need food

            /*if (this.needs.food != null &&
             *      this.needs.food.CurLevel < 1) {
             *      this.needs.food.CurLevel = 1;
             * }/**/

            // Gain experience if learning is allowed
            if (this.def2 == null ||
                !this.def2.allowLearning)
            {
                foreach (SkillRecord current in this.skills.skills)
                {
                    if (current.xpSinceLastLevel > 1)
                    {
                        current.xpSinceLastLevel = 1;
                        current.xpSinceMidnight  = 1;
                    }
                }
            }
            Need_Battery batt = this.needs.TryGetNeed <Need_Battery> ();

            if (base.Spawned &&
                (base.Dead || base.Downed || batt.CurLevel <= 0.02))
            {
                this.Destroy();
            }
            else
            {
                if (base.Spawned)
                {
                    if (this.rechargeStation == null)
                    {
                        this.rechargeStation = ArcBaseRobot.TryFindRechargeStation(this, base.Map);
                    }
                }
            }
        }
        public override void Destroy(DestroyMode mode = 0)
        {
            IntVec3 intVec = (base.Position != IntVec3.Invalid) ? base.Position : base.PositionHeld;
            Map     map    = (base.Map != null) ? base.Map : base.MapHeld;
            Building_BaseRobotRechargeStation rechargestation = this.rechargeStation;
            ThingDef thingDef = null;

            if (this != null && this.def2 != null && this.def2.destroyedDef != null)
            {
                thingDef = this.def2.destroyedDef;
            }
            base.Destroy(0);

            if (thingDef != null)
            {
                BaseRobot_disabled BaseRobot_disabled = (BaseRobot_disabled)GenSpawn.Spawn(thingDef, intVec, map);
                BaseRobot_disabled.stackCount      = 1;
                BaseRobot_disabled.rechargestation = rechargestation;
            }
        }
Beispiel #7
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            ArcBaseRobot bot = pawn as ArcBaseRobot;
            Building_BaseRobotRechargeStation rechargeStation = BaseRobot_Helper.FindRechargeStationFor(bot);
            Job result;

            if (rechargeStation == null)
            {
                result = null;
            }
            else
            {
                if (bot.rechargeStation != rechargeStation)
                {
                    result = null;
                }
                else
                {
                    Job job = new Job(DefDatabase <JobDef> .GetNamed("AIRobot_GoRecharge", true), rechargeStation);
                    result = job;
                }
            }
            return(result);
        }