[Solved] Errors from updating a mod to Alpha 4F

Started by Argain, June 11, 2014, 08:42:33 AM

Previous topic - Next topic

Argain

I was trying to update my Rimrats mod from Alpha 3 to Alpha 4F, which was a very simple replacement of the 'using' statements in the assembly and a few minor changes to xml defs, but when I tried to run the updated assembly it started throwing odd errors:


Could not find a type named UI.ITab_Pawn_Thoughts

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

Could not find a type named UI.ITab_Pawn_Needs

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

Could not find a type named UI.ITab_Pawn_Prisoner

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

Could not find a type named UI.ITab_Pawn_Character

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

ArgumentNullException: Argument cannot be null.

Parameter name: key
  at System.Collections.Generic.Dictionary`2[System.Type,Verse.ITab].TryGetValue (System.Type key, Verse.ITab& value) [0x00000] in <filename unknown>:0

  at Verse.ITabManager.GetSharedInstance (System.Type tabType) [0x00000] in <filename unknown>:0

  at Verse.ThingDef.PostLoad () [0x00000] in <filename unknown>:0

  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)

  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0

  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0

  at Verse.XmlToItem.ItemFromXml[ThingDef] (System.Xml.XmlNode xmlRoot, Boolean doPostLoad) [0x00000] in <filename unknown>:0

  at Verse.XmlLoader+<AllGameItemsFromAsset>c__Iterator63`1[Verse.ThingDef].MoveNext () [0x00000] in <filename unknown>:0

  at Verse.ModDefSet`1[Verse.ThingDef].ReloadAllFromFiles () [0x00000] in <filename unknown>:0

  at Verse.Mod.ReloadAllContent () [0x00000] in <filename unknown>:0

  at Verse.LoadedModManager.LoadAllActiveMods () [0x00000] in <filename unknown>:0

  at Verse.PlayDataLoader.LoadAllPlayData () [0x00000] in <filename unknown>:0

  at VerseBase.Root.Start () [0x00000] in <filename unknown>:0

  at VerseBase.RootEntry.Start () [0x00000] in <filename unknown>:0


It's odd because my assmebly makes no references to the old 'UI' namespace, let alone any of the classes that are supposedly not being found... and as soon as I remove my mod from the folder, everything runs smoothly again  ???

Argain

Here's the complete assembly:

using System;
using System.Linq;
using System.Collections.Generic;

using UnityEngine;

namespace Verse.AI
{
    public class JobGiver_Curiosity : ThinkNode_JobGiver
    {
        public float searchRadius = 99999f;
        protected override Job TryGiveTerminalJob(Pawn pawn)
        {
            int num = 0;
            List<Building> allBuildings = Find.ListerBuildings.allBuildingsColonist;
            List<Building> allBuildingsColonistElect = new List<Building>();

            for (int i = 0; i < allBuildings.Count - 1; i++)
            {
                if (allBuildings[i].TransmitsPower)
                {
                    allBuildingsColonistElect.Add(allBuildings[i]);
                }
            }

            int count = allBuildingsColonistElect.Count - 1;
            if (count > 0)
            {
                float num2 = this.searchRadius * this.searchRadius;
                while (true)
                {
                    int index = UnityEngine.Random.Range(0, count);
                    Building building = allBuildingsColonistElect[index];
                    num++;
                    if (num > count)
                    {
                        break;
                    }
                    if (RimratBuildingTrashUtility.IsGoodTrashTargetFor(building, pawn))
                    {
                        if (this.searchRadius >= 9999f || (building.Position - pawn.Position).LengthHorizontalSquared <= num2)
                        {
                            return RimratBuildingTrashUtility.AttackJobOnFor(building, pawn);
                        }
                    }
                }
            }
            return null;
        }
    }

    public class ThinkNode_ConditionalRimrat : ThinkNode_Priority
    {
        public override JobPackage TryIssueJobPackage(Pawn pawn)
        {
            JobPackage result;
            int curious = UnityEngine.Random.Range(1, 1000);

            if (curious == 37)
            {
                List<Pawn> list = (
                    from p in Find.ListerPawns.AllPawns
                    where p.def.label == "Rimrat"
                    select p).ToList<Pawn>();

                if (list.Count > 0)
                {
                    pawn = list.RandomListElement<Pawn>();
                }
                result = base.TryIssueJobPackage(pawn);
            }
            else
            {
                return null;
            }
            return result;
        }
    }

    public static class RimratBuildingTrashUtility
    {
        private const int AttackJobTimeLimit = 1000;
        public static bool IsGoodTrashTargetFor(Building b, Pawn pawn)
        {
            return pawn.CanReach(b, PathMode.Touch);
        }
        public static Job AttackJobOnFor(Building b, Pawn pawn)
        {
            Job job = new Job(JobDefOf.AttackMelee, b);
            int timeLimit = UnityEngine.Random.Range(300, 3000);
            job.TimeLimit = timeLimit;
            return job;
        }
    }
}


Nothing about any 'UI' stuff in there... so yeah, I'm stumped.

ItchyFlea

#2
Those are all regarding the inspector tabs that will be held in an .xml file. In the Core mod, these are found in /Defs/ThingDefs/Races_Various.xml in the BasePawn thingdef. They will most likely be held in the .xml file you've got that defines the rimrat that will be in the /Defs/ThingDefs folder of your mod.
All my mods are licensed under a Attribution-NonCommercial-ShareAlike 4.0 International
Ask for permission before using in ModPacks

Click here for a list of the mods I've created

Argain

#3
Thanks! Got the UI errors all cleared up... just one left:
Quote
Could not load class AI.ThinkNode_ConditionalRimrat, RimratMod from node <thinkRoot Class="AI.ThinkNode_ConditionalRimrat, RimratMod"><subNodes><li Class="AI.ThinkNode_Priority"><subNodes><li Class="AI.JobGiver_Curiosity, RimratMod" /><li Class="AI.JobGiver_WanderAnywhere" /></subNodes></li></subNodes></thinkRoot>

NullReferenceException: Object reference not set to an instance of an object
  at Verse.ThinkTreeDef.PostLoad () [0x00000] in <filename unknown>:0

I know it's gotta have something to do with the .xml file again, specifically the SubThinkTree... but this is also stumping me. It's virtually identical to the way the Core is setup.

SubThinkTree_Rimrat.xml

<?xml version="1.0" encoding="utf-8" ?>
<ThinkTrees>

<ThinkTreeDef>
<defName>Curiosity</defName>
<thinkRoot Class="AI.ThinkNode_ConditionalRimrat, RimratMod">
<subNodes>
<li Class="AI.ThinkNode_Priority">
<subNodes>
<li Class="AI.JobGiver_Curiosity, RimratMod" />
<li Class="AI.JobGiver_WanderAnywhere" />
</subNodes>
</li>
</subNodes>
</thinkRoot>
</ThinkTreeDef>

</ThinkTrees>

Haplo

If you remove the ", Rimrats" parts, it should work.
Alpha 4 doesn't support the Assembly references anymore. But without them it should work.

Argain

*facepalms* yep, that was it! Thanks a ton  ;D