I'm developing on a simple libGDX-based Game and im using the entity-component-system ashley.
For non-generic but custom behaviour (e.g. the Player Movement), I'm using "scripts" instead of reuseable and generic Entity-Systems. Therefore I've got an ScriptComponent and a ScriptSystem which runs init()
and update()
on all scripts related to an entity.
At some point I want to generate a map, counting game-related-properties etc. that brings me to the point where I'm confused about how to access those porperties from any script.
In other Engines/Enviroments like Unity3D the GameObjects (the entities) brings functionality to find other entities like FindGameObjectsWithTag(...).
But how can I realise that in ashley? Also should it be possible in an Entity-Framework to access specific entities in general?
Edit: Additional information
Here comes a simple example-usecase. This is very notional example I've just created for that post. I just wanted to demonstrate, that I thing there is a need of an "main Game Object" in a game which also uses a entity-component-framework like ashley. So I thought a correct way is, to let this main-game-object be an entitiy too which holds the main script. But I'm not sure, if this is a good approach.
Here I demonstrate this with having a PlayerScript which just sets the lives for the player accordingly to the difficulty level of the game (maybe set by the player on the main-menu-screen). This PlayerScript is attached to the ScriptComponent of the player entity.
public class PlayerScript extends Script {
int playerLives;
public void init() {
GameEntity entity = getTheEntityByName("game"); // this method doesn't exist
GameScriptComponent gsc = scriptComponentMapper.get(entity);
GameScript mainGameScript = gsc.getScriptByName("game");
if(mainGameScript.getDifficulty == "easy")
playerLives = 999;
}
}
PooledEngine
. Because in that engine all components, entities can be pooled by calling.createEntity()
,.createComponent
\$\endgroup\$