Esempio n. 1
0
    public async Async.Task Post_DeletesExistingNodeForMachineId()
    {
        await Context.InsertAll(
            new Node(PoolName.Parse("another-pool"), _machineId, _poolId, "1.0.0"),
            new Pool(_poolName, _poolId, Os.Linux, false, Architecture.x86_64, PoolState.Init, null));

        var auth = new TestEndpointAuthorization(RequestType.Agent, Logger, Context);
        var func = new AgentRegistration(Logger, auth, Context);

        var req = TestHttpRequestData.Empty("POST");

        req.SetUrlParameter("machine_id", _machineId);
        req.SetUrlParameter("pool_name", _poolName);
        req.SetUrlParameter("scaleset_id", _scalesetId);

        var result = await func.Run(req);

        Assert.Equal(HttpStatusCode.OK, result.StatusCode);

        // there should only be one node, the old one with the same machineID was deleted
        var nodes = await Context.NodeOperations.SearchAll().ToListAsync();

        var node = Assert.Single(nodes);

        Assert.Equal(_poolName, node.PoolName);
    }
Esempio n. 2
0
        private void Awake()
        {
            if (IsDontDestroyOnLoad)
            {
                Object.DontDestroyOnLoad(gameObject);
            }

            Group = transform;

            if (string.IsNullOrEmpty(PoolName))
            {
                PoolName = Group.name.Replace("Pool", "");
                PoolName = PoolName.Replace("(Clone)", "");
            }

            if (LogMessages)
            {
                Debug.Log(string.Format("SpawnPool {0}: Initializing..", PoolName));
            }

            for (int i = 0; i < PerPrefabPoolOptions.Count; ++i)
            {
                if (PerPrefabPoolOptions[i].Prefab == null)
                {
                    continue;
                }

                PerPrefabPoolOptions[i].InstanceConstructor();
                CreatePrefabPool(PerPrefabPoolOptions[i]);
            }

            SimplePoolManager.Instance().AddSpawnPool(this);
        }
Esempio n. 3
0
    /// <summary>
    /// This method will create/instance a prefab at a specific position with a specific rotation and a specific scale and assign a material
    /// </summary>
    public static GameObject prefab(PoolName name, Vector3 position, Vector3 rotation, Vector3 scale, string mat)
    {
        // load the prefab from Resources
//        Object pf = Resources.Load("Prefabs/" + name);
//		if (pf!=null)
//		{
        // the prefab was found so create an instance for it.
        var inst = objectPool.GetOrInstantiateDice(name);

//			GameObject inst = (GameObject) GameObject.Instantiate( pf , Vector3.zero, Quaternion.identity);
        if (inst != null)
        {
            // the instance could be created so set material, position, rotation and scale.
//            if (mat != "") inst.GetComponent<Renderer>().material = material(mat);
            inst.transform.position = position;
            inst.transform.Rotate(rotation);
            inst.transform.localScale = scale;
            // return the created instance (GameObject)
            return(inst);
        }

        return(null);

//		}
//		else
//			Debug.Log("Prefab "+name+" not found!");
//		return null;
    }
        public async Task <HttpResponseData> GetPool([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "testhooks/poolOperations/pool")] HttpRequestData req)
        {
            _log.Info("get pool");

            var query   = UriExtension.GetQueryComponents(req.Url);
            var poolRes = await _poolOps.GetByName(PoolName.Parse(query["name"]));

            if (poolRes.IsOk)
            {
                var resp = req.CreateResponse(HttpStatusCode.OK);
                var data = poolRes.OkV;
                var msg  = JsonSerializer.Serialize(data, EntityConverter.GetJsonSerializerOptions());
                await resp.WriteStringAsync(msg);

                return(resp);
            }
            else
            {
                var resp = req.CreateResponse(HttpStatusCode.BadRequest);
                var msg  = JsonSerializer.Serialize(poolRes.ErrorV, EntityConverter.GetJsonSerializerOptions());
                await resp.WriteStringAsync(msg);

                return(resp);
            }
        }
Esempio n. 5
0
    public GameObject GetOrInstantiateDice(PoolName poolName, Vector3 position, Quaternion rotation)
    {
        var poolQueue = PoolDictionary[poolName];

        if (poolQueue.Count > 0)
        {
            var dice = PoolDictionary[poolName].Dequeue();
            dice.transform.position = position;
            dice.transform.rotation = rotation;
            dice.SetActive(true);

            dice.GetComponent <DiceRepooler>().isInPool = false;

            return(dice);
        }

        var pool = poolInfos[poolName];

        if (pool == null)
        {
            return(null);
        }

        var obj = Instantiate(pool.prefab, position, rotation);

        PoolDictionary[pool.poolName].Enqueue(obj);

        return(obj);
    }
Esempio n. 6
0
        /// <summary>
        /// Get a coin price in thai baht per day if we mining it.
        /// </summary>
        /// <param name="coinSymbol"></param>
        /// <param name="poolName"></param>
        /// <param name="exchangeName"></param>
        /// <returns></returns>
        public double GetTotalFiatMoneyMiningPerday(string coinSymbol, PoolName poolName, ExchangeName exchangeName, FiatCurrency fiat)
        {
            double totalBtcPerDay = GetTotalBtcMiningPerday(coinSymbol, poolName, exchangeName);
            double fiatPerBTC     = (fiat == FiatCurrency.THB) ? _thaiBahtPerBTC : _usdPerBTC;

            return(totalBtcPerDay * fiatPerBTC);
        }
Esempio n. 7
0
    static IEnumerable <Task> BuildTasks(int size)
    {
        return(Enumerable.Range(0, size).Select(i =>
                                                new Task(
                                                    Guid.Empty,
                                                    Guid.NewGuid(),
                                                    TaskState.Init,
                                                    Os.Linux,
                                                    new TaskConfig(
                                                        Guid.Empty,
                                                        null,
                                                        new TaskDetails(
                                                            Type: TaskType.LibfuzzerFuzz,
                                                            Duration: 1,
                                                            TargetExe: "fuzz.exe",
                                                            TargetEnv: new Dictionary <string, string>(),
                                                            TargetOptions: new List <string>()),
                                                        Pool: new TaskPool(1, PoolName.Parse("pool")),
                                                        Containers: new List <TaskContainers> {
            new TaskContainers(ContainerType.Setup, new Container("setup"))
        },
                                                        Colocate: true

                                                        ),
                                                    null,
                                                    null,
                                                    null,
                                                    null,
                                                    null)

                                                ));
    }
Esempio n. 8
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (PoolName != null)
         {
             hashCode = hashCode * 59 + PoolName.GetHashCode();
         }
         if (AllowedPoolNames != null)
         {
             hashCode = hashCode * 59 + AllowedPoolNames.GetHashCode();
         }
         if (SchedulerUseleaderforsingle != null)
         {
             hashCode = hashCode * 59 + SchedulerUseleaderforsingle.GetHashCode();
         }
         if (MetricsFilters != null)
         {
             hashCode = hashCode * 59 + MetricsFilters.GetHashCode();
         }
         if (SlowThresholdMillis != null)
         {
             hashCode = hashCode * 59 + SlowThresholdMillis.GetHashCode();
         }
         return(hashCode);
     }
 }
        public async Task <HttpResponseData> CreateNode([HttpTrigger(AuthorizationLevel.Anonymous, "put", Route = "testhooks/nodeOperations/node")] HttpRequestData req)
        {
            _log.Info("create node");

            var query = UriExtension.GetQueryComponents(req.Url);

            Guid poolId    = Guid.Parse(query["poolId"]);
            var  poolName  = PoolName.Parse(query["poolName"]);
            Guid machineId = Guid.Parse(query["machineId"]);

            Guid?scaleSetId = default;

            if (query.ContainsKey("scaleSetId"))
            {
                scaleSetId = Guid.Parse(query["scaleSetId"]);
            }

            string version = query["version"];

            bool isNew = UriExtension.GetBool("isNew", query, false);

            var node = await _nodeOps.Create(poolId, poolName, machineId, scaleSetId, version, isNew);

            var resp = req.CreateResponse(HttpStatusCode.OK);
            await resp.WriteAsJsonAsync(JsonSerializer.Serialize(node, EntityConverter.GetJsonSerializerOptions()));

            return(resp);
        }
Esempio n. 10
0
        public async Task <HttpResponseData> SearchStates([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "testhooks/nodeOperations/searchStates")] HttpRequestData req)
        {
            _log.Info("search states");

            var  query      = UriExtension.GetQueryComponents(req.Url);
            Guid?poolId     = UriExtension.GetGuid("poolId", query);
            Guid?scaleSetId = UriExtension.GetGuid("scaleSetId", query);

            List <NodeState>?states = default;

            if (query.ContainsKey("states"))
            {
                states = query["states"].Split('-').Select(s => Enum.Parse <NodeState>(s)).ToList();
            }
            string?poolNameString = UriExtension.GetString("poolName", query);

            PoolName?poolName = poolNameString is null ? null : PoolName.Parse(poolNameString);

            var excludeUpdateScheduled = UriExtension.GetBool("excludeUpdateScheduled", query, false);
            int?numResults             = UriExtension.GetInt("numResults", query);
            var r    = _nodeOps.SearchStates(poolId, scaleSetId, states, poolName, excludeUpdateScheduled, numResults);
            var json = JsonSerializer.Serialize(await r.ToListAsync(), EntityConverter.GetJsonSerializerOptions());
            var resp = req.CreateResponse(HttpStatusCode.OK);
            await resp.WriteStringAsync(json);

            return(resp);
        }
Esempio n. 11
0
        /// <summary>
        /// Get algorithm price in thai baht per day if we mining in auto btc pool.
        /// </summary>
        /// <param name="algorithmName">algorithm name ex. lyra2z</param>
        /// <param name="poolName">PoolName enum</param>
        /// <returns></returns>
        public double GetTotalFiatMoneyMiningPerday(string algorithmName, PoolName poolName, bool estimateCurrent, FiatCurrency fiat)
        {
            double totalBtcPerDay = GetTotalBtcMiningPerday(algorithmName, poolName, estimateCurrent);
            double fiatPerBTC     = (fiat == FiatCurrency.THB) ? _thaiBahtPerBTC : _usdPerBTC;

            return(totalBtcPerDay * fiatPerBTC);
        }
Esempio n. 12
0
        public static double GetPoolOverrideReward(PoolName poolName, string coinSymbol)
        {
            string key = poolName.ToString() + "_" + coinSymbol;

            if (_reward.ContainsKey(key))
            {
                return(_reward[key]);
            }
            return(-1);
        }
Esempio n. 13
0
        /// <summary>
        /// Get a coin price in btc per day if we mining it.
        /// </summary>
        /// <param name="coinSymbol"></param>
        /// <param name="exchangeName"></param>
        /// <returns>btc</returns>
        public double GetTotalBtcMiningPerday(string coinSymbol, PoolName poolName, ExchangeName exchangeName)
        {
            double coinsPerDay = GetNumOfCoinMiningPerDay(coinSymbol, poolName);

            Debug.WriteLine(string.Format("{0} mining per day {1} {0} at pool {2}", coinSymbol, coinsPerDay, poolName));
            string pairSymbol = coinSymbol + "-BTC";
            double bidPrice   = GetBidPrice(pairSymbol, exchangeName);

            return(coinsPerDay * bidPrice);
        }
Esempio n. 14
0
	public static Transform SpawnPrefab (Spawn spawn, Vector3 pos, Vector3 rot, PoolName pool)
	{
		string poolName = GetPoolName (pool);
		string spawnName = GetSpawnName (spawn);
		
		Transform instance = PoolManager.Pools [poolName].Spawn (GetSpawn (spawnName).transform, pos, Quaternion.identity);
		instance.eulerAngles = rot;
		
		return instance;
	}
Esempio n. 15
0
    public static Transform SpawnPrefab(Spawn spawn, Vector3 pos, Vector3 rot, PoolName pool)
    {
        string poolName  = GetPoolName(pool);
        string spawnName = GetSpawnName(spawn);

        Transform instance = PoolManager.Pools [poolName].Spawn(GetSpawn(spawnName).transform, pos, Quaternion.identity);

        instance.eulerAngles = rot;

        return(instance);
    }
Esempio n. 16
0
 //풀타입에 따른 풀을 찾아옵니다
 private Pool FindPoolByPoolType(PoolName poolType)
 {
     for (int i = 0; i < pools.Length; i++)
     {
         if (pools[i].poolName == poolType)
         {
             return(pools[i]);
         }
     }
     return(null);
 }
Esempio n. 17
0
    public void EnqueueGameObject(PoolName poolName, GameObject obj)
    {
        var pool = poolInfos[poolName];

        if (pool == null)
        {
            return;
        }

        obj.SetActive(false);
        PoolDictionary[poolName].Enqueue(obj);
    }
Esempio n. 18
0
    /// <summary>
    /// 오브젝트를 풀로 반환합니다
    /// </summary>
    /// <param name="poolName">반환시키고 싶은 풀</param>
    /// <param name="obj">반환할 오브젝트</param>
    public void ReturnObject(GameObject obj, PoolName poolName)
    {
        Pool currentPool = FindPoolByPoolType(poolName);

        if (currentPool == null)
        {
            Debug.LogError($"<color=red>[{poolName}]</color>의 풀을 찾지 못했습니다. 이름을 확인해주세요.  </color>");
        }
        obj.gameObject.SetActive(false);
        obj.transform.SetParent(currentPool.poolTr.transform);
        currentPool.poolingObjectQueue.Enqueue(obj);
    }
Esempio n. 19
0
    static string GetPoolName(PoolName pool)
    {
        switch (pool)
        {
        case (PoolName.Default):
            return("Default");

            break;

        default:
            Debug.LogError("Couldn't find Pool Name");
            return("Default");
        }
    }
Esempio n. 20
0
        private static void ExploreMiningDetail(string algorithmName, PoolName pool)
        {
            double btcCurrentPerDay = _calc.GetTotalFiatMoneyMiningPerday(algorithmName, pool, true, _fiat);
            double btc24HoursPerDay = _calc.GetTotalFiatMoneyMiningPerday(algorithmName, pool, false, _fiat);

            if (btc24HoursPerDay > _keepMoreThan || btcCurrentPerDay > _keepMoreThan)
            {
                AlgorithmResult algorAtBlockMaster = new AlgorithmResult();
                algorAtBlockMaster.name             = algorithmName;
                algorAtBlockMaster.Pool             = pool;
                algorAtBlockMaster.estimate_current = btcCurrentPerDay;
                algorAtBlockMaster.estimate_last24h = btc24HoursPerDay;
                _algorsResult.Add(algorAtBlockMaster);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Get total btc per day if we mining at auto btc pool.
        /// </summary>
        /// <param name="algorithmName">algorithm name ex. lyra2z</param>
        /// <param name="poolName">PoolName enum</param>
        /// <param name="current">true if current estimmate, false if 24 hours estimate</param>
        /// <returns>btc</returns>
        public double GetTotalBtcMiningPerday(string algorithmName, PoolName poolName, bool estimateCurrent)
        {
            double btcPerDay = 0;

            if (MyHashRate == -1)
            {
                throw new Exception("Invaid MyHashRate property. Please specify MyHashRate property before calling GetTotalBtcMiningPerday method.");
            }

            AlgorithmBase algor = null;

            if (poolName == PoolName.Zerg)
            {
                algor = _zergAlgorithm[algorithmName];
            }
            else if (poolName == PoolName.PhiPhi)
            {
                algor = _phiAlgorithm[algorithmName];
            }
            else if (poolName == PoolName.AhashPool)
            {
                algor = _ahashAlgorithm[algorithmName];
            }
            else if (poolName == PoolName.Zpool)
            {
                algor = _zpoolAlgorithm[algorithmName];
            }
            else if (poolName == PoolName.BlockMaster)
            {
                algor = _blockMasterAlgorithm[algorithmName];
            }
            if (algor != null)
            {
                if (estimateCurrent)
                {
                    btcPerDay = GetBtcPerDay(algor.estimate_current, algor.mbtc_mh_factor, false);
                }
                else
                {
                    btcPerDay = GetBtcPerDay(algor.actual_last24h, algor.mbtc_mh_factor, true);
                }
            }
            else
            {
                Debug.WriteLine(string.Format("WARNING: Not found algorithm {0} at {1} pool.", algorithmName, poolName));
            }
            return(btcPerDay);
        }
Esempio n. 22
0
        private static void ExploreMiningDetail(CryptoCurrency coins, string symbol, PoolName pool, ExchangeName exchange)
        {
            double moneyPerDay = GetMiningFiatPerDay(symbol, coins[symbol].algo, pool, exchange);

            if (moneyPerDay > _keepMoreThan)
            {
                _result.AppendLine(string.Format("{0},{1},{2},{3},{4}", symbol, coins[symbol].algo, pool, exchange, moneyPerDay));
                CryptoCurrencyResult coin = new CryptoCurrencyResult();
                coin.symbol   = symbol;
                coin.h24_btc  = moneyPerDay;
                coin.Pool     = pool;
                coin.algo     = coins[symbol].algo;
                coin.Exchange = exchange;
                _coinsResult.Add(coin);
            }
        }
Esempio n. 23
0
        private static void ExploreMining(CryptoCurrency coins, string symbol, PoolName pool)
        {
            string coinAtPool = string.Format("{0}@{1}", symbol, pool);

            if (coins != null && coins[symbol] != null && !ExcludeCoinAtPool.ExcludeCoins.Contains(coinAtPool))
            {
                ExploreMiningDetail(coins, symbol, pool, ExchangeName.CryptoBridge);
                ExploreMiningDetail(coins, symbol, pool, ExchangeName.Crex24);
                ExploreMiningDetail(coins, symbol, pool, ExchangeName.Cryptopia);
                ExploreMiningDetail(coins, symbol, pool, ExchangeName.Binance);
                ExploreMiningDetail(coins, symbol, pool, ExchangeName.CoinExchange);
                if (_needToShowCoinsNumPerDay)
                {
                    ShowNumOfCoinMiningPerDay(symbol, pool);
                }
            }
        }
Esempio n. 24
0
    public async Async.Task <OneFuzzResult <Pool> > GetByName(PoolName poolName)
    {
        var pools = QueryAsync(Query.PartitionKey(poolName.String));

        var result = await pools.ToListAsync();

        if (result.Count == 0)
        {
            return(OneFuzzResult <Pool> .Error(ErrorCode.INVALID_REQUEST, "unable to find pool"));
        }

        if (result.Count != 1)
        {
            return(OneFuzzResult <Pool> .Error(ErrorCode.INVALID_REQUEST, "error identifying pool"));
        }

        return(OneFuzzResult <Pool> .Ok(result.Single()));
    }
Esempio n. 25
0
    public async Async.Task Search_MultipleNodes_ByPoolName()
    {
        await Context.InsertAll(
            new Node(PoolName.Parse("otherPool"), Guid.NewGuid(), null, _version),
            new Node(_poolName, Guid.NewGuid(), null, _version),
            new Node(_poolName, Guid.NewGuid(), null, _version));

        var req = new NodeSearch(PoolName: _poolName);

        var auth   = new TestEndpointAuthorization(RequestType.User, Logger, Context);
        var func   = new NodeFunction(Logger, auth, Context);
        var result = await func.Run(TestHttpRequestData.FromJson("GET", req));

        Assert.Equal(HttpStatusCode.OK, result.StatusCode);

        // make sure we got the data from the table
        var deserialized = BodyAs <NodeSearchResult[]>(result);

        Assert.Equal(2, deserialized.Length);
    }
Esempio n. 26
0
    /// <summary>
    /// Return the pool flagged _poolName in inspector. If several are flagged _poolName, returns the one at the index _poolIndex.
    /// </summary>
    /// <param name="_poolName"></param>
    /// <param name="_poolIndex"></param>
    /// <returns></returns>
    public PoolLeader GetPoolByName(PoolName _poolName, int _poolIndex = 0)
    {
        int iteration = 0;

        foreach (PoolLeader leader in poolLeaders)
        {
            if (leader.poolName == _poolName)
            {
                if (iteration == _poolIndex)
                {
                    return(leader);
                }
                else
                {
                    iteration++;
                }
            }
        }

        return(null);
    }
Esempio n. 27
0
        //[Test]
        public async void SimpleWorkflowTest()
        {
            if (!File.Exists("batch-config.json") || !File.Exists("storage-config.json"))
            {
                return;
            }

            var batchConfig =
                JsonConvert.DeserializeObject <Configuration.BatchConfiguration>(File.ReadAllText("batch-config.json"));
            var storageConfig =
                JsonConvert.DeserializeObject <Configuration.StorageConfiguration>(
                    File.ReadAllText("storage-config.json"));

            var simpleCommand = Command.NewSimpleCommand("echo 'Hello World'");

            var simpleWorkload =
                new WorkloadSpecification(
                    new FSharpList <WorkloadUnitTemplate>(
                        new WorkloadUnitTemplate(
                            new CommandSet(
                                new FSharpList <CommandWithErrorHandler>(
                                    new CommandWithErrorHandler(simpleCommand, FSharpOption <Command> .None),
                                    FSharpList <CommandWithErrorHandler> .Empty),
                                FSharpList <Command> .Empty),
                            LocalFiles.Zero,
                            false),
                        FSharpList <WorkloadUnitTemplate> .Empty),
                    LocalFiles.Zero,
                    WorkloadArguments.Zero);

            await
            WorkloadOperations.SubmitWorkloadToPoolAsync(
                batchConfig,
                storageConfig,
                Pool.NewNamedPool(
                    new NamedPool(PoolName.NewPoolName("john"), PoolOperations.GetDefaultPoolSpecification)),
                simpleWorkload);
        }
Esempio n. 28
0
        /// <summary>
        /// Returns true if OrgApacheSlingCommonsSchedulerImplQuartzSchedulerProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheSlingCommonsSchedulerImplQuartzSchedulerProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheSlingCommonsSchedulerImplQuartzSchedulerProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     PoolName == other.PoolName ||
                     PoolName != null &&
                     PoolName.Equals(other.PoolName)
                     ) &&
                 (
                     AllowedPoolNames == other.AllowedPoolNames ||
                     AllowedPoolNames != null &&
                     AllowedPoolNames.Equals(other.AllowedPoolNames)
                 ) &&
                 (
                     SchedulerUseleaderforsingle == other.SchedulerUseleaderforsingle ||
                     SchedulerUseleaderforsingle != null &&
                     SchedulerUseleaderforsingle.Equals(other.SchedulerUseleaderforsingle)
                 ) &&
                 (
                     MetricsFilters == other.MetricsFilters ||
                     MetricsFilters != null &&
                     MetricsFilters.Equals(other.MetricsFilters)
                 ) &&
                 (
                     SlowThresholdMillis == other.SlowThresholdMillis ||
                     SlowThresholdMillis != null &&
                     SlowThresholdMillis.Equals(other.SlowThresholdMillis)
                 ));
        }
Esempio n. 29
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            string[] poolNames = PoolName.GetPoolNames();

            if (poolNames.Length == 0)
            {
                EditorGUI.LabelField(position, ObjectNames.NicifyVariableName(property.name), "Pool is Empty");
                return;
            }

            int[] poolNumbers = new int[poolNames.Length];

            SetPoolNambers(poolNumbers, poolNames);

            if (!string.IsNullOrEmpty(property.stringValue))
            {
                poolNameAttribute.selectedValue = GetIndex(poolNames, property.stringValue);
            }

            poolNameAttribute.selectedValue = EditorGUI.IntPopup(position, label.text, poolNameAttribute.selectedValue, poolNames, poolNumbers);

            property.stringValue = poolNames[poolNameAttribute.selectedValue];
        }
Esempio n. 30
0
    public async Async.Task <Node> Create(
        Guid poolId,
        PoolName poolName,
        Guid machineId,
        Guid?scaleSetId,
        string version,
        bool isNew = false)
    {
        var node = new Node(poolName, machineId, poolId, version, ScalesetId: scaleSetId);

        ResultVoid <(int, string)> r;

        if (isNew)
        {
            r = await Replace(node);
        }
        else
        {
            r = await Update(node);
        }
        if (!r.IsOk)
        {
            _logTracer.WithHttpStatus(r.ErrorV).Error($"failed to save NodeRecord, isNew: {isNew}");
        }
        else
        {
            await _context.Events.SendEvent(
                new EventNodeCreated(
                    node.MachineId,
                    node.ScalesetId,
                    node.PoolName
                    )
                );
        }

        return(node);
    }
Esempio n. 31
0
    public GameObject SpawnFromPool(PoolName poolName, Vector3 position, Quaternion rotation)
    {
        if (!poolDictionary.ContainsKey(poolName))
        {
            return(null);
        }

        GameObject objectToSpawn = poolDictionary[poolName].Dequeue();

        objectToSpawn.SetActive(true);
        objectToSpawn.transform.position = position;
        objectToSpawn.transform.rotation = rotation;

        IPooledObject pooledObj = objectToSpawn.GetComponent <IPooledObject>();

        if (pooledObj != null)
        {
            pooledObj.OnObjectSpawn();
        }

        poolDictionary[poolName].Enqueue(objectToSpawn);

        return(objectToSpawn);
    }
Esempio n. 32
0
	static string GetPoolName (PoolName pool)
	{
		switch (pool) {
		case(PoolName.Default):
			return "Default";
			break;
		default:
			Debug.LogError ("Couldn't find Pool Name");
			return "Default";
		}
	}
Esempio n. 33
0
	public static void DespawnPrefab (Transform trans, PoolName pool)
	{
		string poolName = GetPoolName (pool);

		PoolManager.Pools [poolName].Despawn (trans);
	}