Пример #1
0
        // Pushes the VillageObject to the VillageObjectPool where it will
        // be reused when Village.FromJson is called.
        internal void PushToPool()
        {
            // Don't wait for ResetVillageObject to be called to set the _village to null,
            // so the _village can get picked up by the GC.
            _village = null;

            // Push the object back to the pool.
            VillageObjectPool.Push(this);
            _pushCount++;
        }
Пример #2
0
        // Tries to return an instance of the Building class from the VillageObjectPool.
        // Used by ReadBuildingArray.
        internal static Building GetInstance(Village village)
        {
            var obj = (VillageObject)null;

            if (!VillageObjectPool.TryPop(Kind, out obj))
            {
                obj = new Building();
            }

            obj.SetVillageInternal(village);
            return((Building)obj);
        }
Пример #3
0
        // Tries to return an instance of the Building class from the VillageObjectPool.
        internal static Trap GetInstance(Village village)
        {
            var obj = (VillageObject)null;

            if (!VillageObjectPool.TryPop(Kind, out obj))
            {
                obj = new Trap();
            }

            obj.SetVillageInternal(village);
            return((Trap)obj);
        }
Пример #4
0
        internal static Decoration GetInstance(Village village)
        {
            var obj = (VillageObject)null;

            if (!VillageObjectPool.TryPop(Kind, out obj))
            {
                obj = new Decoration();
            }

            obj.SetVillageInternal(village);
            return((Decoration)obj);
        }
Пример #5
0
        internal static Obstacle GetInstance(Village village)
        {
            var obj = (VillageObject)null;

            if (!VillageObjectPool.TryPop(Kind, out obj))
            {
                obj = new Obstacle();
            }

            obj.SetVillageInternal(village);
            return((Obstacle)obj);
        }