Beispiel #1
0
        public override IEnumerable <Relation <Object, PrefabEventType> > GetRelations(Object entity)
        {
            var asGameObject = entity as GameObject;

            Killable asKillable = (asGameObject != null) ? asGameObject.GetComponent <Killable>() : entity as Killable;

            if (asKillable != null)
            {
                foreach (PrefabEventType type in System.Enum.GetValues(typeof(PrefabEventType)))
                {
                    if ((includeEvents & type) == 0)
                    {
                        continue;
                    }

                    var handler = prefabEventData[type];
                    if (handler.useSpecific(asKillable))
                    {
                        var prefabTransform = handler.getSpecificPrefab(asKillable);
                        if (prefabTransform != null)
                        {
                            yield return(new Relation <Object, PrefabEventType>(entity, prefabTransform.gameObject, type));
                        }
                    }
                    else if (handler.usePool(asKillable))
                    {
                        var pool = LevelSettings.GetFirstMatchingPrefabPool(handler.getPoolName(asKillable));
                        if (pool == null)
                        {
                            continue;
                        }

                        foreach (var item in pool.poolItems)
                        {
                            yield return(new Relation <Object, PrefabEventType>(entity, item.prefabToSpawn.gameObject, type));
                        }
                    }
                }
                yield break;
            }
        }
        public override IEnumerable <Relation <object, string> > GetRelations(object entity)
        {
            var asSpawner = entity as WaveSyncroPrefabSpawner;

            if (asSpawner != null)
            {
                if (asSpawner.activeMode == LevelSettings.ActiveItemMode.Never)
                {
                    yield break;
                }

                foreach (var spec in asSpawner.waveSpecs)
                {
                    if (!DoIncludeWaveSpec(spec, levelFilter, waveFilter))
                    {
                        continue;
                    }

                    yield return(new Relation <object, string>(entity, spec, string.Empty));
                }
                yield break;
            }

            var asWaveSpec = entity as WaveSpecifics;

            if (asWaveSpec != null)
            {
                if (!asWaveSpec.enableWave)
                {
                    yield break;
                }

                if (asWaveSpec.spawnSource == WaveSpecifics.SpawnOrigin.Specific)
                {
                    var prefabNode = new GameObjectNode()
                    {
                        gameObject = asWaveSpec.prefabToSpawn.gameObject
                    };
                    yield return(new Relation <object, string>(entity, prefabNode, "Spawns prefab"));
                }
                else if (asWaveSpec.spawnSource == WaveSpecifics.SpawnOrigin.PrefabPool)
                {
                    var pool = LevelSettings.GetFirstMatchingPrefabPool(asWaveSpec.prefabPoolName);
                    if (pool != null)
                    {
                        var poolNode = new PoolNode()
                        {
                            pool = pool
                        };
                        yield return(new Relation <object, string>(entity, poolNode, "Spawns prefab of pool"));
                    }
                }
                yield break;
            }

            var asPool = entity as PoolNode;

            if (asPool != null)
            {
                // connect to members
                foreach (var item in asPool.pool.poolItems)
                {
                    yield return(new Relation <object, string>(entity, item.prefabToSpawn.gameObject, "Contains prefab"));
                }
                yield break;
            }

            // GameObject: do nothing. prefabs are leaf nodes

            yield break;
        }