[Resolved] Entirely new HediffComp/Properties not found in any loaded assembly

Started by JT, April 24, 2017, 10:13:39 AM

Previous topic - Next topic

JT

Yet another of my crazy difficult questions. =)

Has anyone been able to achieve success with creating an entirely new HediffComp_ from scratch, which inherits from HediffComp, rather than just re-using the existing HediffComps?  I'm attempting to create the following:


public class HediffComp_ReduceHediff : HediffComp
{
protected const int SeverityUpdateInterval = 200;

private HediffCompProperties_ReduceHediff Props {
get {
return (HediffCompProperties_ReduceHediff)this.props;
}
}

public override void CompPostTick() {
base.CompPostTick();
if (base.Pawn.IsHashIntervalTick(200)) {
float num = ReduceSeverityPerDay();
num *= (200f/60000f); //ticks per day
foreach(Hediff hediff in Pawn.health.hediffSet.hediffs) {
if(hediff.def == this.Props.hediffToReduce) {
hediff.Severity -= num;
}
}
}
}

protected virtual float ReduceSeverityPerDay() {
return this.Props.reduceSeverityPerDay;
}
}

public class HediffCompProperties_ReduceHediff : HediffCompProperties
{
public HediffDef hediffToReduce;
public float reduceSeverityPerDay = 1f;

public HediffCompProperties_ReduceHediff() {
this.compClass = typeof(HediffComp_ReduceHediff);
}
}


In other words, it's a slightly hacked variation of the conventional HediffComp_SeverityPerDay which decreases the severity of a different Hediff.  (I chose a reduction mainly because that would be the more likely use, but I'm considering renaming to ModifyHediff and requiring a negative severityPerDay to heal for consistency with SeverityPerDay.  But that's neither here nor there.)

The goal is to allow hediffs to reduce other hediffs gradually over time, allowing for mutually antagonistic hediffs which fight each other and cancel each other out and/or to allow pharmaceuticals which heal other hediffs slowly.

However, Rimworld seems completely unable to parse the definition; on load, errors are thrown that the XmlToObject reflection isn't capable of locating the class.  Naturally, of course, the properties fail to populate as well.

Could not find type named HediffCompProperties_ReduceHediff from node <li Class="HediffCompProperties_ReduceHediff"><hediffToReduce>WoundInfection</hediffToReduce><reduceSeverityPerDay>-0.25</reduceSeverityPerDay></li>
Verse.Log:Error(String)
Verse.XmlToObject:ClassTypeOf(XmlNode)
Verse.XmlToObject:ObjectFromXml(XmlNode, Boolean)
Verse.XmlToObject:ListFromXml(XmlNode)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.XmlToObject:ObjectFromXml(XmlNode, Boolean)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.XmlToObject:ObjectFromXml(XmlNode, Boolean)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.<AllDefsFromAsset>c__Iterator1EE:MoveNext()
Verse.ModContentPack:LoadDefs()
Verse.ModContentPack:ReloadAllContent()
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__735()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__733()


Building the assembly is of course successful, so is there something obvious I'm missing here?  Is there any special step I'm missing for permitting this class to parse properly?  I note, for instance, that there are zero problems with the newly added dismemberment/unanaesthetised amputation class in my field surgery mod, and I can't see any functional difference between a new hard-code recipe and a new hard-code healthdiff component...


[edit] I just thought of something fairly obvious... namespaces.  I'm gonna play around with it a bit. =P

[edit2] Yup, figures.  I have learned nothing.  Sigh...  Well, all fixed now, at least!