build/place on water [solved]

Started by sulusdacor, October 25, 2016, 06:18:14 PM

Previous topic - Next topic

sulusdacor

so what i wanted to do is make some kind of bride(thingdef building) and/or terraindef which can be placed on water. the optimal solution would be that it could be placed anywhere. so you can build a walkway from water into land.

was looking over the mods,that use some sort of placement on water and thought this would be possible with a placeworker only. since most of them used some sort of water only type thing, i started with the place on water only. my current placeworker was:
public class PlaceWorker_OnWater : PlaceWorker
{
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
{
TerrainDef named = DefDatabase<TerrainDef>.GetNamed("Mud", true);
TerrainDef named2 = DefDatabase<TerrainDef>.GetNamed("WaterShallow", true);
TerrainDef named3 = DefDatabase<TerrainDef>.GetNamed("WaterDeep", true);
if (Find.TerrainGrid.TerrainAt(loc) == named
    || Find.TerrainGrid.TerrainAt(loc) == named2
    || Find.TerrainGrid.TerrainAt(loc) == named3)
{
return AcceptanceReport.WasAccepted;
}
return new AcceptanceReport("Must be placed on water.");
}

with this version i got the report line on land placing, but on the waterterrain i got "This terrain cannot support this".
when i switched out the last new acceptanceReport... for the AcceptanceReport.WasAccepted line. i could place my buildingdef and terraindef both on all landtiles, where you could normaly place stuff. so basiclly one half of what i wanted. granted not the one i wanted this to make for in the first place^^.

so my thought process from this point, was that the water tiles are somewhat locked from the game side for where you can build. but could not find there place where you enable them for building. was looking in the core game assemblies, but dont really know where there. so i probaly looked in the wrong places. or do i need to make a new building class for this and placeworkers dont really work for this kind of thing? can i enable the watertiles for construction somehow? kind of cluess myself.

would really appreciate some help/directions where to look. total coding newbie so please be gentle ;)

the file is in the attachement. currently has two placeworkers. was playing around with the one from fishindustry, so dont wonder. work in progress.

[attachment deleted by admin due to age]

Project 06

I'm not exactly good with coding either but I'll throw in a guess to see if it fixes the issue. In the XML of terrain there are "affordances", theres are essentially what type of buildings that terrain can support. I've noticed that water and mud have no affordances. Upon trying to place a building onto a piece of terrain that does not support the building's affordance you get the error: "The terrain here cannot support this". It seems to me the only solution is that you would have to give shallow water, deep water, mud, and anything else you want to add, a affordance. However This would also cause any other building with that affordance to also be place-able on it.

Rock5

Is it possible to add an affordance that would only be applied to building that can be built on water?
Rock5 [B18] Mods
- Butchers Can Count Meat
- Sun Lamp Planner
- JTZoneButtons
- RimSearch
- JTExport

Project 06

Well i tried using to just modify vanilla water and add a affordance to it, just to see how it would work. When i built the structure on top of deepwater, no pawn could walk over it. The passability on this building is standable so it seems that the deepwater terrain overrides all pathing and will simply not allow movement over it. The only other method i could think of for "bridges" would be to have a custom flooring instead of thingDef. However after looking into this a bit it seems getting it so only one specific flooring can be placed over deepWater will be a hard task, on top of that you will have to modify vanilla water by changing the "changeable" flag to true.

sulusdacor

the thing with adding an affoderance for watertiles was one of my many thoughts. but i have no clue how to do it or know a mods, that does such thing, to give me an idea how this would be done.

the current process how mods do building on water in general is:

- place one part/tile/cell of the building on vanilla buildable ground and draw the rest over the non buildable water parts.
(like fish industry)

- add an totaly new terrain type, which looks like water, but which defname is not locked by the game. which requires playing with the map gen tho.
(like ocean biome mod)

i personly dont wanted to make a new biome or replace the vanilla water with my own terrain def, since some mods use these defnames. the idea was to make a walkway for the vanilla tiles, which could be easily placed. so you would not have to place it one at a time. so was wondering if there is a third option.

my workaround idea so far was to make my own terrain def. then make a building (placed like fishing pier on land + water tiles) which prepares one water tile for constructiuon by adding my own terrain def tile over the water after some time/work. then you would have a buildable tile to place a bridge. the problem i have with this: it would make the process very slow and much more complex then i would like for the player. the other thing would be, why not just "terrafrom" land if you add this process.

my plan was to just add more "work to make" to make up for the effort one would need to build on water. but you could easily place it and move around. so would like another option if someone has one, would otherwise probably try myself on the building to terraform thing.

Simulacrum0

<changeable>true</changeable> and you can build on it with affordances.
if passability is Impassable removeing any floor you build will turn to sand.

sulusdacor

oh okay,seems i missunderstood the whole affordance thing in the xml. didn't thought  this would be so easy. thx Siulacrum0.

sulusdacor

#7
okay so i felt like i got somewhere with the affordance thing. my process so far is overriding the vanilla watertiles were you can't build(shallow,deep,marsh) with the changeable to true and add my own affordance.. so the defnames are the same for other mods/vanilla to use them. this changed that all vanilla stuff is still the same, but i can build stuff on the custom terrainaffordance. so in general fine. problem is i still get an error, couse the game doesn't have my custom affordance in the TerrainAffordance list.

my thought was that i could simply add an assemblies in the namespace verse with the TerrainAffordance list from vanilla and just add my parts like this
namespace Verse
{

public enum TerrainAffordance : byte
{
Undefined,
Light,
Heavy,
GrowSoil,
Diggable,
SmoothHard,
SmoothableStone,
VanillaNotBuildableWater,
FundamentBase,
}

}

thought this would just "replace" the vanilla list. so googled a bit and seems you can't expand enum lists? so is this like a dead end? or can i just replace the vanilla TerrainAffordance somehow with my own list?

edit: added output log

[attachment deleted by admin due to age]

Simulacrum0

if all you want is a bride just make a new terrain def name it bride make it cost a lot take a long time to build add <terrainAffordanceNeeded>Light</terrainAffordanceNeeded>

sulusdacor

#9
the problem is that with using the terrain affordance light or others already used by the game, some vanilla buildings and buildings from mods would be buildable on the water, since they use these. since i have to add the affordance onto the vanilla water tiles to make this work. some buildings might be just buildable on water, which would be strange. and if i edit the vanilla building affordance, some might not be placeable on modded stuff. so i would like to avoid this.

Simulacrum0

affordance Undefined is not used in any vanilla defs use that one.

sulusdacor

i totaly missed that one *sinks in shame* -.-

thx so much.

Rock5

I would think that if you make some sort of platform on the water then you would be able to build on it.

Maybe if you built a light wooden platform then you would be able to built light buildings on it but if you made sturdier platforms, maybe with blocks, then it could handle heavy buildings. You could even have a lighter platform that only people can walk on but is too flimsy to hold any sort of building specifically used to make walkways..
Rock5 [B18] Mods
- Butchers Can Count Meat
- Sun Lamp Planner
- JTZoneButtons
- RimSearch
- JTExport