public StepResult Perform(BuildListState state) { if (!Condition.Invoke()) { return(new NextItem()); } if (UnitTypes.LookUp[UnitType].TechRequirement != 0 && Tyr.Bot.UnitManager.Completed(UnitTypes.LookUp[UnitType].TechRequirement) == 0 && UnitTypes.LookUp[UnitType].TechRequirement != UnitTypes.HATCHERY) { Tyr.Bot.DrawText("Skipping list. Morph tech for " + UnitTypes.LookUp[UnitType].Name + " not available: " + UnitTypes.LookUp[UnitType].TechRequirement); return(new NextList()); } if (Build.FoodLeft() < UnitTypes.LookUp[UnitType].FoodRequired) { return(new NextItem()); } state.AddDesired(UnitType, Number); if (state.Desired[UnitType] > Tyr.Bot.UnitManager.Count(UnitType)) { if (!Morph(state, state.Desired[UnitType] - Tyr.Bot.UnitManager.Count(UnitType))) { return(new WaitForResources()); } } return(new NextItem()); }
public StepResult Perform(BuildListState state) { if (!Condition.Invoke()) { return(new NextItem()); } if (UnitTypes.LookUp[UnitType].TechRequirement != 0 && Tyr.Bot.UnitManager.Completed(UnitTypes.LookUp[UnitType].TechRequirement) == 0 && UnitTypes.LookUp[UnitType].TechRequirement != UnitTypes.HATCHERY) { Tyr.Bot.DrawText("Skipping list. Build tech for " + UnitTypes.LookUp[UnitType].Name + " not available: " + UnitTypes.LookUp[UnitType].TechRequirement); return(new NextList()); } state.AddDesired(UnitType, Number); if (DesiredPos != null) { bool built = false; foreach (BuildRequest request in ConstructionTask.Task.BuildRequests) { if (request.Type == UnitType && request.Exact == Exact && request.AroundLocation == DesiredPos) { built = true; break; } } foreach (BuildRequest request in ConstructionTask.Task.UnassignedRequests) { if (request.Type == UnitType && request.Exact == Exact && request.AroundLocation == DesiredPos) { built = true; break; } } if (!built) { foreach (Agent agent in Tyr.Bot.UnitManager.Agents.Values) { if (CheckTypeMatches(UnitType, agent.Unit.UnitType) && agent.Exact == Exact && agent.AroundLocation == DesiredPos) { built = true; break; } } } if (!built) { if (!Construct(state, 1)) { return(new WaitForResources()); } } } if (DesiredBase == null && state.Desired[UnitType] > Tyr.Bot.UnitManager.Count(UnitType) && !Exact) { if (!Construct(state, state.Desired[UnitType] - Tyr.Bot.UnitManager.Count(UnitType))) { return(new WaitForResources()); } } if (DesiredBase != null) { BuildingAtBase key = new BuildingAtBase(UnitType, DesiredBase); state.AddDesiredPerBase(key, Number); if (state.DesiredPerBase[key] > Build.Count(DesiredBase, UnitType) && !Exact) { if (!Construct(state, state.DesiredPerBase[key] - Build.Count(DesiredBase, UnitType))) { return(new WaitForResources()); } } } return(new NextItem()); }