// After spawning a natural organ, set its origin to that of the pawn it was extracted from. public static void Postfix(Thing __result, Pawn pawn) { // Try to get our organ origin. CompOrganOrigin organOrigin = __result.TryGetComp <CompOrganOrigin>(); // Does our organ origin exist? if (organOrigin != null) { // Set the origin def of our organ to the pawn's def. organOrigin.originDef = pawn.def; } }
private bool MyTryGetFactor(StatRequest req, out float factor) { // Get our organ origin comp, if possible. CompOrganOrigin organOrgin = req.Thing?.TryGetComp <CompOrganOrigin>(); if (organOrgin != null) { // Normalize against human market value (most animals are worth less than humans). factor = organOrgin.originDef.BaseMarketValue / ThingDefOf.Human.BaseMarketValue; return(true); } // Default case if no thing or comp. factor = 1f; return(false); }
// Restrict natural organ installations to whose where the organ's origin matches the patient. public static bool Postfix(bool __result, Bill __instance, Thing thing) { // If if the result was already false nothing we're going to do here will change that so just quit now. if (!__result) { return(false); } // Try to get our organ origin. CompOrganOrigin organOrgin = thing.TryGetComp <CompOrganOrigin>(); // Does our organ origin exist? if (organOrgin != null) { // Is our bill giver (patient) a pawn and the recipe a natural part installation? if ((__instance.billStack.billGiver is Pawn patient) && (__instance.recipe.Worker is Recipe_InstallNaturalBodyPart)) { // Return whether our origin origin def is the same as our patient. return(organOrgin.originDef == patient.def); } } // Default return original result. return(__result); }
public override bool AllowStackWith(Thing other) { CompOrganOrigin otherComp = other.TryGetComp <CompOrganOrigin>(); return((otherComp != null) && (otherComp.originDef == originDef)); }