Entity

by Kaiochao
Build game objects from components, like in Unity!
ID:2130107
 
Kaiochao wrote:
DM Entity - Demo Components

Demo of a component-based entity system (like Unity's MonoBehaviour and GameObject) in BYOND, with:
* a smooth camera component
* a player (blue circle) controller component that supports keyboard (WASD) and gamepad (left analog stick) controls
* wandering AI component (the red circles)

GitHub (full source code!): https://github.com/Kaiochao/dm-entity

YouTube video: https://youtu.be/qm9_hNIYfc0



https://puu.sh/qx2k6/098eebef40.mp4

I added entity-tracking to the Camera component, which allows for components like Wander AI to deactivate when entities are not in range of a camera, and activate when they come into range of a camera.

The result is a map with 5000 wandering entities with less than 3% CPU usage in normal circumstances (depends on how many entities are in the camera) and you'll never see an inactive wandering entity.

In the video (which is lower quality than the YouTube video because it's from ShareX instead of OBS Studio), I click a "watch random entity" verb that sets the camera to a random entity in the world. Setting the camera is as easy as calling camera.SetTarget(atom).