コード例 #1
0
        //
        // Methods
        //
        public override float GetPriority(Pawn pawn)
        {
            //Need_Rest rest = pawn.needs.rest;
            Need_Battery battery = pawn.needs.TryGetNeed <Need_Battery> ();

            float result;

            if (battery == null)
            {
                result = 0;
            }
            else
            {
                float             curLevel          = battery.CurLevel;
                TimeAssignmentDef timeAssignmentDef = (pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything;

                if (timeAssignmentDef == TimeAssignmentDefOf.Anything)
                {
                    if ((curLevel < 0.5 && pawn is ArcBaseRobot) &
                        !BaseRobot_Helper.IsInDistance(pawn.Position, (pawn as ArcBaseRobot).rechargeStation.Position, 50))
                    {
                        result = 8;
                    }
                    else
                    {
                        result = (curLevel < 0.3) ? 8 : 0;
                    }
                }
                else
                {
                    if (timeAssignmentDef == TimeAssignmentDefOf.Work)
                    {
                        result = 0;
                    }
                    else
                    {
                        if (timeAssignmentDef == TimeAssignmentDefOf.Joy)
                        {
                            result = (curLevel < 0.3) ? 8 : 0;
                        }
                        else
                        {
                            if (timeAssignmentDef == TimeAssignmentDefOf.Sleep)
                            {
                                result = (curLevel < 0.75) ? 8 : 0;
                            }
                            else
                            {
                                result = 0;
                            }
                        }
                    }
                }
            }
            return(result);
        }
コード例 #2
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);
        }
コード例 #3
0
        public override void Tick()
        {
            base.Tick();
            this.UpdateGraphic();

            if (this.robot == null && this.IsRobotInContainer())
            {
                ArcBaseRobot bot = this.container [0];
                if (bot == null)
                {
                    this.container.Remove(this.container [0]);
                }
                else
                {
                    Need_Battery battery = bot.needs.TryGetNeed <Need_Battery> ();

                    if (this.SpawnRobotAfterRecharge && battery.CurLevel >= 0.99)
                    {
                        this.Button_SpawnBot();
                    }
                    else
                    {
                        if (battery.CurLevel < 1)
                        {
                            //Need_Rest expr_B8 = bot.needs.rest;
                            battery.CurLevel = battery.CurLevel + 4E-05f * this.rechargeEfficiency;
                            if (battery.CurLevel > 1)
                            {
                                battery.CurLevel = 1;
                            }
                            this.TryThrowBatteryMote(bot);
                        }
                    }
                }
            }
            else
            {
                if (!this.robotIsDestroyed)
                {
                    if (!(this.robot == null && (!this.robotSpawnedOnce || !this.IsRobotInContainer())))
                    {
                        if (this.robotSpawnedOnce && !this.IsRobotInContainer() && (this.robot == null || this.robot.Destroyed || this.robot.Dead))
                        {
                            if ((this.robot.Destroyed || this.robot.Dead) && this.robot.Corpse != null)
                            {
                                this.robot.Corpse.Destroy(0);
                            }
                            this.robotIsDestroyed = true;
                        }
                        else
                        {
                            this.checkDistanceAndEnergyTicks--;
                            bool flag10 = this.checkDistanceAndEnergyTicks > 0;
                            if (!flag10)
                            {
                                this.checkDistanceAndEnergyTicks = 192;
                                Need_Battery battery = this.robot.needs.TryGetNeed <Need_Battery> ();
                                if (battery.CurLevel < 0.4 && !this.robot.Drafted && !BaseRobot_Helper.IsInDistance(base.Position, this.robot.Position, 50))
                                {
                                    this.Button_CallBotForShutdown();
                                    this.SpawnRobotAfterRecharge = true;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
 public static Building_BaseRobotRechargeStation FindRechargeStationFor(ArcBaseRobot p)
 {
     return(BaseRobot_Helper.FindRechargeStationFor(p, p, false, false, false));
 }