private void Button_CallBotForShutdown(bool onlyRecharging) { SpawnRobotAfterRecharge = onlyRecharging; if (robot == null || robotIsDestroyed) { return; } if (!robot.Spawned) // || robot.HostFaction != null || robot.Faction != Faction.OfPlayer) { return; } // preparation: stop all other jobs if (robot.jobs == null) { Log.Error("Robot has no job driver!"); return; } ThinkResult jobPackage; if (onlyRecharging) { // Go Recharging X2_JobGiver_RechargeEnergy getRecharge = new X2_JobGiver_RechargeEnergy(); jobPackage = getRecharge.TryIssueJobPackage(robot, new JobIssueParams()); } else { // Go Despawning X2_JobGiver_Return2BaseDespawn getRest = new X2_JobGiver_Return2BaseDespawn(); jobPackage = getRest.TryIssueJobPackage(robot, new JobIssueParams()); } // Do nothing more, if the jobPackage or job is null, or if the current job is already the target job if (jobPackage == null || jobPackage.Job == null || (robot.CurJob != null && robot.CurJob.def == jobPackage.Job.def)) { return; } robot.jobs.StopAll(); // Do Job with JobGiver -> Force owner to recharge robot.jobs.StartJob(jobPackage.Job); }
private void Button_CallBotForShutdown() { SpawnRobotAfterRecharge = false; if (robot == null || robotIsDestroyed) { return; } if (!robot.Spawned) // || robot.HostFaction != null || robot.Faction != Faction.OfPlayer) { return; } // preparation: stop all other jobs if (robot.jobs == null) { Log.Error("Robot has no job driver!"); } X2_JobGiver_RechargeEnergy getRest = new X2_JobGiver_RechargeEnergy(); ThinkResult jobPackage = getRest.TryIssueJobPackage(robot, new JobIssueParams()); // Do nothing more, if the jobPackage or job is null, or if the current job is already the target job if (jobPackage == null || jobPackage.Job == null || robot.CurJob.def == jobPackage.Job.def) { return; } robot.jobs.StopAll(); //if (robot.drafter == null) // robot.drafter = new Pawn_DraftController(robot); //robot.drafter.Drafted = false; // Do Job with JobGiver -> Force owner to recharge robot.jobs.StartJob(jobPackage.Job); }