-
Notifications
You must be signed in to change notification settings - Fork 70
Traversing the DataStructure
this is an unfinished page on traversing the datastructure to get the data you need.
To get the entity Owned by a specific Datablob: Entity
BaseDataBlob.OwningEntity
To get an Entity's manager EntityManager
Entity.Manager()
To get the subpulse: `EntityManager.ManagerSubpulse'
EntityManager Game Game
Game.GlobalManager.FindEntityByGuid()
Game.GlobalManager.FindEntityByGuid()
EntityManager List GetAllEntitiesWithDataBlob() Entity GetFirstEntityWithDataBlob() bool FindEntityByGuid(Guid entityGuid, out Entity entity)
Entity T GetDataBlob()
##Problems and issues:
Currently the only real link between an entity and a starsystem is the PositionDB. Managers do not have a link to the StarSystem, so if you have a manager, and want to get the star system that it handles, you'd have to get an entity with the PositionDB then get the SystemGuid from the PositionDB, then get the starSystem from the Game class using the SystemGuid.
problems with this:
As seen above, it's a bit of a pain to find a starsystem.
A manager might have entites in multiple systems - why or when you might want to do this, I'm unsure, but the way the structure is currently, this is allowed.
The only way to get entities within a star system, is to get the starSystem's manager, then get all entites with a PositionDB, then check each of those to match the SystemGuid.
We could enforce 1 starSystem 1 manager, either by giving managers a havea or and isa relationship with starSystems. this would remove the flexibility of allowing managers to handle entities across starsystems, which may not be an issue anyway.
We could also look at making starSystems an entity in and of themselfs - this would allow us to do manager.getAllEntitesWithDatablob() which would allow a manager to handle entites in multiple systems. we could then give StarSystem and OwnerDB and starSystems could then own entites within them, to make getting all entites within a system a bit easier. we need to improve the ownership anyway, currently factions have an OwnerDB and Owned DB has a smart property which adds the entity to the OwnerDB when Owned.FactionOwner gets set. we could have a hirachrical ownership using the OwnerDB.ObjectOwner ie, shipComponent -> ship -> StarSystem, or facility -> colony -> planet -> starSystem.
note that some entites don't have position (ship components, facilitys, colonies) which means that they have no starSystem link at all currently.
It's possible that we might at some point want to add position to these at some point (ie position within a ship, position on a planet.) that being said, a different positionDB could be used for this.
Enforcing a 1 to 1 relationship between managers and starsystems would keep things a bit more simple, I'm unsure if the timeloop/pulse will fully support entites in different starsystems or if odd bugs will pop up if this is allowed. at the same time, I'm not keen on removing flexibility which might make sense in the future.
Documentation
-
Contribution
-
Design
-
Processes
-
Datatypes
-
Guides and Resources
-
Modding & Json files