Useful feature(?): container stacking

More
12 years 4 months ago #17229 by SRC
I think I have a "fix" to the problem of grandchild sims (sims that are children of the child sims attached to the player-ship (or to non-player ships) not following the ship through capsule jumps.

Basically, prior to a jump you need to use the function

Sim.Children(ship-about-to-jump)

to get a "Set" (this is a specific data type in the SDK) of all sims that are children of the ship that is about to jump. These sims will all jump with the ship, but their children will not.

You can convert this Set to a List (another data type) and attach it to the ship-about-to-jump as a handle property ( with function Object.AddListProperty() )

Then, for each sim in that Set, do the same thing -- use Sim.Children(child-sim-N) to get a set of all grandchildren sims of the top sim (the ship about to jump). COnvert from Set to List and attach to the sim handle.

Keep doing this, descending into the "family tree" of sims that are "related" to the ship-about-to-jump.

When you are done, you will have a comprehensive list of the structure of the parent-child relationships on the ship about to jump, and after the jump you can use this information to attempt to reconnect all the grand- and greater-than-grandchild sims that did not follow the ship through the jump.

This reconstruction will be most straightforward for sims that are docked to the "parent" (or to children of the parent, etc). If the docking was done with iDockingUtil.pog functions, each dockport will have the handle to its partner on the docked sim, and this information can be used to re-dock all orphaned sims back to the precise locations they had on their respective parents. Actually, this dockport-handle information alone should be enough to reconstruct the "family tree" of child sim relationships after a jump provided that all child sims were children by virtue of being docked to their parents. There are other ways to attach child sims to parents, and it is less clear to me in that case how to reconstruct the family tree. You would need to know the exact locations of the child sims with respect to their parents; with that information you would use the Sim.AddChildRelativeTo() function.

But I think that the dockport information should cover most cases of grand- and greater-children being left behind at capsule jumps. Multi-stacked pods will have been docked. And in notional cases of ship-carrier transports carrying ships with children through a jump, the children of the carried ships will generally be docked (pods, or turret-ships, or docked lifeboats) to their respective parents, and so the above scheme should work.

I'll code a small package iChildSims.pog with some functions to do these things.

I think this will resolve the major obstacle to implementing cargo pod stacking and chaining, and also to the use of the Megafreighter to carry cargo through capsule space. Because the small cargo pods are children of the mega-pods, they are grandchildren of the megafreighter and so do not jump with the freighter.

Please Log in or Create an account to join the conversation.