public void OnNPCCraftedRecipe(IJob job, Recipe recipe, List <RecipeResult> result)
        {
            if (job == null || job.NPC == null || job.NPC.Colony == null)
            {
                return;
            }

            ColonyStatistics stats = GetColonyStats(job.NPC.Colony);

            if (recipe != null)
            {
                foreach (var item in recipe.Requirements)
                {
                    var itemStat = stats.GetTimedItemStats(item.Type);
                    itemStat.Consume(item.Amount);
                    itemStat.AddConsumer(job.NPC.ID);
                }
            }

            if (result != null)
            {
                foreach (var item in result)
                {
                    var itemStat = stats.GetTimedItemStats(item.Type);
                    itemStat.Produce(item.Amount);
                    itemStat.AddProducer(job.NPC.ID);
                }
            }
        }
        public static void RemoveInventory(Colony colony, ushort type, int amount)
        {
            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 (ColonyShopVisitTrackerHookOnVisit.isFood)
            {
                itemStats.UseAsFood(amount);
            }

            if (RuleHookTryExecute.trading)
            {
                itemStats.TradeOut(amount);
            }
        }
        public static void AddInventory(Colony colony, ushort type, int amount)
        {
            ColonyStatistics    stats     = Statistics.GetColonyStats(colony);
            TimedItemStatistics itemStats = stats.GetTimedItemStats(type);

            itemStats.AddInventory(amount);

            RemoveConsumerAddProducer(itemStats, ScientistJobSettingsHookOnNPCAtJob.npc, amount);
            RemoveConsumerAddProducer(itemStats, GuardJobSettingsHookShootAtTarget.npc, amount);
            RemoveConsumerAddProducer(itemStats, BlockFarmAreaJobHookOnNPCAtJob.npc, amount);
            RemoveConsumerAddProducer(itemStats, FarmAreaJobHookOnNPCAtJob.npc, amount);
            RemoveConsumerAddProducer(itemStats, BuilderBasicHookDoJob.npc, amount);
            RemoveConsumerAddProducer(itemStats, ColonyShopVisitTrackerHookOnVisit.npc, amount);
            RemoveConsumerAddProducer(itemStats, AbstractAreaJobHookOnNPCAtStockpile.npc, amount);

            if (ColonyShopVisitTrackerHookOnVisit.isFood)
            {
                // wonder if this gets ever called ? It shouldn't though
                itemStats.UseAsFood(-amount);
            }

            if (RuleHookTryExecute.trading)
            {
                itemStats.TradeIn(amount);
            }
        }
        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);
            }
        }
        public void OnNPCGathered(IJob job, Pipliz.Vector3Int pos, List <ItemTypes.ItemTypeDrops> items)
        {
            if (job == null || job.NPC == null || job.NPC.Colony == null || items == null)
            {
                return;
            }

            ColonyStatistics stats = GetColonyStats(job.NPC.Colony);

            foreach (var item in items)
            {
                var itemStat = stats.GetTimedItemStats(item.Type);
                itemStat.Produce(item.Amount);
                itemStat.AddProducer(job.NPC.ID);
            }
        }