Regen Terrain

Started by skullywag, November 14, 2014, 06:16:41 PM

Previous topic - Next topic

skullywag

Anyone know if its possible to regen a specific cell back to how the map originally had it. So where you place floors, remove said floor and have it back to the terrain it was before. Cant find anything in the terrain grid I can use.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Klitri

It's not legitimately possible, you'd have to make a mod that adds the vanilla floors to the construction list

Rikiki

Constructed floors are TerrainDef objects.
You could save a copy of the TerrainGrid at the new colony startup.
You then just need to get the value from this saved variable with
Find.MySavedTerrainGrid.TerrainAt(position)
... BUT, this might be a very big variable...

iame6162013

Quote from: Rikiki on December 14, 2014, 03:12:50 AM
Constructed floors are TerrainDef objects.
You could save a copy of the TerrainGrid at the new colony startup.
You then just need to get the value from this saved variable with
Find.MySavedTerrainGrid.TerrainAt(position)
... BUT, this might be a very big variable...
you could make it a saved file and read it, then it doesn't matter too much for how big it is.(while not using it.)
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Robert J. Hanlon: "Never attribute to malice that which is adequately explained by stupidity."

Kubouch

You can use fertilizer pump in case of dirt.

skullywag

This is for purple ivy when it eats flooring it currently turns it into dirt but was hoping to revert back to original terrain, but as Rikiki stated the storage for said things is rather large. Ill find a way.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

JuliaEllie

Quote from: skullywag on December 14, 2014, 09:28:08 AM
This is for purple ivy when it eats flooring it currently turns it into dirt but was hoping to revert back to original terrain, but as Rikiki stated the storage for said things is rather large. Ill find a way.

You could just add a "TerrainDef formerTerrain" to your purple ivy class and save the TerrainDef here before it changes the terrain. On its removal you just create the formerTerrain again. warning pseudo code incoming:


TerrainDef formerTerrain;
//save the terrain
override onSpawn()
{
this.formerTerrain = Find.TerrainGrid.TerrainAt(this.position);
}
//restore terrain
override onDestroyed()
{
Find.TerrainGrid.setTerain(this.position,this.formerTerrain);
}

Rikiki

Yep, that's the good solution! Only save the terrain def where needed. :)

skullywag

#8
THAT is literally what i did last night. Lol think being away from the code for a week cleared my mind. I picked it up and went.."oh i could just..*tap**tap**tap*....done". Thanks guys your pointing got me there though.

Edit - grahh no im an idiot. Tested my code and it doesnt work. The ivy doesnt change it, the player does. Player lays down concrete over soil, ivy comes along and eats concrete needs to turn it back into soil. No way i can get the pevious terraindef...

This is why floors need to be a thing and not a terrain (totally selfish)
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

RawCode

Its possible to regenerate sections of map to initial condition by reversing world generation methods.
Most layers are generated from single noise source called "elevation".
Simply checking cell vs "elevation" map allows to get nearly perfect result.

Second check for beach and third check for "lakes" (in case of player allowed to remove "lakes" by mod or other means).

Storing initial type is OK, but if you going to make "decaying" floors with saveload support, overhead from storing params of each cell inside save may cause issues on large maps.

If you really want this - i can explain step by step what classes to check, but there is no way to explain how fractal noise works, you must understand it on your own.

skullywag

I see where youre coming from Rawcode. I may just leave it as setting it to soil for now and approach this if it really feels wrong. The only issue will be of someone lays a floor over a non growable on terrain (eg stone) ill turn that into soil. Not a major issue really and deffo not worth this effort at this stage.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

RawCode

Modding is about process, not about result.
It does not really matters how "hard" and "time consuming" process is as long as you enjoy it.

Igabod

if it makes you feel better, in real life, plants create soil on otherwise non-growable land all the time. In many big cities around the world that have buildings which have been there a while, there is soil on the roof that wasn't put there by humans. Just dead leaves blowing onto the roof and getting caught then decomposing into soil. So the idea that a plant such as this one could turn cement into soil isn't that far fetched.

skullywag

Quote from: RawCode on December 15, 2014, 08:55:49 PM
Modding is about process, not about result.
It does not really matters how "hard" and "time consuming" process is as long as you enjoy it.

True, im an agile programmer by trade so i know how to point things up and manage my time to keep my velocity up. This is too big a job for me to take on and still deliver the other things i want to. Hence "not worth the effort". :)
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?