#Communication between ECS and MonoBehaviour player

1 messages · Page 1 of 1 (latest)

polar ivy
#

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?

jovial pilot
#

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

polar ivy
jovial pilot
#

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

polar ivy
jovial pilot
#

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

polar ivy
#

I think I confused a little bit, what do you mean by entity prefab. Isn't prefab is a mono feature

jovial pilot
#

maybe quickly read on this

#

to get some overview of things