HELP PLEASE Restricting building areas [solved]

Started by jamieg, April 25, 2014, 09:26:50 PM

Previous topic - Next topic

jamieg

I'm having the hardest time with a sand pit... I have it working but not how i want, at the moment my people can create 10 bags of sand but it cost 1 metal and about 20-30 seconds, and you can place the sandpit anywhere.

I would like it so it can only be built on sand and so that it does not require anything to make except the time it take them to dig if you get me, I've been playing around with this loads, tried the whole restriction like with a geothermal on a steam geyser ect but im all out of ideas

SOMEONE PLEASE GET BACK TO ME ASAP WHILST MY INSPIRATION IS RUNNING WILD :D
YES! Its true! im updating The BIG BANG mod pack check it out here: https://www.youtube.com/watch?v=orzLZbECR20&list=UUr1sEPUEhFqy01q16zGisIg

ItchyFlea

<SurfaceNeeded> and <SurfacesSupported> are the tags you'll need to work with to restrict placement to just sand and nothing else. Unfortunately there isn't a surface type just for sand that isn't shared by the other terrain types. You'll need to create a separate one, probably with a .dll, and use that.

As for taking time but for free, keep the <WorkToBuild> tag but remove the <CostList> one.
All my mods are licensed under a Attribution-NonCommercial-ShareAlike 4.0 International
Ask for permission before using in ModPacks

Click here for a list of the mods I've created

jamieg

#2
Thank you once again Itchy!! I ow ya! Although i may need to hold for a few days or so on this as i am too nooby for dll at the moment and will need Zelldot to teach me
YES! Its true! im updating The BIG BANG mod pack check it out here: https://www.youtube.com/watch?v=orzLZbECR20&list=UUr1sEPUEhFqy01q16zGisIg

Kirid

I think your best bet would be <SurfaceNeeded> <li>Diggable</li> </SurfaceNeeded> That includes only sand, soil, rich soil, and gravel. Light includes alot more things like floors and stone.
I'm pretty nooby at dll editing atm also, but this idea doesn't seem too hard.
You can't rollerskate in a muffalo herd

WorldOfIllusion

You could try making a custom PlacementRestricter for it.

And then explain to me why mine don't work :P
Artistically challenged modder seeking artistically talented texturer's help. Please, please, PM me :)

jamieg

#5
Quote from: ItchyFlea on April 25, 2014, 09:44:58 PM

As for taking time but for free, keep the <WorkToBuild> tag but remove the <CostList> one.

I ment in the BagOfSand recipe when removing the resources required to make it, it causes the game to get very vibrant in colour when my pawns try to use it, then it crashes so i had to set it to cost 1 wood to make which bugs me :(
YES! Its true! im updating The BIG BANG mod pack check it out here: https://www.youtube.com/watch?v=orzLZbECR20&list=UUr1sEPUEhFqy01q16zGisIg

jamieg

#6
Quote from: Kirid on April 26, 2014, 02:27:05 AM
I think your best bet would be <SurfaceNeeded> <li>Diggable</li> </SurfaceNeeded> That includes only sand, soil, rich soil, and gravel. Light includes alot more things like floors and stone.
I'm pretty nooby at dll editing atm also, but this idea doesn't seem too hard.

Does ANYONE know of a replacment for Diggable in this that is for sand only? because this is almost spot on
YES! Its true! im updating The BIG BANG mod pack check it out here: https://www.youtube.com/watch?v=orzLZbECR20&list=UUr1sEPUEhFqy01q16zGisIg

Kirid

Not unless you define a new Surface Type.  Any, Light, Heavy, GrowSoil, Diggable, SmoothHard, SmoothableStone are the only types currently.
I'm looking at the SurfaceType dll right now trying to figure out how define a new one  ;) I'm not sure how to build class files into a dll.
You can't rollerskate in a muffalo herd

jamieg

Quote from: Kirid on April 26, 2014, 11:09:10 AM
Not unless you define a new Surface Type.  Any, Light, Heavy, GrowSoil, Diggable, SmoothHard, SmoothableStone are the only types currently.
I'm looking at the SurfaceType dll right now trying to figure out how define a new one  ;) I'm not sure how to build class files into a dll.

I think (as this is for our full conversions) that i will change steam geysers to something like Sink holes as an example and set the restrictions probs be the easier way.
YES! Its true! im updating The BIG BANG mod pack check it out here: https://www.youtube.com/watch?v=orzLZbECR20&list=UUr1sEPUEhFqy01q16zGisIg

ItchyFlea

Quote from: jamieg on April 26, 2014, 10:58:39 AM
I ment in the BagOfSand recipe when removing the resources required to make it, it causes the game to get very vibrant in colour when my pawns try to use it, then it crashes so i had to set it to cost 1 wood to make which bugs me :(
Ahh, I see.
A workaround would be to make it cost 1 of something, and have the recipe result include that something as well as the bag of sand.
All my mods are licensed under a Attribution-NonCommercial-ShareAlike 4.0 International
Ask for permission before using in ModPacks

Click here for a list of the mods I've created

jamieg

so it could cost 1 wood but you get it back with the bag of sand.... why didnt i think of this! ITCHY you genius :p
YES! Its true! im updating The BIG BANG mod pack check it out here: https://www.youtube.com/watch?v=orzLZbECR20&list=UUr1sEPUEhFqy01q16zGisIg

pawnstorm

Quote from: WorldOfIllusion on April 26, 2014, 07:17:23 AM
You could try making a custom PlacementRestricter for it.

And then explain to me why mine don't work :P
Show me yours, I'll show you mine :P

    public class PlacementRestricter_OnlyOne : PlacementRestricter
    {
        public override AcceptanceReport CanPlaceWithRestriction(EntityDef checkingDef, IntVec3 loc, IntRot rot)
        {
            if (Find.ListerBuildings.ColonistsHaveBuilding((ThingDef) checkingDef))
            {
                return new AcceptanceReport("Can only build one of those.");
            }
            return true;
        }
    }


You could probably make something like that which checks for sand too. Maybe using TerrainGrid.TerrainAt?

Cala13er

Since we're exposing Placement Restrictors, here's mine for the hydro plants of Industrial RIM. Just so people can learn from it :).


public class PlacementRestricter_NextToHydroAccepter : PlacementRestricter
{
public override AcceptanceReport CanPlaceWithRestriction(EntityDef Building, IntVec3 loc, IntRot rot)
{
foreach (IntVec3 current in GenAdj.AdjacentSquares8Way(loc))
{
foreach (Thing current2 in Find.get_Grids().ThingsAt(current))
{
ThingDef thingDef = ThingDef.Named("HydroPowerPlant");
ThingDef thingDef2 = ThingDef.Named("HydroPool");
ThingDef thingDef3 = ThingDef.Named("HydroAccelerator");
ThingDef thingDef4 = ThingDef.Named("HydroAdvancedTurbine");
if (current2.def == thingDef)
{
AcceptanceReport result = true;
return result;
}
if (current2.def == thingDef2)
{
AcceptanceReport result = true;
return result;
}
if (current2.def == thingDef3)
{
AcceptanceReport result = true;
return result;
}
if (current2.def == thingDef4)
{
AcceptanceReport result = true;
return result;
}
}
}
return "Must be placed next to a hydroplant, hydropool, hydroaccelerator or advancedhydroturbines";
}
}

Tynan

Not tested, but this should work.


public class PlacementRestricter_OnlyOnSand : PlacementRestricter
{
        public override AcceptanceReport CanPlaceWithRestriction(EntityDef checkingDef, IntVec3 loc, IntRot rot)
        {
            if( Find.TerrainGrid.TerrainAt( loc ) != TerrainDef.Named("Sand") )
               return "Can only place on sand."
            else
                return true;
        }
    }
Tynan Sylvester - @TynanSylvester - Tynan's Blog

Cala13er

Quote from: Tynan on April 27, 2014, 05:25:41 PM
Not tested, but this should work.


public class PlacementRestricter_OnlyOnSand : PlacementRestricter
{
        public override AcceptanceReport CanPlaceWithRestriction(EntityDef checkingDef, IntVec3 loc, IntRot rot)
        {
            if( Find.TerrainGrid.TerrainAt( loc ) != TerrainDef.Named("Sand") )
               return "Can only place on sand."
            else
                return true;
        }
    }


Oh, I thought someone had already resolved his problem.

Apart from that, +1 that code. Works fine.