#pragma once #include "entity.h" #include #include #include struct EntitySpawn; struct RoomEntry; // Whether EntityFactory::Create overwrites an entity in use when its pool is full (SpawnEx's flag 1 keeps them). enum PoolMode { POOL_OVERWRITE, POOL_KEEP }; // EntityFactory's pools, one per entity class. enum PoolId { ENTITY_POOL_EFFECT, ENTITY_POOL_FAMILIAR, ENTITY_POOL_BOMB, ENTITY_POOL_PROJECTILE, ENTITY_POOL_TEAR, ENTITY_POOL_LASER, ENTITY_POOL_PICKUP, ENTITY_POOL_SLOT, ENTITY_POOL_NPC, ENTITY_POOL_TEXT, ENTITY_POOL_KNIFE, ENTITY_POOL_COUNT }; // A pool's class, its size, and its name in the pool full warning. struct PoolDesc { std::unique_ptr (*make)() = nullptr; const char* name = ""; uint32_t size = 0; }; // One class's entities. A slot is made the first time Create reaches it and reused once its entity leaves the room. // Create cycles from the slot it handed out last. struct EntityPool { std::vector> slots; const PoolDesc* desc = nullptr; uint32_t cursor = 0; Entity* Create(PoolMode mode); private: Entity& slot_get(); Entity& slot_next(); }; // The entity pools of a run (Game::entityFactory): every entity but the players lives in one, so spawning never // allocates once a slot exists. The original built all its pools in its constructor (006f2a10) and freed them in Game's // destructor. Slots are made on first use instead, which a new entity cannot tell apart. Its pool of plain Entity_Dummy // objects was never handed out, so it is gone. struct EntityFactory { std::array pools; EntityFactory(); Entity* Create(int type, PoolMode mode); }; // How Room::SpawnEntry places a layout entry, as when the room is entered or when its enemies respawn. enum EntryMode { ENTRY_SPAWN, ENTRY_RESPAWN }; // A layout entry spawned on a cell, and where to hand back the entity it made. struct RoomEntrySpawn { Entity** outEntity = nullptr; int gridIndex = 0; uint32_t seed = 0; EntryMode mode = ENTRY_SPAWN; }; Entity* game_spawn(const EntitySpawn& spawn, PoolMode mode); bool entity_is_erased(Entity& entity); void erased_enemy_id_fix(int& type, int& variant, int& subType); bool room_entry_spawn(Room& room, RoomEntry entry, const RoomEntrySpawn& spawn); void room_entry_transform(Room& room, RoomEntry& entry, int gridIndex, uint32_t seed); bool room_entity_is_persistent(int type, int variant); void room_trigger_output_index_add(Room& room, int group, int gridIndex); void room_trigger_output_cell_add(Room& room, int group, int column, int row);