Ludeon Forums

RimWorld => Releases => Mods => Outdated => Topic started by: Greep on March 30, 2017, 07:53:13 PM

Title: [A16] Less/More faction bases
Post by: Greep on March 30, 2017, 07:53:13 PM
Another mod request.  Below are three mods with preset values (too lazy to make one that reads from xml).  Unzip into mods folder

A)Minimal:  each faction has one base
B)Less: each faction has 1/3 bases
C) More: Each faction has 3x bases

Licence: Steal and upload for all I care, this is pretty tiny.  Link to this thread and/or a name crediting would be nice, though.

Source:

namespace LessBases
{
    [StaticConstructorOnStartup]
    internal class Main
    {
        static Main()
        {
            HarmonyInstance.Create("com.greep.rimworld.mod.variablebases").PatchAll(Assembly.GetExecutingAssembly());
        }
    }

    [HarmonyPatch(typeof(FactionGenerator))]
    [HarmonyPatch("GenerateFactionsIntoWorld")]
    class Patch
    {
        static void Prefix(ref string seedString)
        {
           
           Type type = typeof(FactionGenerator);
            FieldInfo info = type.GetField("FactionBasesPer100kTiles", BindingFlags.NonPublic | BindingFlags.Static);
            info.SetValue(null, new FloatRange(25f, 30f));
        }
    }
}

[attachment deleted by admin due to age]
Title: Re: [A16] Less/More faction bases
Post by: Spdskatr on March 30, 2017, 09:26:23 PM
Since you have Harmony, why not use Traverse? It's a lot faster and better than Reflection in many ways.

so like


static void Prefix(ref string seedString)
        {
            Traverse.Create(typeof(FactionGenerator)).Field("FactionBasesPer100kTiles").SetValue(new FloatRange(25f, 30f)); //No BindingFlags needed
        }


Also btw why do you have seedString in your method? It is optional and I don't see you using it :P
Title: Re: [A16] Less/More faction bases
Post by: Greep on March 30, 2017, 10:31:15 PM
Ah, well I just don't know all of harmony's uses yet.

As for the ref string, heh, cruft from a refactor where I gave up and modified the whole method.  Thought I was having issues modifying the variable because it was readonly, turns out I made a really stupid mistake instead.  Not going to bother ripping it out tho :P
Title: Re: [A16] Less/More faction bases
Post by: Dragoon on April 05, 2017, 10:57:48 AM
Sweet. I often found a crap ton of them and wished there were a bit fewer.
Title: Re: [A16] Less/More faction bases
Post by: Alex3Wood on April 22, 2017, 12:52:05 PM
Question, is it possible to make bases even more diffuse? Like this is supposed to be a RIMworld right? How many settlements could there be for other factions? Normal game it seems like there are just cities on an under developed world, nothing more. Really I wanna make them like 1/6th as populous as normal game.
Title: Re: [A16] Less/More faction bases
Post by: Greep on April 22, 2017, 04:34:43 PM
I'm still pretty new to modding, so it's three mods because at the time I didn't feel like learning how to make a dll that reads from XML.  If I were to add yet another mod for 1/6, it'd make sense to just roll them all up into one at that point and let the player set it in a file.  I may do that at some point, but I'm currently on a short mod break xD.

There's still the option of minimal right now, which has almost no faction bases.
Title: Re: [A16] Less/More faction bases
Post by: Alex3Wood on April 22, 2017, 11:57:14 PM
Ooo yeah I understand that, I was going to alter the modded file to make it even less if I could, but I dont know what I'm looking at so have no clue. But that idea of giving people the option of choosing sounds cool, but this will have to do for now!! Eitherway it helps my immersion by a lot.
Title: Re: [A16] Less/More faction bases
Post by: Sixdd on May 30, 2017, 07:08:58 AM
So I'm trying to learn some basics by updating this mod but I'm having no luck at all. I updated the libraries and I'm not getting any errors in Visual Studio but I can't for the life of me get it to do anything. Any help would be great.

EDIT: Nevermind, I figured out how to accomplish this in pure XML . I'll post it to the releases board in the next day or so if it works out as well as I hope it will.

EDIT: Ok, didn't figure it out.
Title: Re: [A16] Less/More faction bases
Post by: dwlatrel on June 03, 2017, 02:10:12 PM
hei Greep update  pls  :D