Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Mari

#1
Help / Changing the layers for rendering apparel
July 08, 2017, 11:39:32 PM
Heya,

I was wondering how I might go about adding/changing layers for clothing. As of now, Rimworld has 5 layers defined in ApparelLayer:

OnSkin,
Middle,
Shell,
Belt,
Overhead

These are a bit random and not very useful, especially when you get a lot of mods adding things to different layers. What I want to do is reclassify the layers to something more reasonable, such as the following:

Naked Body > Onskin/Underwear > Shirts > Pants > Jackets > Head Graphic > Hair > Hats > Accessories (jewelry, scarves, belts, etc)

The purpose would be ultimately for integrating it with prepare carefully so that you could dress up your pawns in a more more reasonable and intuitive way without conflicts that make no sense, plus add a lot more fashionable accessories and variety of clothing items. As of now, for example, there are a lot pants that for some reason can't be worn over certain bottom clothing, or conflict with tops which are on the same layer, while meanwhile you can wear pants under your pants because some pants are classified as pants while some are middle clothing, and on top of that skirts are shell clothing so you can wear a skirt over your two pairs of pants but not with a jacket.

I imagine it isn't as simple as just changing it in ApparelLayer, do I have to override, say, PawnRender.RenderPawnInternal? With my mediocre understanding of the Rimworld codebase and C# in general, I can't work out what's going on in that method at all. Are there any other places where it would need to be updated (opening up some massive can of worms to be untangled)? Patching the clothes themselves to follow the new structure should be trivially easy, and I'm pretty confident I can figure out how to patch prepare carefully, but last time I made one of these dll mods back in a14 I spent like 3 days just trying to trace back the entire structure of how Rimworld runs and what classes do what so I could figure out where I need to actually make a change, so I'd like to avoid that this time around. Thanks for any info that might help me out!
#2
Outdated / Re: [A14]Bodytypes Config (v1.0)
August 14, 2016, 07:04:11 AM
Quote from: kaptain_kavern on August 14, 2016, 05:39:58 AM
Looks awesome.
Congratz on the great job

Thank you, I made it for myself but I hope people like it :>
#3
Outdated / [A14]Bodytypes Config (v1.0.1)
August 14, 2016, 05:08:06 AM
Bodytypes Config
Author: Mari
Powered By

Have you ever been annoyed that despite doing hard labor on a daily basis, your colonists are still 300 pounds overweight, found it unrealistic that your female colonists are built like the Incredible Hulk, or tried to make a custom colonist but the backstory you wanted came packaged with a bodytype that completely clashed with the character you had in mind? I know I have. If so, this is the mod for you! Bodytypes Config adds a custom configuration menu to the game that allows you to replace the bodytypes of your colonists globally or on a single backstory basis.


Features:

--Replace the bodytype of all pawns of a specific bodytype-gender combination. For example, you can choose to set all female pawns that would spawn with the Hulk bodytype to spawn instead with the Female bodytype. You can even set all male pawns to spawn with Female bodies or vice versa, if that's what you're into. (Male bodies are a good alternative to Hulk for female pawns with a slightly more muscular build).

--Replace the bodytype of each backstory on an individual basis for male and female pawns. These settings will be applied AFTER the general settings, meaning if you want all Fat pawns to appear as Thin, except for the Midworld Chef, you can do that. Combining the two settings you can get almost full control over the bodytypes of your colonists.

--In-game config menu using CCL's ModConfigurationMenus. This means you can change your settings without a restart and they will save between sessions. You can also manually configure the settings via an xml file in the same folder as your RimWorld saves directory, if for some reason you wanted to do that.


Required:

--The Community Core Library is required for this mod to function. It must be installed and loaded BEFORE this mod.


Known Issues:

--At the moment, certain preset pawns/name in the game colonists (as well as their hardcoded backstories) cannot be altered, and I have no idea how to fix this. You will occasionally see these colonists in your games despite them breaking the bodytype rules you have enabled. If anyone knows where these pawns are defined in the code or how to mod them please let me know and I'll try to patch it.

--Bodytypes cannot be edited on a per pawn basis (for example with Prepare Carefully). Bodytype is hardcoded to backstory, and therefore it may be impossible for this to ever happen.


Compatibility:

--Other backstory mods: Unfortunately at this time they are not compatible for the most part, however they will not break the game, the added backstories will simply not be available. Partially compatible as of 1.0.1, the additional backstories will appear in game and you shouldn't get any errors, however they will NOT have their associated bodytypes replaced at this time. You can edit them manually though in that mod's BackstoryDefs folder. You should load these mods BEFORE this mod and EdB Prepare Carefully.

--Clothing mods: Work fine.

--EdB Prepare Carefully: Works for the most part, and is highly recommended. However, Prepare Carefully lets you access several backstories related to special or name in game pawns. As previously mentioned, these cannot be modified and may break your configured rules. As a rule of thumb, if it isn't in the "Choose a backstory..." menu on the Bodytypes config menu, it cannot be changed.

--Savegames: In most cases should be fully compatible, and will even change your existing colonists. Yay!


Planned updates:

--Fix the issues with special and name in game pawns

--Add compatibility for additional backstory mods which use CCL's BackstoryDefs

--Attempt to hack a way to configure bodytypes for your individual pawns, for integration with EdB (Potentially impossible, but I have a few ideas)

--Possibly add a framework to mod in additional bodytypes beyond the vanilla ones? (Potentially impossible)

--Make the config menu less hideous


Installation and Download:

--Direct download: http://puu.sh/qBuaG/f0f33e98ed.zip
--Steam workshop: http://steamcommunity.com/sharedfiles/filedetails/?id=743764089

--To install, unzip to your mods folder. Make sure CCL is loaded before this mod.


Updates:

Quote--Aug. 14, updated to 1.0.1;
        --Fixed minor bug where some pawns would spawn with Undefined bodytypes.
        --Added partial compatibility with BackstoryDef mods.


License:

--Feel free to do whatever you want with it or use it as a basis for your own mods. I will post the source code whenever I stop being too lazy to make a github page.


For any bugs, questions, comments, or suggestions, please comment below! I am more active on steam than here though so, if you want a quick reply that's the best place.
#4
Help / Re: CCL ModConfigurationMenu dropdown list?
August 12, 2016, 01:00:31 AM
Quote from: 1000101 on August 11, 2016, 09:07:35 PM
Are you perhaps using an A13 version?

I don't think so, I never had downloaded it before A14, and it says AssemblyVersion("0.14.0.0") in the dll. Though trying it without reflection does seem to compile. The code in MCM_MiniMap is

Listing_Standard listing_Standard = new Listing_Standard(rect);
listing_Standard.set_ColumnWidth(rect.width - 4f);
string text = Translator.Translate("MiniMap.MCMToggleMain");
listing_Standard.CheckboxLabeled(text, ref MiniMapController.visible, null);
listing_Standard.Gap(12f);


and it uses .get_ColumnWidth and .get_CurHeight several times. Perhaps I do somehow have an outdated version though.

Edit: it seems you are on v14.2 now, the version in the github repository does not use reflection, so that must have been my problem. Thanks
#5
Help / Re: CCL ModConfigurationMenu dropdown list?
August 11, 2016, 05:00:29 PM
I see. Then my question is, I tried to just copy the Minimap MCM code and then adjust it, but the listing_standard.set_ColumnWidth doesn't compile. It does not recognize set_ColumnWidth as valid. Why wouldn't that work?
#6
Help / Re: CCL ModConfigurationMenu dropdown list?
August 11, 2016, 04:09:04 PM
Yeah, I figured as much. A button with float menu is fine then, but I can't figure out how to make it draw. For some reason ButtonText returns a bool? and every implementation of it seems to use if (Widgets.ButtonText(...)) but when I do that it doesn't seem to actually spawn a button. I can get labels to appear but not buttons. How would I go about creating one?
#7
Help / CCL ModConfigurationMenu dropdown list?
August 11, 2016, 06:36:47 AM
Hello,

I am trying to work out the MCMs in CCL, and I am wondering if there is a way to include dropdown selection menus in it. I've been trying to mess around with it but my c# experience is pretty limited so setting up UI stuff is really confusing to me. What I am thinking of is something like:

http://puu.sh/qxnSA/f88f9c4a3c.png

where there are several settings, each with 6~ possible values in a dropdown menu, and also an additional pair of dropdowns at the bottom, one containing a list of a ton of specific settings and one with the possible values (the same possibilities for all of them). Selecting an item in the dropdown list would set the value of that setting to whatever was selected. I have been looking through a lot of the example code and other mods I could find which use the MCM, but I couldn't find any using dropdown menus. Failing that, a button which opens a FloatMenu, like in the main game config menu for temperature settings for example, would work just as well for the most part, but I also haven't seen one of those. If anyone has any idea and can help, I would appreciate it!

Thanks!
#8
Help / Re: Help with body mod
August 08, 2016, 06:23:02 AM
Shockingly, I actually managed to make it work by using a special injector and then calling the method from the injector itself since it seems that method runs before CCL special injectors in the loading process? Thanks for posting that reference robotguy!

If anyone ever is searching for something similar and finds this thread, I used two classes. The first one uses SpecialInjector to override and call the backstory loading method on startup:

using CommunityCoreLibrary;
using System;
using RimWorld;

namespace FemaleBodyTypes
{
public class DetourInjector : SpecialInjector
{
public override bool Inject() {
System.Reflection.MethodInfo method = typeof(BackstoryDatabase).GetMethod("ReloadAllBackstories", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
System.Reflection.MethodInfo method2 = typeof(FemaleBodyTypes).GetMethod("ReplaceBodyTypes", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
Detours.TryDetourFromTo(method, method2);
BackstoryDatabase.Clear();
BackstoryDatabase.ReloadAllBackstories();
return true;
}
}
}


and the second one contains the code to rebuild the dictionary of backstories:

using System;
using Verse;
using RimWorld;
using CommunityCoreLibrary;

namespace FemaleBodyTypes
{
public static class FemaleBodyTypes {

public static void ReplaceBodyTypes() {

foreach (Backstory current in XmlLoader.LoadXmlDataInResourcesFolder<Backstory>("Backstories/Shuffled"))
{
current.PostLoad();
current.ResolveReferences();

if (current.bodyTypeFemale == BodyType.Hulk) {
current.bodyTypeFemale = BodyType.Male;
}
if (current.bodyTypeFemale == BodyType.Fat) {
current.bodyTypeFemale = BodyType.Thin;
}
foreach (string current2 in current.ConfigErrors(false))
{
Log.Error(current.title + ": " + current2);
}
BackstoryDatabase.AddBackstory(current);
}
SolidBioDatabase.LoadAllBios();
}
}
}


In principle it seems like that method could be used to mod other aspects of the hardcoded default backstories like their stats or which types of work are allowed, or remove some completely based on title or id if you wanted. In any case, I will get working on a more generalized configurable version now, maybe with CCL mod config menus, I'll post it here and on steam when it's finished.

Edit: finished the mod: https://ludeon.com/forums/index.php?topic=24173.0
#9
Help / Re: Help with body mod
August 08, 2016, 05:09:04 AM
Quote from: robotguy4 on August 08, 2016, 03:39:38 AM
While I can't be much help, I suggest you ultimately make your mod have more options in terms of what body types to block.

A mod that just blocks just one type isn't going to be very useful to many people. One that can block specified ones would be useful to many people.

Thanks! I plan to make a more useful version once I get the basic thing working. I just wanted to try making it for my personal use as a challenge but assuming it actually is possible to do this at all, it'll be much easier to generalize that into something more useful once I understand how it actually works. I have definitely seen a few people asking for something like that so if I can figure it out I'd be happy to try to make a configurable version.

I will try looking at that code you linked, it might help if I mess around with it a bit. It looks like that modder overwrote the SpecialInjector class in CCL, I can try doing that instead for a start.
#10
Help / Help with body mod
August 08, 2016, 12:01:26 AM
Hello,

I didn't like my female colonists having the larger body types, so I tried to make a mod addressing this. I read on the forums that the body types are hardcoded based on the backstories, but I thought it might be possible. I (perhaps obviously) have very little experience with C# but my idea was basically to detour with CCL the method that loads in the backstories and then replace the body types before adding them to the dictionary, but for some reason it won't work the way I have it written. I suspect I am doing something obviously wrong, or it may just be impossible.

Here is my code:

using System;
using Verse;
using RimWorld;
using CommunityCoreLibrary;

namespace FemaleBodyTypes
{
[StaticConstructorOnStartup]
public class FemaleBodyTypes {

public FemaleBodyTypes() {
System.Reflection.MethodInfo method = typeof(BackstoryDatabase).GetMethod("ReloadAllBackstories", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
System.Reflection.MethodInfo method2 = typeof(FemaleBodyTypes).GetMethod("ReplaceBodyTypes", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
Detours.TryDetourFromTo(method, method2);
}

public static void ReplaceBodyTypes() {

foreach (Backstory current in XmlLoader.LoadXmlDataInResourcesFolder<Backstory>("Backstories/Shuffled"))
{
current.PostLoad();
current.ResolveReferences();

if (current.bodyTypeFemale == BodyType.Hulk) {
current.bodyTypeFemale = BodyType.Female;
}
if (current.bodyTypeFemale == BodyType.Fat) {
current.bodyTypeFemale = BodyType.Thin;
}
foreach (string current2 in current.ConfigErrors(false))
{
Log.Error(current.title + ": " + current2);
}
BackstoryDatabase.AddBackstory(current);
}
SolidBioDatabase.LoadAllBios();
}
}
}


My idea was to detour the method that builds the backstory dictionary in the constructor of my class to a method that is basically identical except having a couple extra if statements to replace the body types as they are read in. It seems like the constructor is never even being called though, so I am clearly in over my depth. Maybe there is something really obvious I am doing wrong, so I was hoping someone with more C# experience and knowledge of the game code could help me.

Thanks a lot!