On Fri, Jul 31, 2015 at 1:00 AM, Al Thomas <astav...@yahoo.co.uk> wrote:
> > From: Alan Manuel Gloria <almkg...@gmail.com> > > Semantically, an Entity is a reference to a row in an entity component > > system; it just happens to be implemented using uint. > > > This kind of sounds like referential integrity rules in > a relational database. I presume you not using a database > for performance and/or memory issues? > > Yes. > > > I want to do this> because when I delete a row in the ECS table, I want > the row to be retained > > as "deleted" until all references to it are dropped, so that I avoid > > the "missile suddenly chases a new entity" problem. > > By 'retained as "deleted"' do you mean changing the state of the row so it > can > no longer be used when a new entity is created? Would it cause too much of > a > performance hit if the row had an 'allow new references' boolean that > caused > a newly created entity to skip it if the row was closed? > The refcount would serve as something like that; if the refcount drops to 0, the row can be reused, otherwise not. > Another thought is GLib signals, these are Vala signals, with a return > value. > So you would emit an I am about to delete xyz referenced component and if > anything returns no don't do that the component is kept. I've not used > return > values so not sure how this would work and is a bit more heavy weight > compared > to reference counting. > > Just a few thoughts. I got the impression it could be a design issue rather > than an implementation one. > I'd prefer to keep it automated; keeping a reference to the Entity should be enough to keep the row alive, and in each subsystem that is interested, query the liveness. class TrackingMissile: Component { public Entity target; } class TrackingMissileSys: Subsystem { protected override void run() { foreach(Entity e in component_column<TrackingMissile>()) { TrackingMissile tm = e.get<TrackingMissile>(); if (!tm.target.is_live()) { // missile loses its ability to track anything once target is dead. e.detach<TrackingMissile>(); continue; } // ... track target here ... } } } Of course, maybe signals would also work; maybe I could add hooks for attaching and detaching components to entities. > > All the best, > > > > Al > _______________________________________________ > vala-list mailing list > vala-list@gnome.org > https://mail.gnome.org/mailman/listinfo/vala-list > _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list