public void Execute(HatcheryBuildingStep hatcheryStep) { var drone = MyUnits.TrackedUnits.FirstOrDefault(kvp => kvp.Value.StartsWith("MoveDroneTo")).Key ?? GetFreeDrone(); var buildSite = GetBuildRegion(hatcheryStep); Construct(drone, ToBuildLocation(buildSite), hatcheryStep); }
private MapRegion GetBuildRegion(HatcheryBuildingStep step) { switch (step.HatcheryType) { case HatcheryType.NaturalExp: return(Natural); case HatcheryType.ThirdExp: return(Third); default: throw new ArgumentOutOfRangeException(); } }
private void Construct(Unit builder, TilePosition buildSite, HatcheryBuildingStep constructStep) { if (!Game.IsExplored(buildSite)) { builder.Move(buildSite.ToPixelTile(), false); return; } builder.Build(constructStep.Target, buildSite); _constructionStarted.Where(x => x == constructStep.Target).Take(1).Subscribe(x => { constructStep.Complete(); // TODO: problem, if we start constructing another instance of the same building before, we complete the step prematurely _gameInfo.MyBases.Add(new MyBase(GetBuildRegion(constructStep), constructStep.HatcheryType.ToBaseType())); }); }