/// <summary>
        /// Allocates a worker to the specified <see cref="VillageObject"/>.
        /// </summary>
        /// <param name="vilObj"><see cref="VillageObject"/> to allocate the worker to.</param>
        public void AllocateWorker(VillageObject vilObj)
        {
            if (vilObj == null)
            {
                throw new ArgumentNullException(nameof(vilObj));
            }

            if (!_villageObjects.Contains(vilObj))
            {
                _villageObjects.Add(vilObj);
            }
        }
        // Tries to get the VillageObject with the corresponding game ID.
        public static bool TryPop(int kindId, out VillageObject obj)
        {
            //return GetPool(gameId).TryTake(out obj);

            obj = default(VillageObject);
            var success = GetPool(kindId).TryTake(out obj);

            if (success)
            {
                obj.ResetVillageObject();
            }

            return(success);
        }
        /// <summary>
        /// Deallocates a worker allocated to the specified <see cref="VillageObject"/>.
        /// </summary>
        /// <param name="vilObj"><see cref="VillageObject"/> to deallocate the worker.</param>
        public void DeallotateWorker(VillageObject vilObj)
        {
            if (vilObj == null)
            {
                throw new ArgumentNullException(nameof(vilObj));
            }

            var id = vilObj.Id;

            if (_villageObjects.Contains(vilObj))
            {
                _villageObjects.Remove(vilObj);
            }
        }
 // Pushes the specified VillageObject to the corresponding pool.
 public static void Push(VillageObject obj)
 {
     GetPool(obj.KindId).Add(obj);
 }
示例#5
0
 /// <summary>
 /// Resets the <see cref="Component"/>.
 /// </summary>
 protected internal virtual void ResetComponent()
 {
     _parent = default(VillageObject);
 }