vegapnk / RJW-Genes

Rimworld Biotech Genes related to RJW
MIT License
33 stars 34 forks source link

living cumbucket Error #129

Closed 2d1tvvv closed 1 week ago

2d1tvvv commented 1 month ago

This error occurs when Licentia Labs is not present. Activating Licentia Labs ensures normal operation without any errors

Exception in JobDriver tick for pawn ABCDE driver=JobDriver_ProcessingCumbucket (toilIndex=0) driver.job=(ProcessCumbucket (Job_3726) A = (149, 0, 141))
System.TypeLoadException: Could not resolve type with token 010000f6 (from typeref, class/assembly LicentiaLabs.Licentia, LicentiaLabs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)
[Ref 46C5FB47]
 at Verse.AI.JobDriver.DriverTick () [0x001d2] in <f0ac5eb9b52e4cc396c70fc9a4ee15e5>:0 
     - TRANSPILER Krkr.RocketMan.Soyuz: IEnumerable`1 Soyuz.Patches.JobDriver_DriverTick_Patch:Transpiler(IEnumerable`1 instructions, ILGenerator generator)
     - TRANSPILER Orion.Hospitality: IEnumerable`1 Hospitality.Patches.JobDriver_Patch+DriverTick:Transpiler(IEnumerable`1 insts)
UnityEngine.StackTraceUtility:ExtractStackTrace ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Log.Error_Patch4 (string)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.AI.JobUtility.TryStartErrorRecoverJob_Patch1 (Verse.Pawn,string,System.Exception,Verse.AI.JobDriver)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.AI.JobDriver.DriverTick_Patch0 (Verse.AI.JobDriver)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.AI.Pawn_JobTracker.JobTrackerTick_Patch0 (Verse.AI.Pawn_JobTracker)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Pawn.Tick_Patch2 (Verse.Pawn)
Verse.TickList:Tick ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.TickManager.DoSingleTick_Patch5 (Verse.TickManager)
Verse.TickManager:TickManagerUpdate ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Game.UpdatePlay_Patch3 (Verse.Game)
Verse.Root_Play:Update ()
vegapnk commented 1 month ago

Thank you for your Report! This seems a bit odd, but I will look into it. It might be due to Rocketman (at least reading the message)

vegapnk commented 1 month ago

This is the relevant file, but it seems ok to me.

2d1tvvv commented 1 month ago

I opened the Rjw-Genes.dll file with dnSpy, made modifications with ChatGPT's help, and it seems to be working properly now.

using System;
using System.Collections.Generic;
using RimWorld;
using UnityEngine;
using Verse;
using Verse.AI;

namespace RJW_Genes
{
    // Token: 0x02000026 RID: 38
    internal class JobDriver_ProcessingCumbucket : JobDriver_Vomit
    {
        // Token: 0x06000067 RID: 103 RVA: 0x0000231E File Offset: 0x0000051E
        public override bool CanBeginNowWhileLyingDown()
        {
            return true;
        }

        // Token: 0x06000068 RID: 104 RVA: 0x00002321 File Offset: 0x00000521
        protected override IEnumerable<Toil> MakeNewToils()
        {
            if (!ModsConfig.IsActive("rjw.sexperience"))
            {
                yield break;
            }
            Toil toil = new Toil();
            toil.initAction = delegate()
            {
                this.ticksLeft = Rand.Range(150, 600);
                int num = 0;
                IntVec3 c;
                do
                {
                    c = this.pawn.Position + GenAdj.AdjacentCellsAndInside[Rand.Range(0, 9)];
                    num++;
                    if (num > 12)
                    {
                        goto IL_6B;
                    }
                }
                while (!c.InBounds(this.pawn.Map) || !c.Standable(this.pawn.Map));
                goto IL_77;
                IL_6B:
                c = this.pawn.Position;
                IL_77:
                this.job.targetA = c;
                this.pawn.pather.StopDead();
            };
            toil.tickAction = delegate()
            {
                if (this.ticksLeft % 150 == 149)
                {
                    if (!this.sourceName.NullOrEmpty())
                    {
                        if (ModsConfig.IsActive("LustLicentia.RJWLabs"))
                        {
                            FilthMaker.TryMakeFilth(this.job.targetA.Cell, base.Map, DefDatabase<ThingDef>.GetNamed("FilthCum", true), this.sourceName, 1, FilthSourceFlags.None);
                        }
                        this.SpawnCum(this.pawn, this.job.targetA.Cell, base.Map);
                    }
                    else
                    {
                        if (ModsConfig.IsActive("LustLicentia.RJWLabs"))
                        {
                            FilthMaker.TryMakeFilth(this.job.targetA.Cell, base.Map, DefDatabase<ThingDef>.GetNamed("FilthCum", true), 1, FilthSourceFlags.None, true);
                        }
                        this.SpawnCum(this.pawn, this.job.targetA.Cell, base.Map);
                    }
                }
                this.ticksLeft--;
                if (this.ticksLeft <= 0)
                {
                    base.ReadyForNextToil();
                    if (ModsConfig.IsActive("LustLicentia.RJWLabs"))
                    {
                        TaleRecorder.RecordTale(DefDatabase<TaleDef>.GetNamed("VomitedCum", true), new object[]
                        {
                            this.pawn
                        });
                    }
                }
            };
            toil.defaultCompleteMode = ToilCompleteMode.Never;
            toil.WithEffect(EffecterDefOf.Vomit, TargetIndex.A, new Color?(new Color(100f, 100f, 100f, 0.5f)));
            toil.PlaySustainerOrSound(() => SoundDefOf.Vomit, 1f);
            yield return toil;
            yield break;
        }

        // Token: 0x06000069 RID: 105 RVA: 0x000053A8 File Offset: 0x000035A8
        private void SpawnCum(Pawn pawn, IntVec3 cell, Map map)
        {
            ThingDef named = DefDatabase<ThingDef>.GetNamed("GatheredCum", true);
            Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.rjw_genes_filled_living_cumbucket, false);
            if (firstHediffOfDef == null)
            {
                ModLog.Warning(string.Format("{0} has the JobDriver_ProcessCumbucket but does not have the Hediff for filled cumbucket.", pawn));
                return;
            }
            if (firstHediffOfDef.Severity <= 10f)
            {
                Thing thing = ThingMaker.MakeThing(named, null);
                thing.Position = cell;
                int num = Math.Max(1, (int)((double)firstHediffOfDef.Severity * 1.5));
                num = Math.Min(num, 75);
                thing.stackCount = num;
                thing.SpawnSetup(map, false);
                firstHediffOfDef.Severity -= (float)(num / 50);
                return;
            }
            int num2;
            for (int i = Math.Max(1, (int)((double)firstHediffOfDef.Severity * 1.5)); i > 0; i -= num2)
            {
                Thing thing2 = ThingMaker.MakeThing(named, null);
                thing2.Position = cell;
                num2 = Math.Min(i, 75);
                thing2.stackCount = i;
                thing2.SpawnSetup(map, false);
                firstHediffOfDef.Severity -= (float)(num2 / 50);
            }
        }

        // Token: 0x04000034 RID: 52
        private int ticksLeft;

        // Token: 0x04000035 RID: 53
        public string sourceName;
    }
}
vegapnk commented 1 month ago

Thanks for further looking into things @2d1tvvv :)

You do not need to de-compile the RJW-Genes.dll, the code is open source 😅

It's a bit hard for me to follow the changes in the code due to de-compilation, but if you want you can open a pull request and then I can incorporate your fix for everyone 👍

vegapnk commented 1 month ago

(Just for documentation:)

I got another report about this in the Discord with the following Error Message:

Exception in JobDriver tick for pawn Bell driver=JobDriver_ProcessingCumbucket (toilIndex=0) driver.job=(ProcessCumbucket (Job_727284) A = (107, 0, 91))
System.TypeLoadException: Could not resolve type with token 010000f6 (from typeref, class/assembly LicentiaLabs.Licentia, LicentiaLabs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)
[Ref 46C5FB47] Duplicate stacktrace, see ref for original
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Warning (string)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.AI.JobUtility.TryStartErrorRecoverJob_Patch2 (Verse.Pawn,string,System.Exception,Verse.AI.JobDriver)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.AI.JobDriver.DriverTick_Patch0 (Verse.AI.JobDriver)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.AI.Pawn_JobTracker.JobTrackerTick_Patch0 (Verse.AI.Pawn_JobTracker)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Pawn.Tick_Patch4 (Verse.Pawn)
Verse.TickList:Tick ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.TickManager.DoSingleTick_Patch3 (Verse.TickManager)
Verse.TickManager:TickManagerUpdate ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Game.UpdatePlay_Patch3 (Verse.Game)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Root_Play.Update_Patch1 (Verse.Root_Play)
vegapnk commented 1 week ago

Closing this for now, #129 removed it preliminary and I will likely rework the filth-spawning once the Cumpilation is here.