Example Components

by Kaiochao
ID:2130252
 
Included components

They aren't necessarily "standard" enough to go in the Standard Components library, but they're still pretty cool on their own.

* Move AI moves an entity at a constant speed in a straight line towards a target position.

* Player Controller allows entities to be controlled by a player's keyboard (WASD) or gamepad (left analog stick).

* Wander AI features a camera-aware AI that causes entities to wander around their starting position, but only while in range of a camera. This allows 50,000 entities to be evenly-spaced on the 750x750 map, without using any CPU, but still "appearing" to always be moving around.

* Color in Camera makes entities darken as they're in a camera, and revert to normal when they're no longer in any cameras.

* Velocity moves entities by a certain velocity over time. Used by bullets to keep them moving!

* Bullet (component) destroys bullet entities when they hit something.

* Player Gun Controller allows players to equip and fire guns.

* Gun components are what's equipped and fired. They can come in many shapes and sizes...

Prefabs?

I also introduce a sort of "Prefab" (in Unity terms) which is just an entity that comes instantiated with a default set of components.

The prefabs included, with the components that make them:

* Player: Camera, Player Controller, Player Gun Controller, Fully-Automatic Gun

* Wanderer: Move AI, Wander AI, Color in Camera

* Bullet: Bullet (component), Velocity

Entity Saving

This demo includes a very early attempt at being able to save and load entities. Use the "save player" and "load player" verbs. It should work fine, for the most part.
I made this hub because the core Entity library hub wasn't automatically installing the required libraries, probably because I was trying to only include them for the demo and not the rest of the library. I have since moved all the non-core content into this library, as well as the Standard Components library.

When you download this, all the libraries required by the core Entity library (e.g. Input Handler) should also be installed, along with Standard Components. Basically, this hub should be your first stop on your way to making your own components.