Spawn an entity in the world. This schedules the Entity to be added to the Entity list and its components to the component store at the beginning of the next tick. @param e the entity to spawn @return true if the spawn succeeded, false if it failed */
| 107 | @return true if the spawn succeeded, false if it failed |
| 108 | */ |
| 109 | bool RavEngine::World::Spawn(Ref<Entity> e){ |
| 110 | //if the entity is not already spawned or pending spawn |
| 111 | if (find(Entities.begin(), Entities.end(),e) == Entities.end() && find(PendingSpawn.begin(), PendingSpawn.end(),e) == PendingSpawn.end() ){ |
| 112 | mtx.lock(); |
| 113 | PendingSpawn.push_back(e); |
| 114 | mtx.unlock(); |
| 115 | return true; |
| 116 | } |
| 117 | return false; |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | Marks an entity for destruction. This does NOT destroy it or its components immediately. At the end of the tick, entities marked with |