Moonwards-Virtual-Moon icon indicating copy to clipboard operation
Moonwards-Virtual-Moon copied to clipboard

Refactor how the ECS works for ease of coding.

Open Zach777 opened this issue 3 years ago • 0 comments

You will have Entity APIs that will be in charge of letting everything know certain actions were performed. It will also be the place to get entity values from. These APIs are called EPIs, for Entity Programming Interface.

The other will be Component APIs. These will allow you to get the specific component that the entity may or may not have. Component APIs are called CPIs.

You will always call a function in the AEntity to retrieve the API that you want. Regardless of whether the API is a EPI or CPI.

There are two forms of calling function, a request or a demand.

Requests will not crash or cause an error when the requested API is not present in the AEntity.

Demands will crash if they are not present in the AEntity. This is useful for if you rely on the APIs presence. Lets say that a camera component needs to know when someone has taken control of it's entity. The component will have a variable much like this: onready var context_epi : ContextEPI = entity.request_epi(APIList.epis.ContextEPI) #Component does not require this epi so it will return a dummy epi if the epi is not in the parent entity.

This dummy epi still has all it's functions, variables and signals so the component does not need to have any logic for a missing component.

Now all camera has to do is listen for a signal from context_epi that emits when someone takes control. Components that are in charge of switching entities will not need to call any components directly. It can just call the AEntity it is taking control of and pass the entity it is inside to the EPI.

Zach777 avatar Mar 07 '21 18:03 Zach777