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 - Lockdown

#16
Help / Designator woes
August 27, 2016, 11:38:36 PM
I'm creating a couple of designators to mass forbid/unforbid blueprints, because drag-select is atrocious for it, as it'll prioritize selecting any resource or animal that happens to be over your blueprints.

I've used Designator_Claim as a base, and successfully edited it to the intended functionality. But, the forbid blueprint designator, in addition to being available from the Orders tab, also shows up when I select an individual blueprint, which is redundant, as the F button is already there for that. Is there a way to remove my designator from there, so it only appears in the Orders tab?

Designator class, if needed for reference:
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Verse;

namespace ForbidBlueprints
{
public class Designator_ForbidBlueprint : Designator
    {
        public override int DraggableDimensions
        {
            get
            {
                return 2;
            }
        }

        public Designator_ForbidBlueprint()
        {
            this.defaultLabel = "Forbid blueprints";
            this.defaultDesc = "Sets blueprints within area to forbidden";
            this.icon = ContentFinder<Texture2D>.Get("UI/Designators/Claim", true);
            this.soundDragSustain = SoundDefOf.DesignateDragStandard;
            this.soundDragChanged = SoundDefOf.DesignateDragStandardChanged;
            this.useMouseIcon = true;
            this.soundSucceeded = SoundDefOf.DesignateClaim;
            //this.hotKey = KeyBindingDefOf.Misc4;
        }

        public override AcceptanceReport CanDesignateCell(IntVec3 c)
        {
            if (!c.InBounds())
            {
                return false;
            }
            if (c.Fogged())
            {
                return false;
            }
            if (!(from t in c.GetThingList() where this.CanDesignateThing(t).Accepted select t).Any<Thing>())
            {
                return "Must designate blueprints.";
            }
            return true;
        }

        public override void DesignateSingleCell(IntVec3 c)
        {
            List<Thing> thingList = c.GetThingList();
            for (int i = 0; i < thingList.Count; i++)
            {
                if (this.CanDesignateThing(thingList[i]).Accepted)
                {
                    this.DesignateThing(thingList[i]);
                }
            }
        }

        public override AcceptanceReport CanDesignateThing(Thing t)
        {
            Blueprint blueprint = t as Blueprint;

            if (blueprint != null && blueprint.Faction == Faction.OfPlayer && blueprint.def.IsBlueprint)
            {
                return true;
            }
            return false;
        }

        public override void DesignateThing(Thing t)
        {
            if (ForbidUtility.IsForbidden(t, Faction.OfPlayer) == false)
            {
                ForbidUtility.SetForbidden(t, true, true);
            }
           
        }
    }
}
#17
Help / Re: Texture looks bad ingame
August 27, 2016, 11:38:13 AM
If your texture doesn't have mipmaps, or if you're reusing a core texture and are not rebuilding the mipmaps after making changes, it's going to look bad when you zoom in/out.
#18
General Discussion / Re: Question about steam release
August 27, 2016, 01:48:22 AM
Quote from: NolanSyKinsley on August 27, 2016, 01:37:27 AM

That would take a mod author being idiotic

People can make pretty stupid decisions, I've seen this happen with the patch beta builds of Stellaris. May not have happened to you yet but it's always a risk you're taking. You'll also run into problems when a mod is removed from the workshop, which is a somewhat common occurence. Overall, the Steam Workshop is a bit of a Russian roulette, and I only rely on it for multiplayer-only games where my mods need to be on the same version as the servers at all times anyway.
#19
General Discussion / Re: Question about steam release
August 27, 2016, 01:16:48 AM
Quote from: NolanSyKinsley on August 26, 2016, 01:27:12 PM
I really don't get why you have such a massive issue with the workshop, I have never had any problems with it. Provides the mods, easy to subscribe to and easy to remove. I quite enjoy it.

The problem with the Steam workshop is that it's too user-friendly. By automating the entire mod updating process, control is effectively removed from the player, which can often lead to broken games.

For example, let's say you're playing with mods on A14, and one of the mod authors decides to update to an unstable A15 branch, because he wanted to play with the new drugs. Your game will auto-update it without your consent, and your save is now bricked, with no way to downgrade to the previous version. Most you can do is preemptively make local backups of all your mods, but since you have to do that manually every time a mod updates, you may as well ditch the Steam workshop entirely and manage your mods manually for full control.
#20
Help / Re: Add item to ThingDefOf for spawning.
August 27, 2016, 12:07:32 AM
If I understand correctly, you want your mod to to spawn an item from another mod? The simplest way is probably to add the other mod as a library reference, like you've done for Assembly-CSharp.dll and UnityEngine.dll, which will allow your mod's class to reference the intended item directly. If you want to do it without a mod dependency, I don't know how to help, but CCL might have a way of making that happen.
#21
Help / Re: RimWorld core art source
August 25, 2016, 11:20:08 PM
Is it normal that the textures are all lumped up in a single directory? I've seen usages of ContentFinder<Texture2D>.Get() in the core code and it seems to indicate textures are organized inside folders (for example, "UI/Icons/Medical/NoCare"). So if I wanted to use, say, the Lavish texture with the Get() method, how would I find out what directory to use?

Edit: Seems like the paths are defined in the globalgamemanagers file, just have to search for the texture name and it'll list the full path to it.
#22
Help / Re: Adding a field to an existing core class
August 25, 2016, 11:06:22 PM
Wow, CCL is such a Swiss army knife, I love it. :D
#23
Help / Re: Adding a field to an existing core class
August 25, 2016, 09:52:49 PM
Well, bummer. So as suspected, I'll have to inject the thingComp into all the different animal defs, and if used together with another mod that adds more wildlife, a patch would be needed to include them.

Quote from: CallMeDio on August 25, 2016, 09:17:53 PM
In my opinion that post you linked should be a stick in the mod help forum,  I have a mod(unreleased) where I didn't defined the abstract, it works perfectly and don't cause problems to others but I will check it out for sure when I have time. Thanks 1000101

Yeah, same here. I made a couple XML mods for myself before I started tinkering with C#, and I had no idea it worked like that. I had assumed it was like Bethesda games where you can reference stuff from the base ESM instead of having to redefine it.
#24
Help / Re: Adding a field to an existing core class
August 25, 2016, 05:26:55 PM
Quote from: 1000101 on August 24, 2016, 04:26:46 AM
CCL has a ThingComp injector which you can use to inject your comp into the pawns.

From code you just need to use pawn.TryGetComp<MyCompClass>()

Thanks! I got the mod to work with a CCL-injected ThingComp, but only for humans so far. Seeing as I want pets to also have their food restricted by the selector, I thought of injecting the ThingComp into BasePawn instead of Human, so everything is covered. But I get an error if I do that. I'm guessing this might be because BasePawn is an abstract def, so is there any way to get around it or do I have to inject the thingComp into Human and every single non-abstract animal def?

This is the ModHelper.xml, if needed:
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<CommunityCoreLibrary.ModHelperDef>
<defName>RationControl</defName>
<ModName>RationControl</ModName>
<minCCLversion>0.14.0</minCCLversion>
<SpecialInjectors>
<li>RationControl.DetourInjector</li>
</SpecialInjectors>
<ThingComps>
<li>
<compProps>
<compClass>RationControl.RationControlThingComp</compClass>
</compProps>
<targetDefs>
<li>BasePawn</li>
</targetDefs>
</li>
</ThingComps>
</CommunityCoreLibrary.ModHelperDef>
</Defs>
#25
Help / Re: Adding a field to an existing core class
August 24, 2016, 02:07:25 AM
Well, I already finished doing it the bad way. ;D And yes, I realize the potential for clusterfuck caused by mods overwriting classes they have no business messing with, but as said earlier, the main goal here is learning; this is not a mod I intend to release, at least not until it's done the proper way.

Regarding ThingComps, I'm not sure what to do with the one I've made. I see pawns have a public List<ThingComp> that they inherit from their base class, which includes all the comps bound to them, and I assume this is how I access each individual pawn's ration setting that's stored in the ThingComp. But, not quite sure how to add my own comp to the list without detouring anything; perhaps via XML? But there doesn't seem to be any XML def that corresponds to Verse.Pawn, where I could bind the comp. In any case, I've only looked at it briefly so far, so I'm probably missing something major.
#26
Help / Re: Adding a field to an existing core class
August 23, 2016, 11:41:54 PM
Quote from: JaxelT on August 23, 2016, 08:44:36 PM
No, he means make a new class that inherits the old class, and detour the methods that create new instances of Pawn_PlayerSettings so they create instances of your class instead.

Oh, of course! Thanks for clarifying.

Quote from: 1000101 on August 23, 2016, 09:25:08 PM
Not sure what happened to your reply about ThingComps, but that is the best solution.

I deleted that reply. While I realize a ThingComp may suit the situation better, I was left with more questions than answers after looking into them, and decided to go with the inherited class option for the time being, as detours and manipulating core classes are mainly what I'm trying to get the hang of at the moment. I'll re-visit the ThingComp option once I have more time to go through it, but for the meantime I just wanted to make a functional mod out of the goal I set out for myself, even if it's not done the best way.
#27
Help / Re: Clothing Mods
August 23, 2016, 05:54:51 PM
Are your custom clothing items inheriting ApparelMakeableBase?
#28
Help / Re: Adding a field to an existing core class
August 23, 2016, 04:04:00 PM
Quote from: 1000101 on August 23, 2016, 01:25:53 PM
You'd have to inherit the existing class and detour all the methods which instantiate it so they instantiate your class instead.

For clarity, you mean the constructors, right? Those seem to require GetConstructor() instead of GetMethod(), so am I right in assuming I have to detour them manually instead of using CCL's TryDetourFromTo?
#29
Help / Adding a field to an existing core class
August 23, 2016, 12:45:12 PM
I'm making a mod that adds a food selector, similar to the medicine selector. Looking at how medicine is implemented, I would need to add an additional field to Pawn_PlayerSettings so that each pawn instance remembers their current food restriction. Given that it's not possible to detour the entire Pawn_PlayerSettings class in order to add an extra field, what would be the best option to add this functionality, while keeping compatibility with other mods in mind?
#30
Help / Re: Detour tutorial?
August 22, 2016, 11:16:25 AM
JaxelT, thank you so much for the detailed guide. It made me notice I was doing a bunch of things completely wrong without realizing it, and covered all the topics I was still confused about.