Hello, I am making a city simulation game. In my game, the player builds buildings, changes the configuration of buildings and makes some decisions (for example, the speed of all workers increases by 10%). Apart from this, the city simulation works. At this point, I want to program my player class and things like resources in MonoBehaviour and the rest in ECS (like combat, unit movements, physics). In this case, how should I create the communication between my player class, which is MonoBehaviour, and my ECS entities?
#Communication between ECS and MonoBehaviour player
1 messages · Page 1 of 1 (latest)
best not do that
generally, it's only ECS that's supposed to have access to Monos
while monos should not access ECS
that limits what monobehs can do to the point, they become just a data storage
So, in cases where I need to keep a global state, does it make sense to do this with Monos? For example, how should I store my resources in the game (food, iron), configurations of buildings, etc.?
on prefabs
state of resources can be just a component on entity
which is player
so basically, player entity has a component (dynamic buffer, which is basically a list component)
a list of struct Resource { public int resourceGuid; public int count; }
all configurations on buildings can easily belong on buildings themselves
so when you want to build something (as in, click on a button with said building) it will instantiate a prefab and based on components it has, all the necessary logic for making it work will function
It creates the entity required for the building with Prefab authoring. Did I get right?
not really
it will just instantiate an entity prefab associated with button
and then this instantiated entity will trigger all systems that are relevant to it
I think I confused a little bit, what do you mean by entity prefab. Isn't prefab is a mono feature