public void SpawnEntity(string identity, EntityType type, int x, int y) { Vector3 position = WorldManager.GamePosAtTile(ManagerInstance.Get <WorldManager>().completeMap[x, y]); GameObject gameObject = GameObject.Instantiate(Resources.Load("Entities/" + type), position, Quaternion.identity) as GameObject; bool foundData = false; switch (type) { case EntityType.None: break; case EntityType.Actor: for (int i = 0; i < m_actors.loadedData.Count; i++) { if (m_actors.loadedData[i].identity == identity) { gameObject.GetComponent <EntityComponent>().SetData(m_actors.loadedData[i].Clone(), m_actors.loadedGraphics[i]); foundData = true; } } break; case EntityType.Static: for (int i = 0; i < m_staticEntities.loadedData.Count; i++) { if (m_staticEntities.loadedData[i].identity == identity) { gameObject.GetComponent <EntityComponent>().SetData(m_staticEntities.loadedData[i].Clone(), m_staticEntities.loadedGraphics[i]); foundData = true; } } break; case EntityType.Dynamic: for (int i = 0; i < m_dynamicEntities.loadedData.Count; i++) { if (m_dynamicEntities.loadedData[i].identity == identity) { gameObject.GetComponent <EntityComponent>().SetData(m_dynamicEntities.loadedData[i].Clone(), m_dynamicEntities.loadedGraphics[i]); foundData = true; } } break; default: break; } m_activeEntities.Add(gameObject.GetComponent <EntityComponent>().entity); if (!foundData) { Destroy(gameObject); CommandInput.DebugLog(new string[] { "Entity Not Found" }); } }