Jemgine

4Feb/101

2-4

Problem : A list of created entities. All entities in the list are initialized, and if they have an OnSpawn handler, it is called. Problem : The OnSpawn handler can spawn an object, which is placed in the list of created entities. Possible result : Infinite loop creating an infinite number of entities.
Solution : Double-buffer the created entities list. I can do this by hand, or just create a simple collection class to handle it for me. Bonus : I get to learn how to write collections in C#. It only needs three operations : Swap, ClearFront, and Add. (Of course, implement the IEnumerator interface to use foreach on it - it's just a pass through to the front buffer.)

Problem : Referring to entities by ID. IDs cannot be reused. If IDs are never reused, entities must be stored in a dictionary. If IDs are reused, errors can occur when an ID is recycled soon after being released. (Things referring to it need at least one complete update cycle to notice that the ID has been invalidated - and this is hard on scripts anyway.)
Solution : Entity handles. Untie the array index from the entity ID. A handle is an ID and an index. This lets a handle be invalid even if a new entity has been created at that index - their IDs will not match. This solution is not meant to recycle entities, only array indexes. Entity look-up remains fast, while not creating a reference in the object graph.
Addendum : This breaks some functionality of the scripting system, while making other functionality possible. I will proceed with caution.
Implementation : Write a custom container. It indexes on handles.

About Bleck

No description. Please complete your profile.
Comments (1) Trackbacks (0)
  1. Random unqualified suggestion: Use higher brush opacity. Like 100% but with pressure sensitivity. I haven’t painted in months and months, but I seem to recall liking the ability to “dig in” hard and completely draw over an area with my selected color. Constantly using semi-transparent brushes makes the image look undefined and ghosty without a clear palette, plus it adds to the negative impact of linear RGB blending that will rob you of some color saturation.

    Also – I haven’t put in the reading effort, but at a glance it seems you are obsessing way too much over theoretical programming constructs. I know you like your C++ though, and it’s fine as long as you admit it’s entertainment rather than productivity :)


Leave a comment


Trackbacks are disabled.