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

Topics - Nationality

#1
When I try to open the debug menu with my manually updated version of Psychology, I receive the following error.

Exception filling window for Verse.ImmediateWindow: System.TypeLoadException: Could not resolve type with token 010000de (from typeref, class/assembly EdB.PrepareCarefully.CustomPawn, EdBPrepareCarefully, Version=1.0.16.0, Culture=neutral, PublicKeyToken=null)
  at (wrapper managed-to-native) System.Reflection.MonoMethodInfo.get_method_info(intptr,System.Reflection.MonoMethodInfo&)
  at System.Reflection.MonoMethodInfo.GetMethodInfo (System.IntPtr handle) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0
  at System.Reflection.MonoMethod.GetPseudoCustomAttributes () [0x00002] in <567df3e0919241ba98db88bec4c6696f>:0
  at System.MonoCustomAttrs.GetPseudoCustomAttributes (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType) [0x0000a] in <567df3e0919241ba98db88bec4c6696f>:0
  at System.MonoCustomAttrs.GetCustomAttributesBase (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inheritedOnly) [0x0001f] in <567df3e0919241ba98db88bec4c6696f>:0
  at System.MonoCustomAttrs.GetCustomAttributes (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) [0x00037] in <567df3e0919241ba98db88bec4c6696f>:0
  at System.Reflection.MonoMethod.GetCustomAttributes (System.Type attributeType, System.Boolean inherit) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0
  at Verse.GenAttribute.TryGetAttribute[T] (System.Reflection.MemberInfo memberInfo, T& customAttribute) [0x00000] in <df50c46ef3c74cec81344c2206c0de6f>:0
  at Verse.Dialog_DebugActionsMenu..ctor () [0x0003e] in <df50c46ef3c74cec81344c2206c0de6f>:0
  at Verse.DebugWindowsOpener.ToggleDebugActionsMenu () [0x0001c] in <df50c46ef3c74cec81344c2206c0de6f>:0
  at (wrapper dynamic-method) Verse.DebugWindowsOpener.DMD<DMD<DrawButtons_Patch0>?-810289920::DrawButtons_Patch0>(Verse.DebugWindowsOpener)
  at Verse.ImmediateWindow.DoWindowContents (UnityEngine.Rect inRect) [0x00000] in <df50c46ef3c74cec81344c2206c0de6f>:0
  at Verse.Window.InnerWindowOnGUI (System.Int32 x) [0x00165] in <df50c46ef3c74cec81344c2206c0de6f>:0
Verse.Log:Error(String, Boolean)
Verse.Window:InnerWindowOnGUI(Int32)
UnityEngine.GUI:CallWindowDelegate(WindowFunction, Int32, Int32, GUISkin, Int32, Single, Single, GUIStyle)


The only mods I have loaded are Hugslib and the version of Psychology I am currently updating, not Prepare Carefully. So it seems there is something strange going on.
Attached is a copy of the mod.
I have deleted any reference to EdBPrepareCarefully in Psychology, but still it seems to want to load a reference to it.

You can download a copy of the mod in question from my google drive: https://drive.google.com/file/d/1WhDUvcU9dFr-v9zBScODb5F5f3bkKJlw/view?usp=sharing
#2
Help / Harmony transpiler plus GUI, need help!
February 21, 2020, 06:50:59 PM
Hi, I'm trying to update Psychology to 1.1. I'm getting better at C#, but I'm still not comfortable with either GUI coding or using Harmony's transpilers. Unfortunately, the issue I have currently relates to both. Here is the relevant code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using Verse;
using Verse.Sound;
using HarmonyLib;
using UnityEngine;
using System.Reflection;
using System.Reflection.Emit;

namespace Psychology.Harmony
{
    [HarmonyPatch(typeof(CharacterCardUtility), nameof(CharacterCardUtility.DrawCharacterCard))]
    public static class CharacterCardUtility_ButtonPatch
    {
        [HarmonyTranspiler]
        public static IEnumerable<CodeInstruction> AddPsycheDisplay(IEnumerable<CodeInstruction> instr, ILGenerator gen)
        {
            int doNames = 0;
            foreach(CodeInstruction itr in instr)
            {
                yield return itr;
                if (itr.opcode == OpCodes.Call && itr.operand == typeof(CharacterCardUtility).GetMethod(nameof(CharacterCardUtility.DoNameInputRect)))
                {
                    doNames++;
                    if (doNames == 3)
                    {
                        yield return new CodeInstruction(OpCodes.Ldloc_S, 6);
                        yield return new CodeInstruction(OpCodes.Ldarg_1);
                        yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(CharacterCardUtility_ButtonPatch), "PsycheCardButton", new Type[] { typeof(Rect), typeof(Pawn) }));
                       
                    }
                   
                }
            }
        }

        [LogPerformance]
        public static void PsycheCardButton(Rect panelRect, Pawn pawn)
        {
            if(PsycheHelper.PsychologyEnabled(pawn))
            {
                Rect rect = new Rect(panelRect.xMax + 5f, 3f, 22f, 22f);
                Color old = GUI.color;
                if (rect.Contains(Event.current.mousePosition))
                {
                    GUI.color = new Color(0.97647f, 0.97647f, 0.97647f);
                }
                else
                {
                    GUI.color = new Color(0.623529f, 0.623529f, 0.623529f);
                }
                GUI.DrawTexture(rect, ContentFinder<Texture2D>.Get("Buttons/ButtonPsyche", true));
                if (Widgets.ButtonInvisible(rect, false))
                {
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                    Find.WindowStack.Add(new Dialog_ViewPsyche(pawn));
                }
                GUI.color = old;
            }
        }
    }
}


Currently, the character card draws the psyche button over the third name input rectangle, making it unclickable.
I think that the psyche button is being drawn before the third name input rectangle, though I'm very new to how GUIs and transpilers work.
#3
Unfinished / (WIP) Gradual Romance
November 26, 2019, 06:00:57 PM
NEW UPDATE 17/12, see latest changelog in thread.

Hi, I've been silently working on this mod for a little while now - without writing an essay, it's a total overhaul of how romantic relationships work in Rimworld. I've tested it with a bunch of mods and it seems reasonably functional right now. However, I'm an amateur coder, and this is my first major mod ever, so it probably could use the eyes of people who are more experienced. It definitely needs more work, with a few missing planned features.

FEATURES --
* Adds four new relationship stages (Lovebuddy, Sweetheart, Paramour, Boyfriend/Girlfriend).
* Adds a flirt mechanic, sort of like RomanceAttempt, but less risky if you fail. Pawns are encouraged to try romance attempts after successful flirts, and discouraged by bad ones. Each flirt has entertaining, flavorful descriptions based on the Pawn's traits and personality.
* Adds an "ask to move in" interaction
* Changes everything about how romantic attraction works, and gives hints on what pawns like/dislike about each other every time they flirt/romance. Greedy colonists, as an example, prefer colonists with really nice bedrooms. In addition, it is much easier to add new attraction factors and exposes a lot of functionality in the Defs.
* Supports alien races and autopatches them to be compatible.
* Requires Psychology by The Word Mule. (Most likely incompatible with Rational Romance)

PLANNED FEATURES --
* More depth to ongoing relationships and breakups, such as quarreling.
* Secret affairs.
* Lovin' outside of bed.
* Crushes, romantic rivalries, obsessions, and other fun stuff.

I will be pretty busy for the next few days, which is why I wanted to post this now, so I can get some feedback, so I apologize if I don't respond immediately.

https://github.com/NationalityNZ/Gradual_Romance-Rimworld-mod