コード例 #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
        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);
                    }
                }
            }
        }
コード例 #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;
                                }
                            }
                        }
                    }
                }
            }
        }