public int GetAllocatedCount(PoolId poolId) { ObjectPool pool; if (objectPoolInstances.TryGetValue(poolId, out pool)) { return(pool.GetAllocatedCount()); } else { Debug.LogError("Pool " + poolId.ToString() + " has not been configured or initialised"); return(0); } }
/// <summary> /// Return a JSON representation of this object. /// </summary> public JObject ToJSON() => JSONObject.Create( new JProperty("poolId", PoolId.ToString()), Address != null ? new JProperty("address", Address.ToJSON()) : null, GeoCoordinates.HasValue ? new JProperty("geoCoordinates", GeoCoordinates.Value.ToJSON()) : null, ChargingStations.SafeAny() ? new JProperty("chargingStations", JSONArray.Create(ChargingStations.Select(chargingStation => chargingStation.ToJSON()))) : null );
public GameObject Allocate(PoolId poolId, Vector3 position, Quaternion rotation) { ObjectPool pool; if (objectPoolInstances.TryGetValue(poolId, out pool)) { var go = pool.Allocate(position, rotation); var poolTypeComponent = go.GetComponent <PoolAllocation>(); if (!poolTypeComponent) { poolTypeComponent = go.AddComponent <PoolAllocation>(); poolTypeComponent.poolId = poolId; } return(go); } else { Debug.LogError("Pool " + poolId.ToString() + " has not been configured or initialised"); return(null); } }