static void Prefix(NPCBase npc, ref bool gotFood) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name, npc); inFunctionStockpile = npc.Colony.Stockpile; ColonyShopVisitTrackerHookOnVisit.npc = npc; }
static void Prefix(SortedList <ushort, int> __instance, int index, int val) { Stockpile stockpile = ColonyShopVisitTrackerHookOnVisit.inFunctionStockpile; if (stockpile == null) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name, "INVALID SOTKCPILE"); return; } if (stockpile.Owner == null) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name, "INVALID OWNER"); return; } DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name); int difference = __instance.GetValueAtIndex(index) - val; ushort type = __instance.GetKeyAtIndex(index); if (difference > 0) { InventoryStatistics.RemoveInventory(stockpile.Owner, type, difference); } else { InventoryStatistics.AddInventory(stockpile.Owner, type, -difference); } }
public static void RemoveInventory(Colony colony, ushort type, int amount) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name, "Type: " + type.ToString() + ", Amount: " + amount.ToString()); ColonyStatistics stats = Statistics.GetColonyStats(colony); TimedItemStatistics itemStats = stats.GetTimedItemStats(type); itemStats.RemoveInventory(amount); AddConsumerRemoveProducer(itemStats, ScientistJobSettingsHookOnNPCAtJob.npc, amount); AddConsumerRemoveProducer(itemStats, GuardJobSettingsHookShootAtTarget.npc, amount); AddConsumerRemoveProducer(itemStats, BlockFarmAreaJobHookOnNPCAtJob.npc, amount); AddConsumerRemoveProducer(itemStats, FarmAreaJobHookOnNPCAtJob.npc, amount); AddConsumerRemoveProducer(itemStats, BuilderBasicHookDoJob.npc, amount); AddConsumerRemoveProducer(itemStats, ColonyShopVisitTrackerHookOnVisit.npc, amount); AddConsumerRemoveProducer(itemStats, AbstractAreaJobHookOnNPCAtStockpile.npc, amount); if (ItemTypes.GetType(type).ColonyPointsMeal > 0) { itemStats.UseAsFood(amount); } if (RuleHookTryExecute.trading) { itemStats.TradeOut(amount); } }
static void Prefix(Stockpile __instance, ushort type, int amount) { if (amount <= 0 || type <= 0 || __instance.Owner == null) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name + ": INVALID"); return; } DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name); InventoryStatistics.AddInventory(__instance.Owner, type, amount); }
static void Postfix(Stockpile __instance, bool __result, ushort type, int amount, bool sendUpdate) { if (amount <= 0 || type <= 0 || __instance.Owner == null) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name + ": INVALID"); return; } if (__result) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name, __result); InventoryStatistics.RemoveInventory(__instance.Owner, type, amount); } else { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name, __result); } }
public static void Prefix(SortedList <ushort, int> __instance, int index, int amount) { Stockpile stockpile = ColonyShopVisitTrackerHookOnVisit.inFunctionStockpile; if (stockpile == null) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name, "INVALID SOTCKPILE"); return; } if (stockpile.Owner == null) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name, "INVALID OWNER"); return; } DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name); InventoryStatistics.RemoveInventory(stockpile.Owner, __instance.GetKeyAtIndex(index), amount); }
static void Postfix(Rule __instance, ref float tradePower) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name); trading = false; }
static void Postfix(AbstractAreaJob __instance, ref NPCBase.NPCState state) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name); npc = null; }
static void Postfix(BuilderBasic __instance, IIterationType iterationType, IAreaJob areaJob, ConstructionJobInstance job, ref NPCBase.NPCState state) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name); npc = null; }
static void Prefix(FarmAreaJob __instance, ref NPCBase.NPCState state) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name, __instance.NPC); npc = __instance.NPC; }
static void Postfix(GuardJobSettings __instance, GuardJobInstance instance, ref NPCBase.NPCState state) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name); npc = null; }
static void Postfix(ScientistJobSettingsHookOnNPCAtJob __instance, BlockJobInstance blockJobInstance, ref NPCBase.NPCState state) { DebugLog.Write(MethodBase.GetCurrentMethod().DeclaringType + "::" + MethodBase.GetCurrentMethod().Name); npc = null; }