Getting a exeption

Started by MalGaron, September 20, 2018, 01:45:22 AM

Previous topic - Next topic

MalGaron

Hello, I recently starting making my first mode for rimworld, I have few things done, I made material called Azerite, you can mine it from ore veins,  and I wanted to see, if I can make it work as medicine, but every time I get this exeption:
JobDriver threw exception in initAction for pawn Rissa driver=JobDriver_TendPatient (toilIndex=6) driver.job=(TendPatient (Job_28425) A=Thing_Human553 B=Thing_Azerite200415) lastJobGiver=Verse.AI.ThinkNode_QueuedJob
System.InvalidCastException: Cannot cast from source type to destination type.
  at RimWorld.Toils_Tend+<FinalizeTend>c__AnonStorey2.<>m__0 () [0x00000] in <filename unknown>:0
  at Verse.AI.JobDriver.TryActuallyStartNextToil () [0x00000] in <filename unknown>:0
Verse.Log:Error(String, Boolean)
Verse.AI.JobUtility:TryStartErrorRecoverJob(Pawn, String, Exception, JobDriver)
Verse.AI.JobDriver:TryActuallyStartNextToil()
Verse.AI.JobDriver:ReadyForNextToil()
Verse.AI.JobDriver:DriverTick()
Verse.AI.Pawn_JobTracker:JobTrackerTick()
Verse.Pawn:Tick()
Verse.TickList:Tick()
Verse.TickManager:DoSingleTick()
Verse.TickManager:TickManagerUpdate()
Verse.Game:UpdatePlay()
Verse.Root_Play:Update(),
what I see there is that it cannot finish the "tending" to the pawn in question, but it never finishes, I'd love to learn why is that and fix this issue :)

Link to the mod if you wanna try it: https://www.dropbox.com/s/jzploewlxm7bfqe/Azerite.rar?dl=0 its nothing special yet and hardly finnished.
Thanks for any help in advance :)

jamaicancastle

The problem here is related to ThingClass. Classes are bundles of C# code and variables that define how particular objects in the game should act. Most things you see in the game belong to a class called, simply, Thing. Some of them have more complicated behavior, though, so they have a more specialized class. One of them is Medicine.

It so happens that the Medicine class is pretty much vestigial; most of the work it used to do is now taken up by stats, which are more flexible. However, the end step of the tending code still assumes that any medicine used will be of the Medicine class, and complains if it isn't. To fix this, add this to your Azerite XML:

<thingClass>Medicine</thingClass>