I am trying to solve a problem where I want show or hide certain entities when the player enters a room. For example, lets say I have the following 2 rooms, and 3 entities that I wish to show or hide.
// Rooms
Entity1 = [Room]
Entity2 = [Room]
// Entities to toggle Visbility on
Entity3 = [...]
Entity4 = [...]
Entity5 = [...]
I am using the entity event pattern to detect when the player enters a room. And what I want is to show Entity3 & Entity4 (and hide Entity5) when the player enters the room Entity1, and show Entity5 (and hide Entity3 & Entity4) when the player enters room Entity2.
I am examining two different approaches for solving this problem. DynamicBuffer vs Multiple Entity Approach (data layout of these approaches shown below). And my question is, which approach would better for this kind of problem? I am trying to wrap my head around when it would be better to use one approach vs the other.
// Dynamic Buffer Approach
Entity6 = [
OnRoomEnter { roomEntity = Entity1 },
ToggleEntityVisibilityBuffer { buffer = [Entity3, Entity4]}
]
Entity7 = [
OnRoomEnter { roomEntity = Entity2 },
ToggleEntityVisibilityBuffer { buffer = [Entity5]}
]
// Multiple Entity Approach
Entity6 = [
OnRoomEnter { roomEntity = Entity1 },
ToggleEntityVisibility { entity = Entity3 }
]
Entity7 = [
OnRoomEnter { roomEntity = Entity1 },
ToggleEntityVisibility { entity = Entity4 }
]
Entity8 = [
OnRoomEnter { roomEntity = Entity2 },
ToggleEntityVisibility { entity = Entity5 }
]