I just wrote an extension of CompPowerBattery for purposes of extending battery functionality, however I discovered a limitation in ThingDef.ConnectToPower. That Property checks that any Comp of that ThingDef is a CompPowerBattery; I propose allowing a sub-class of CompPowerBattery as well.
For my purposes, I've replaced that property getter with a harmony patch.
For my purposes, I've replaced that property getter with a harmony patch.
Code Select
static bool ConnectToPower_getter
{
if(this.EverTransmitsPower) {
return false;
}
for(int i = 0; i < this.comps.Count; i++) {
if(typeof(CompPowerBattery).IsAssignableFrom(this.comps[i].compClass)) {
return true;
}
if(typeof(CompPowerTrader).IsAssignableFrom(this.comps[i].compClass)) {
return true;
}
}
return false;
}