Exemplo n.º 1
0
        protected override Job TryGiveTerminalJob(Pawn pawn)
        {
            if (!(pawn is ICharge))
            {
                return(null);
            }
            ICharge chargee = (ICharge)pawn;
            Droid   droid   = (Droid)pawn;

            if (droid != null && !droid.Active)
            {
                return(null);
            }

            float chargeThreshold;
            float distance;

            switch (stage)
            {
            case 1:
            {
                chargeThreshold = chargee.PowerSafeThreshold;
                distance        = 20f;
                break;
            }

            case 2:
            {
                chargeThreshold = chargee.PowerLowThreshold;
                distance        = 50f;
                break;
            }

            case 3:
            {
                chargeThreshold = chargee.PowerCriticalThreshold;
                distance        = 9999f;
                break;
            }

            default:
            {
                chargeThreshold = chargee.PowerLowThreshold;
                distance        = 50f;
                break;
            }
            }
            if (chargee.TotalCharge <= chargee.MaxEnergy * chargeThreshold)
            {
                Thing target = ListerDroids.ClosestChargerFor(chargee, distance);
                if (target != null)
                {
                    return(new Job(DefDatabase <JobDef> .GetNamed("MD2ChargeDroid"), new TargetInfo(target)));
                }
            }
            return(null);
        }
Exemplo n.º 2
0
 public void CheckPowerRemaining()
 {
     if (!parent.playerController.Drafted)
     {
         if (parent.TotalCharge <= parent.meta.PowerCriticalThreshold && parent.CurJob.def != ChargeJob)
         {
             Thing target = ListerDroids.ClosestChargerFor(parent);
             if (target != null)
             {
                 parent.jobs.StartJob(new Job(ChargeJob, new TargetInfo(target)), JobCondition.InterruptForced);
             }
         }
     }
     if (parent.TotalCharge < 1f)
     {
         Disable("DroidOutOfPower".Translate(), "DeactivatedNoPower".Translate(), true);
     }
 }