Description:
Allows spaceships to have detectable interiors (no structural beams needed) and allows them to do suborbital jumps. With planned animation (droppod style).
Currently in early stage with working (i.e jumping) prototype done.
Prototype can currently transport pretty much everything except zoning.
Without animation yet.
After developed it is supposed to be integrated with things like RimVerse and such and be a framework for other mods.
Feel free to use detailed concept below and code in your mods (or continue it yourself if I abandon this). Just keep in mind that everything is subject to change.
All tips are welcome.
Mechanics:
Modified ship ComputerCore.
When commanded to launch a suborbital jump does following (at least this is a plan):
1. Detects ship boundaries and returns ship area as List<IntVec3>. (yes)
2. Constructs full lists of floors, walls and other buildings, pawns and things (possibly zones) inside ship area. (yes)
3. Asks player to select destination (like transportPod). Uses the constructed catalog to project ship boundaries allowing to select suitable place for landing. (yes)
4. Despawns entire ship except for ComputerCore itself and packs it into inner storage. (yes)
5. Using massive Draw() override and disabled Print() projects an illusion of a ship (based on the stored info) instead of despawned actual ship. (not yet)
6. Performs takeoff animation. (not yet)
7. Forms DropPod-like object on the global map but with more content attached to it. (yes)
8. Travels. (yes)
9. On arrival spawns ShipComputerCore that makes an illusion again and on touch down spawns everything. (no illusions yet)
Progress:
Step 1. Simple Illusions. (done)
Managed to make ShipComputerCore mimick different flooring and buildings with Draw() or Graphic() overrides.
Also managed to make ShipComputerCore look like it launches itself in the sky on command despite it being a building (you need to conditionally override Draw, DrawPos, disable Print and call a dirtymesh cleanup for this.)
The reason I did this first is because flooring in game is very different from Things and you need special tricks to make it move smoothly. I wasn't sure it is possible from start but seems like it is mostly ok.
Ideally I will also mimick items and pawns and lights and shadows but it seems like it should be ok so I better prove other stuff first.
Step 2. Ship boundary detection (Done. Ship area is now connected together by any floors and walls)
Created basic selection overlay for ShipComputerCore to visualize ship area.
Decided to make first iteration of area to be Everything that is connected by walls or floors with the Core.
Wrote a recurrent algorithm for boundary detection and it works.
Right now floors-not floors is decided by having/not having a blueprint def in Terraindata. I did it because i wanted for mod to be as compatible as it can.
Step 3. Basic ship contents detection. (done)
Ship now correctly detects all flooring, walls, buildings, items, dirt and pawns inside without double detections. No roof detection yet.
I also overwrote gamend spacelaunch conditions so that ship can now search for needed parts on entire ship grid. Ideally it will require them to be powered.
Step 6. Basic worldmap/localmap landing area selection interface. (done)
Made a raw but working adaptation of user interface from compLaunchable.
Step 7. Basic Travelling Spaceship worldobject. (done)
Prepared mostly-empty but working "spaceship" that is created on launch, is visible on map, travels to destination, sends a message on arrival and is ready to be filled with shipgrid info and actions.
Section: This Map-> This Map transportation tests (via Travelling Spaceship worldobject)
Step 8. Floor transport. (done)
If launch was ordered from pause state... then some unknown... bad thing ( it brought me a lot of headache) tried to nullify flooring storage of a ship on unpause. Protected my ship storage by adding special setter which DOES NOT allow nullification... and now it seems to work... Yes, Rimworld is a dangerous place indeed.
...Maybe i can use the setter to catch this flooring thief ( like "oh... the value you want to set is null... Can you tell me your name, please?"), but I don't know how to do it yet.
Step 9. Item transport. (done)
Step 10. Building transport. (done)
There is a bug in game where simultaneous deletion of walls with doors inserted like X|-|-|X results in a bunch of errors. Was forced to invent a workaround for this. Now works without errors.
Step 11. Pawn transport.(Done. At least no bugs noticed yet.)
Used 40kInjector (see Acknowledgements).
Detoured Pawnsfinder.get_AllMapsCaravansAndTravelingTransportPods
Detoured PawnsUtility.IsTravelingInTransportPodWorldObject(Pawn pawn)
Now pawns in spaceships should be counted as pawns in droppods.
Step 12. Roof detection and transport.(done but no hanging outside roof detection yet. For number of reasons including potential problem avoidance and aerodynamical realism it is probable that it will remain this way.)
Step 13. Full destination selection interface with multicell checks based on ship area. (done)
Section: This Map-> Other Map transportation tests.
Step 14. Automatic landing area selection.(Seems to be working. It is random so hard to tell.)
Step 15. Attacking other bases. (Done. Well, at least it seems to work.)
There was a funny bug with generated map for some reason starting with null sections[] but putting MapDrawer.RegenerateEverythingNow() was enough to counter this.
There is only one deployment method at the moment and it is "at the edge".
I was experimenting mostly with small "spaceships" though and it looks like bigger ones should have much more trouble with finding place to land.
Don't know what to do with that for now. Maybe less limitations on where it is possible to land (right now for every cell of the ship it is similar to droppod except for it cannot punch through roofs) or an ability to crashland.
Step 16. Settling with spaceship. (done with cat sleeping on knees)
[Note] Keep in mind that animation is not really necessary for mod to add to gameplay.
If all animation efforts will fail I will just use default screenfader to white to hide the moment of launch. (I will put it there anyway till animation is done)
So when Step 16 is done I will call it a working prototype.
Section: Static ship illusion.
Step 1. Floors.
Step 2. Buildings.
Step 3. Items.
Step 4. Pawns.
Step 5. Takeoff and landing animations.
Step 6. Shadows and lighting.
Screenshots:
On this screenshot cyan "ship" outline is shown.
ShipComputerCore pretends that it is just wooden plancks and certainly not a modified core.
Landing site selection interface (on world map standard droppod interface is used.)
Abanqueiro was tired of short jumps that evil Houkime forced him to do over and over (and also from other colonists trying to catch his jumping cabin) and this time jumped much farther.
A few seconds before jump:
And after his multi game-hour flight:
Acknowledgements:
Detours (2 methods) in this mod are made using 40KInjector which is cpt. Ohu's convenient repack of CCL-team detouring methods. Injector was taken from his colossal mod Warhammer 40K Corruption. You can find it here:
https://ludeon.com/forums/index.php?topic=28422.msg286833#msg286833
Downloads:
A bit bugfixed GridTOL prototype is attached.
[attachment deleted by admin due to age]
Allows spaceships to have detectable interiors (no structural beams needed) and allows them to do suborbital jumps. With planned animation (droppod style).
Currently in early stage with working (i.e jumping) prototype done.
Prototype can currently transport pretty much everything except zoning.
Without animation yet.
After developed it is supposed to be integrated with things like RimVerse and such and be a framework for other mods.
Feel free to use detailed concept below and code in your mods (or continue it yourself if I abandon this). Just keep in mind that everything is subject to change.
All tips are welcome.
Mechanics:
Modified ship ComputerCore.
When commanded to launch a suborbital jump does following (at least this is a plan):
1. Detects ship boundaries and returns ship area as List<IntVec3>. (yes)
2. Constructs full lists of floors, walls and other buildings, pawns and things (possibly zones) inside ship area. (yes)
3. Asks player to select destination (like transportPod). Uses the constructed catalog to project ship boundaries allowing to select suitable place for landing. (yes)
4. Despawns entire ship except for ComputerCore itself and packs it into inner storage. (yes)
5. Using massive Draw() override and disabled Print() projects an illusion of a ship (based on the stored info) instead of despawned actual ship. (not yet)
6. Performs takeoff animation. (not yet)
7. Forms DropPod-like object on the global map but with more content attached to it. (yes)
8. Travels. (yes)
9. On arrival spawns ShipComputerCore that makes an illusion again and on touch down spawns everything. (no illusions yet)
Progress:
Step 1. Simple Illusions. (done)
Managed to make ShipComputerCore mimick different flooring and buildings with Draw() or Graphic() overrides.
Also managed to make ShipComputerCore look like it launches itself in the sky on command despite it being a building (you need to conditionally override Draw, DrawPos, disable Print and call a dirtymesh cleanup for this.)
The reason I did this first is because flooring in game is very different from Things and you need special tricks to make it move smoothly. I wasn't sure it is possible from start but seems like it is mostly ok.
Ideally I will also mimick items and pawns and lights and shadows but it seems like it should be ok so I better prove other stuff first.
Step 2. Ship boundary detection (Done. Ship area is now connected together by any floors and walls)
Created basic selection overlay for ShipComputerCore to visualize ship area.
Decided to make first iteration of area to be Everything that is connected by walls or floors with the Core.
Wrote a recurrent algorithm for boundary detection and it works.
Right now floors-not floors is decided by having/not having a blueprint def in Terraindata. I did it because i wanted for mod to be as compatible as it can.
Step 3. Basic ship contents detection. (done)
Ship now correctly detects all flooring, walls, buildings, items, dirt and pawns inside without double detections. No roof detection yet.
I also overwrote gamend spacelaunch conditions so that ship can now search for needed parts on entire ship grid. Ideally it will require them to be powered.
Step 6. Basic worldmap/localmap landing area selection interface. (done)
Made a raw but working adaptation of user interface from compLaunchable.
Step 7. Basic Travelling Spaceship worldobject. (done)
Prepared mostly-empty but working "spaceship" that is created on launch, is visible on map, travels to destination, sends a message on arrival and is ready to be filled with shipgrid info and actions.
Section: This Map-> This Map transportation tests (via Travelling Spaceship worldobject)
Step 8. Floor transport. (done)
If launch was ordered from pause state... then some unknown... bad thing ( it brought me a lot of headache) tried to nullify flooring storage of a ship on unpause. Protected my ship storage by adding special setter which DOES NOT allow nullification... and now it seems to work... Yes, Rimworld is a dangerous place indeed.
...Maybe i can use the setter to catch this flooring thief ( like "oh... the value you want to set is null... Can you tell me your name, please?"), but I don't know how to do it yet.
Step 9. Item transport. (done)
Step 10. Building transport. (done)
There is a bug in game where simultaneous deletion of walls with doors inserted like X|-|-|X results in a bunch of errors. Was forced to invent a workaround for this. Now works without errors.
Step 11. Pawn transport.(Done. At least no bugs noticed yet.)
Used 40kInjector (see Acknowledgements).
Detoured Pawnsfinder.get_AllMapsCaravansAndTravelingTransportPods
Detoured PawnsUtility.IsTravelingInTransportPodWorldObject(Pawn pawn)
Now pawns in spaceships should be counted as pawns in droppods.
Step 12. Roof detection and transport.(done but no hanging outside roof detection yet. For number of reasons including potential problem avoidance and aerodynamical realism it is probable that it will remain this way.)
Step 13. Full destination selection interface with multicell checks based on ship area. (done)
Section: This Map-> Other Map transportation tests.
Step 14. Automatic landing area selection.(Seems to be working. It is random so hard to tell.)
Step 15. Attacking other bases. (Done. Well, at least it seems to work.)
There was a funny bug with generated map for some reason starting with null sections[] but putting MapDrawer.RegenerateEverythingNow() was enough to counter this.
There is only one deployment method at the moment and it is "at the edge".
I was experimenting mostly with small "spaceships" though and it looks like bigger ones should have much more trouble with finding place to land.
Don't know what to do with that for now. Maybe less limitations on where it is possible to land (right now for every cell of the ship it is similar to droppod except for it cannot punch through roofs) or an ability to crashland.
Step 16. Settling with spaceship. (done with cat sleeping on knees)
[Note] Keep in mind that animation is not really necessary for mod to add to gameplay.
If all animation efforts will fail I will just use default screenfader to white to hide the moment of launch. (I will put it there anyway till animation is done)
So when Step 16 is done I will call it a working prototype.
Section: Static ship illusion.
Step 1. Floors.
Step 2. Buildings.
Step 3. Items.
Step 4. Pawns.
Step 5. Takeoff and landing animations.
Step 6. Shadows and lighting.
Screenshots:
On this screenshot cyan "ship" outline is shown.
ShipComputerCore pretends that it is just wooden plancks and certainly not a modified core.
Landing site selection interface (on world map standard droppod interface is used.)
Abanqueiro was tired of short jumps that evil Houkime forced him to do over and over (and also from other colonists trying to catch his jumping cabin) and this time jumped much farther.
A few seconds before jump:
And after his multi game-hour flight:
Acknowledgements:
Detours (2 methods) in this mod are made using 40KInjector which is cpt. Ohu's convenient repack of CCL-team detouring methods. Injector was taken from his colossal mod Warhammer 40K Corruption. You can find it here:
https://ludeon.com/forums/index.php?topic=28422.msg286833#msg286833
Downloads:
A bit bugfixed GridTOL prototype is attached.
[attachment deleted by admin due to age]