private void ApplyInput(GameState s, float dt, SpawnBuildingEvent e) { RTSTeam team = s.teams[e.Team]; // Check If We Can Add A Building There Vector2 wp = new Vector2(e.GridPosition.X + 0.5f, e.GridPosition.Y + 0.5f) * s.CGrid.cellSize; if (!s.CGrid.CanAddBuilding(wp, team.Race.Buildings[e.Type].GridSize)) { return; } RTSBuilding building = team.AddBuilding(e.Type, wp); if (building == null) { return; } // Check For Instant Building if (e.InstantBuild) { building.BuildAmountLeft = 0; } else { building.OnBuildingFinished += (b) => { s.SendAlert(building.Data.FriendlyName + " Is Built", AlertLevel.Passive); }; } // Check If A Building Was Possible if (building == null) { return; } s.EntityHashSet.Add(building.UUID, building); // Set Default Height building.Height = s.CGrid.HeightAt(building.GridPosition); building.CollisionGeometry.Height = building.Height; s.CGrid.Add(building); // Add Building Decision Task AddTask(s, building, e.Team, e.Type); }
public static void Trigger_SpawnBuildingEvent(GameObject ObjectToSpawn) { SpawnBuildingEvent.Invoke(ObjectToSpawn); }