public static TacticalTaskInstance CreateInstance(string type) { var instance = new TacticalTaskInstance(); instance.prototype = prototypes[type]; return(instance); }
public static TacticalTaskInstance CreateInstance(TacticalTaskPrototype prototype) { var instance = new TacticalTaskInstance(); instance.prototype = prototype; return(instance); }
private static TacticalTaskInstance MostValuableTask(AIStateController controller) { var currentTask = CurrentTask(controller); TacticalTaskInstance nextBestTask = currentTask; float commitmentBias = 0.25f; // re-evaluate currentTask currentTask.score = currentTask.prototype.Evaluate(currentTask.config); if ((controller.characterRole & CharacterRole.Hunter) != CharacterRole.NA) { if (controller.characterRole == CharacterRole.Roamer) { var flank = GetFlankInstanceWithBestTarget(controller); var followAttack = GetFollowAndAttackInstanceWithBestTarget(controller); nextBestTask = flank.score > followAttack.score ? flank : followAttack; } else if (controller.characterRole == CharacterRole.Defender) { var guard = GetGuardInstanceWithBestTarget(controller); var followAttack = GetFollowAndAttackInstanceWithBestTarget(controller); nextBestTask = guard.score > followAttack.score ? guard : followAttack; } } else if ((controller.characterRole & CharacterRole.Survivor) != CharacterRole.NA) { if (controller.characterRole == CharacterRole.Defuser) { var defuse = GetDefuseInstanceWithBestTarget(controller); var flee = GetFleeInstance(controller); nextBestTask = defuse.score > flee.score ? defuse : flee; } else if (controller.characterRole == CharacterRole.Support) { var fakeDefuse = GetFakeDefuseInstanceWithBestTarget(controller); var flee = GetFleeInstance(controller); var trap = GetDeployAmbushInstanceWithBestTarget(controller); nextBestTask = fakeDefuse; if (flee.score > nextBestTask.score) { nextBestTask = flee; } if (trap.score > nextBestTask.score) { nextBestTask = trap; } } } if (currentTask.done) { return(nextBestTask); // should be wander } else if (currentTask.score + commitmentBias < nextBestTask.score) { return(nextBestTask); } return(currentTask); }