Example #1
0
        /// <summary>
        /// File-in and process the actions contained in the node.
        /// </summary>
        /// <param name="processor">Interchange format processor responsible for the processing context.</param>
        /// <param name="parseErrorSink">Error sink for reporting parse errors.</param>
        /// <param name="sourceCodeService">Source code service that can convert tokens to source code span and reports issues.</param>
        /// <returns>Return an interchange unit node for annotation, usually just self.</returns>
        public override InterchangeUnitNode FileIn(InterchangeFormatProcessor processor, IParseErrorSink parseErrorSink, ISourceCodeReferenceService sourceCodeService)
        {
            if (processor == null)
            {
                throw new ArgumentNullException("processor");
            }
            if (parseErrorSink == null)
            {
                throw new ArgumentNullException("parseErrorSink");
            }
            if (sourceCodeService == null)
            {
                throw new ArgumentNullException("sourceCodeService");
            }
            // ALL instance vars must be set. If one is missing, then source code bug, and
            //   InterchangeFormatParser.ParsePoolDefinition() should have reported the error.
            if (this.PoolName == null)
            {
                return(this);
            }

            PoolDefinition definition = new PoolDefinition(processor.CreateSourceReference(this.PoolName.Value, this.PoolName, sourceCodeService));

            this.Definfition = definition;
            // This may fail, but we don't care. If failed, it reported the error through its error sink.
            processor.FileInProcessor.FileInPool(definition);
            return(this);
        }
Example #2
0
        /// <summary>
        /// Loads pool definition asset and preloads pool into memory
        /// </summary>
        /// <param name="definition">Pool definition asset</param>
        /// <param name="Override">Should destroy current Object Pool data before load?</param>
        public void LoadPooldefinition(PoolDefinition definition, bool Override = false)
        {
            if (Override)
            {
                foreach (RecycleBin recycleBin in runtimeRecycleBins.Values)
                {
                    recycleBin.Dispose(true);
                }

                runtimeRecycleBins.Clear();
                ObjectPoolData.Clear();
            }
            StartCoroutine(I_LoadDefinition(definition));
        }
Example #3
0
    private void Init()
    {
        PlayerDefitionPool       = GameDefinitions.PoolDefinitions.FirstOrDefault(x => x.PoolType == PoolType.Player);
        EnemyDefinitionPool      = GameDefinitions.PoolDefinitions.FirstOrDefault(x => x.PoolType == PoolType.Enemy);
        ProjectileDefinitionPool =
            GameDefinitions.PoolDefinitions.FirstOrDefault(x => x.PoolType == PoolType.Projectile);
        MissileDefinitionPool = GameDefinitions.PoolDefinitions.FirstOrDefault(x => x.PoolType == PoolType.Missile);

        if (PlayerDefitionPool != null)
        {
            PlayerBehaviour = (PlayerBehaviour)ResourceManager.SpawnFromPool(PlayerDefitionPool.ID,
                                                                             PlayerSpawnPoint.transform.position,
                                                                             Quaternion.identity);
            PlayerBehaviour.Init();
        }
    }
Example #4
0
        private async void GetAvailablePools()
        {
            Func <Task> pools = new Func <Task>(
                async() =>
            {
                var availablePools = await PoolDefinition.GetAvailablePools();
                var proxies        = availablePools.Select(poll => new PollsProxy()
                {
                    Definition = poll
                });
                Polls      = new ObservableCollection <PollsProxy>(proxies);
                Categories = new ObservableCollection <string> (Polls.Select(p => p.Definition.Category));
            }
                );

            await ExecuteSafeOperation(pools);
        }
 bool IInterchangeFileInProcessor.FileInPool(PoolDefinition definition)
 {
     this.AddPool(definition);
     return(true);
 }
Example #6
0
        private IEnumerator I_LoadDefinition(PoolDefinition definition)
        {
            if (definition != null && definition.PoolData.Length > 0)
            {
                RecycleBinData[] poolData = definition.PoolData;
                Debug.Log($"[{GetType().Name}] Load PoolDefinition Started");

                List <RecycleBin> tmp_recycleBins = new List <RecycleBin>();

                for (int i = 0; i < poolData.Length; i++)
                {
                    var current_data = poolData[i];
                    if (string.IsNullOrEmpty(current_data.Label))
                    {
                        Debug.LogWarning($"[{GetType().Name}] Pool With null label detected at position {i}. Ignoring...");
                        continue;
                    }

                    if (runtimeRecycleBins.ContainsKey(current_data.Label))
                    {
                        Debug.LogWarning($"[{GetType().Name}] A Pool already Exists with label '{current_data.Label}'. Ignoring...'");
                        continue;
                    }

                    RecycleBin current = null;

                    switch (current_data.ReferenceType)
                    {
                    case PoolReferenceType.PREFAB:
                        current = new RecycleBin(current_data.Label, current_data.Prefabs,
                                                 current_data.PreallocateCount, null, current_data.UsePoolParent, current_data.Priority);
                        break;

#if ADDRESSABLES_INSTALLED
                    case PoolReferenceType.ASSET_REFERENCE:
                        current = new RecycleBin(current_data.Label, current_data.AssetReference, current_data.PreallocateCount,
                                                 null, current_data.UsePoolParent, current_data.Priority);
                        break;

                    case PoolReferenceType.LABEL_REFERENCE:
                        current = new RecycleBin(current_data.Label, current_data.AssetLabelReference,
                                                 current_data.PreallocateCount, null, current_data.UsePoolParent, current_data.Priority);
                        break;
#endif
                    default: goto case PoolReferenceType.PREFAB;
                    }

                    runtimeRecycleBins.Add(current.Label, current);
                    tmp_recycleBins.Add(current);
                }

                for (int i = 0; i < tmp_recycleBins.Count; i++)
                {
                    yield return(tmp_recycleBins[i].Allocate());
                }
                tmp_recycleBins.Clear();
            }
            yield return(new WaitForEndOfFrame());

            Debug.Log($"[{GetType().Name}] Load PoolDefinition finished");
            if (OnPoolDefinitionLoaded != null)
            {
                OnPoolDefinitionLoaded.Invoke();
            }
        }
 public void Start()
 {
     BackgrounndPool = GameDefinitions.PoolDefinitions.FirstOrDefault(x => x.PoolType == PoolType.Background);
     InitBackgroundLayer(transform.position);
 }
 /// <summary>
 /// Add a pool definition to the installation context.
 /// </summary>
 /// <param name="definition">Definition of the pool to be added.</param>
 public void AddPool(PoolDefinition definition)
 {
     this._globals.Add(definition);
 }