public static T Instantiate <T>(int x, int y, SpawnsManager.SpawnData data = null) where T : GameObject, new() { T g = new T(); GameObjectsManager.AddObject(g); g.SetPosition(x, y); if (data != null) { g.SetData(data); } g.Init(); return(g); }
private void Instance_OnUpdate() { HashSet <int> itemsToRemove = new HashSet <int>(); foreach (var item in objectsToRespawn) { if (item.Value.respawnTime < Time.time) { GameObjectsManager.AddObject(item.Value.id, item.Value.go); if (MapsManager.GetMap(item.Value.go.mapId, out Map m)) { m.AddPlayer(item.Value.id); } item.Value.Respawn(); itemsToRemove.Add(item.Value.id); } } foreach (var item in itemsToRemove) { objectsToRespawn.Remove(item); } }