/// <summary>
        /// Creates this cache entry
        /// Automatically gets reference to the EntityTag of the Entity
        /// </summary>
        /// <param name="Entity">GameEntity to cache</param>
        public GameEntityCacheEntry(GameObject Entity)
        {
            if(Entity.tag != "GameEntity")
            {
                Debug.LogError("Attempted to cache a non GameEntity GameObject. Blocked");
                Entity = null;
                Tag = null;
            }

            this.Entity = Entity;

            Tag = Entity.GetComponent<EntityTag>();

            EntityHash = Entity.GetHashCode();
        }
Exemple #2
0
        /// <summary>
        /// caches all spawnpoints in game world into this collection
        /// </summary>
        public void CacheAll()
        {
            GameObject[] Entities = GameObject.FindGameObjectsWithTag("GameEntity");
            if (Entities.Length > 0)
            {
                for (int i = 0; i < Entities.Length; ++i)
                {
                    EntityTag TagManager = Entities[i].GetComponent <EntityTag>();

                    if (TagManager != null)
                    {
                        if (TagManager.Is(Tag.SpawnPoint))
                        {
                            SpawnPoints.Add(Entities[i]);
                        }
                    }
                    else
                    {
                        Debug.LogError("ERROR: Entity does not have EntityTag: " + Entities[i].ToString());
                    }
                }
            }
        }