private void OnMassConsumed(Sim.MassConsumedCallback mcd) { if (IsRunning()) { if (mcd.mass > 0f) { massUnavailableFrameCount = 0; Diet.Info dietInfo = base.def.diet.GetDietInfo(targetElement.tag); if (dietInfo != null) { float calories = dietInfo.ConvertConsumptionMassToCalories(mcd.mass); CreatureCalorieMonitor.CaloriesConsumedEvent caloriesConsumedEvent = default(CreatureCalorieMonitor.CaloriesConsumedEvent); caloriesConsumedEvent.tag = targetElement.tag; caloriesConsumedEvent.calories = calories; CreatureCalorieMonitor.CaloriesConsumedEvent caloriesConsumedEvent2 = caloriesConsumedEvent; Trigger(-2038961714, caloriesConsumedEvent2); } } else { massUnavailableFrameCount++; if (massUnavailableFrameCount >= 2) { Trigger(801383139, null); } } } }
public static GameObject CreateMoo(string id, string name, string desc, string anim_file, bool is_baby) { GameObject gameObject = BaseMooConfig.BaseMoo(id, name, CREATURES.SPECIES.MOO.DESC, "MooBaseTrait", anim_file, is_baby, null); EntityTemplates.ExtendEntityToWildCreature(gameObject, MooTuning.PEN_SIZE_PER_CREATURE, 75f); Trait trait = Db.Get().CreateTrait("MooBaseTrait", name, name, null, false, null, true, true); trait.Add(new AttributeModifier(Db.Get().Amounts.Calories.maxAttribute.Id, MooTuning.STANDARD_STOMACH_SIZE, name, false, false, true)); trait.Add(new AttributeModifier(Db.Get().Amounts.Calories.deltaAttribute.Id, (0f - MooTuning.STANDARD_CALORIES_PER_CYCLE) / 600f, name, false, false, true)); trait.Add(new AttributeModifier(Db.Get().Amounts.HitPoints.maxAttribute.Id, 25f, name, false, false, true)); trait.Add(new AttributeModifier(Db.Get().Amounts.Age.maxAttribute.Id, 75f, name, false, false, true)); HashSet <Tag> hashSet = new HashSet <Tag>(); hashSet.Add("GasGrass".ToTag()); Diet.Info[] infos = new Diet.Info[1] { new Diet.Info(hashSet, POOP_ELEMENT, CALORIES_PER_DAY_OF_PLANT_EATEN, KG_POOP_PER_DAY_OF_PLANT, null, 0f, false, false) }; Diet diet = new Diet(infos); CreatureCalorieMonitor.Def def = gameObject.AddOrGetDef <CreatureCalorieMonitor.Def>(); def.diet = diet; def.minPoopSizeInCalories = MIN_POOP_SIZE_IN_CALORIES; SolidConsumerMonitor.Def def2 = gameObject.AddOrGetDef <SolidConsumerMonitor.Def>(); def2.diet = diet; return(gameObject); }
public static GameObject CreateDrecko(string id, string name, string desc, string anim_file, bool is_baby) { GameObject prefab = BaseDreckoConfig.BaseDrecko(id, name, desc, anim_file, "DreckoBaseTrait", is_baby, "fbr_", 308.15f, 363.15f); prefab = EntityTemplates.ExtendEntityToWildCreature(prefab, DreckoTuning.PEN_SIZE_PER_CREATURE, 150f); Trait trait = Db.Get().CreateTrait("DreckoBaseTrait", name, name, null, false, null, true, true); trait.Add(new AttributeModifier(Db.Get().Amounts.Calories.maxAttribute.Id, DreckoTuning.STANDARD_STOMACH_SIZE, name, false, false, true)); trait.Add(new AttributeModifier(Db.Get().Amounts.Calories.deltaAttribute.Id, (0f - DreckoTuning.STANDARD_CALORIES_PER_CYCLE) / 600f, name, false, false, true)); trait.Add(new AttributeModifier(Db.Get().Amounts.HitPoints.maxAttribute.Id, 25f, name, false, false, true)); trait.Add(new AttributeModifier(Db.Get().Amounts.Age.maxAttribute.Id, 150f, name, false, false, true)); HashSet <Tag> hashSet = new HashSet <Tag>(); hashSet.Add("SpiceVine".ToTag()); hashSet.Add(SwampLilyConfig.ID.ToTag()); hashSet.Add("BasicSingleHarvestPlant".ToTag()); Diet.Info[] infos = new Diet.Info[1] { new Diet.Info(hashSet, POOP_ELEMENT, CALORIES_PER_DAY_OF_PLANT_EATEN, KG_POOP_PER_DAY_OF_PLANT, null, 0f, false, true) }; Diet diet = new Diet(infos); CreatureCalorieMonitor.Def def = prefab.AddOrGetDef <CreatureCalorieMonitor.Def>(); def.diet = diet; def.minPoopSizeInCalories = MIN_POOP_SIZE_IN_CALORIES; SolidConsumerMonitor.Def def2 = prefab.AddOrGetDef <SolidConsumerMonitor.Def>(); def2.diet = diet; ScaleGrowthMonitor.Def def3 = prefab.AddOrGetDef <ScaleGrowthMonitor.Def>(); def3.defaultGrowthRate = 1f / SCALE_GROWTH_TIME_IN_CYCLES / 600f; def3.dropMass = FIBER_PER_CYCLE * SCALE_GROWTH_TIME_IN_CYCLES; def3.itemDroppedOnShear = EMIT_ELEMENT; def3.levelCount = 6; def3.targetAtmosphere = SimHashes.Hydrogen; return(prefab); }
public DietContainer(Diet.Info info) { this.producedTag = info.producedElement.IsValid ? info.producedElement.ToString() : null; this.caloriesPerKg = info.caloriesPerKg; this.producedConversionRate = info.producedConversionRate; this.diseaseId = info.diseaseIdx.ToDiseaseId(); this.diseasePerKgProduced = info.diseasePerKgProduced; this.consumedTags = new HashSet <string>(info.consumedTags.Select(x => x.ToString())); }
public static Diet.Info[] Convert(List <DietContainer> c) { Diet.Info[] result = new Diet.Info[c.Count]; for (int i = 0; i < c.Count; i++) { result[i] = new Diet.Info(new HashSet <Tag>(c[i].consumedTags.Select(x => x.ToTag())), c[i].producedTag, c[i].caloriesPerKg, c[i].producedConversionRate, c[i].diseaseId, c[i].diseasePerKgProduced, c[i].produceSolidTile, c[i].eatsPlantsDirectly); } return(result); }
public static GameObject SetupDiet(GameObject prefab, Tag consumed_tag, Tag producedTag, float caloriesPerKg, float producedConversionRate, string diseaseId, float diseasePerKgProduced, float minPoopSizeInKg) { HashSet <Tag> hashSet = new HashSet <Tag>(); hashSet.Add(consumed_tag); Diet.Info[] diet_infos = new Diet.Info[1] { new Diet.Info(hashSet, producedTag, caloriesPerKg, producedConversionRate, diseaseId, diseasePerKgProduced, false, false) }; return(SetupDiet(prefab, diet_infos, caloriesPerKg, minPoopSizeInKg)); }
public static void Postfix(List <Diet.Info> __result) { Diet.Info resu = null; foreach (Diet.Info resua in __result) { resu = resua; break; } __result.Clear(); __result.Add(new Diet.Info(new HashSet <Tag>() { SimHashes.Steel.CreateTag() }, SimHashes.Lime.CreateTag(), resu.caloriesPerKg, 0.4f, Db.Get().Diseases.FoodPoisoning.Id, 1000000)); }
public static GameObject SetupDiet(GameObject prefab, HashSet <Tag> consumed_tags, Tag producedTag, float caloriesPerKg) { Diet.Info[] infos = new Diet.Info[1] { new Diet.Info(consumed_tags, producedTag, caloriesPerKg, 1f, null, 0f, false, false) }; Diet diet = new Diet(infos); CreatureCalorieMonitor.Def def = prefab.AddOrGetDef <CreatureCalorieMonitor.Def>(); def.diet = diet; SolidConsumerMonitor.Def def2 = prefab.AddOrGetDef <SolidConsumerMonitor.Def>(); def2.diet = diet; return(prefab); }
public Tag GetNextPoopEntry() { for (int i = 0; i < caloriesConsumed.Count; i++) { CaloriesConsumedEntry caloriesConsumedEntry = caloriesConsumed[i]; if (!(caloriesConsumedEntry.calories <= 0f)) { Diet.Info dietInfo = diet.GetDietInfo(caloriesConsumedEntry.tag); if (dietInfo != null && !(dietInfo.producedElement == Tag.Invalid)) { return(dietInfo.producedElement); } } } return(Tag.Invalid); }
public float GetTotalConsumedCalories() { float num = 0f; foreach (CaloriesConsumedEntry item in caloriesConsumed) { CaloriesConsumedEntry current = item; if (!(current.calories <= 0f)) { Diet.Info dietInfo = diet.GetDietInfo(current.tag); if (dietInfo != null && !(dietInfo.producedElement == Tag.Invalid)) { num += current.calories; } } } return(num); }
public static GameObject SetupDiet(GameObject prefab, Tag consumed_tag, Tag producedTag, float caloriesPerKg, float producedConversionRate, string diseaseId, float diseasePerKgProduced, float minPoopSizeInKg) { HashSet <Tag> hashSet = new HashSet <Tag>(); hashSet.Add(consumed_tag); Diet.Info[] infos = new Diet.Info[1] { new Diet.Info(hashSet, producedTag, caloriesPerKg, producedConversionRate, diseaseId, diseasePerKgProduced, false, false) }; Diet diet = new Diet(infos); CreatureCalorieMonitor.Def def = prefab.AddOrGetDef <CreatureCalorieMonitor.Def>(); def.diet = diet; def.minPoopSizeInCalories = minPoopSizeInKg * caloriesPerKg; GasAndLiquidConsumerMonitor.Def def2 = prefab.AddOrGetDef <GasAndLiquidConsumerMonitor.Def>(); def2.diet = diet; return(prefab); }
public static void Prefix(CreatureCalorieMonitor.Instance __instance) { GameObject go = __instance.gameObject; if (go != null && go.name.Contains("Oilfloater")) // include modded ones { int higherGerms = Numbers.GetGermCount(go, Numbers.IndexZombieSpores); float bonus = Numbers.PercentOfMaxGerms(higherGerms); Tag tag = Tag.Invalid; float amount = 0.0f; List <CreatureCalorieMonitor.Stomach.CaloriesConsumedEntry> caloriesConsumed; caloriesConsumed = Traverse.Create(__instance.stomach).Field("caloriesConsumed").GetValue <List <CreatureCalorieMonitor.Stomach.CaloriesConsumedEntry> >(); if (caloriesConsumed == null || caloriesConsumed.Count == 0) { return; } for (int index = 0; index < caloriesConsumed.Count; ++index) { CreatureCalorieMonitor.Stomach.CaloriesConsumedEntry caloriesConsumedEntry = caloriesConsumed[index]; if (caloriesConsumedEntry.calories > 0) { Diet.Info dietInfo = __instance.stomach.diet.GetDietInfo(caloriesConsumedEntry.tag); if (dietInfo != null && (!(tag != Tag.Invalid) || !(tag != dietInfo.producedElement))) { amount += dietInfo.ConvertConsumptionMassToProducedMass(dietInfo.ConvertCaloriesToConsumptionMass(caloriesConsumedEntry.calories)); tag = dietInfo.producedElement; } } } amount *= bonus * Settings.Instance.MaxSlicksterBonus; Element element = ElementLoader.GetElement(tag); float temperature = go.GetComponent <PrimaryElement>().Temperature; if (element.IsLiquid && amount > 0) { FallingWater.instance.AddParticle(Grid.PosToCell(go), element.idx, amount, temperature, Numbers.IndexZombieSpores, higherGerms, true); } } }
public static void AdditionalSolidPoop(GameObject go, CreatureCalorieMonitor.Instance __instance, byte germIdx, float maxBonus) { int higherGerms = Numbers.GetGermCount(go, germIdx); float bonus = Numbers.PercentOfMaxGerms(higherGerms); Tag tag = Tag.Invalid; float amount = 0.0f; List <CreatureCalorieMonitor.Stomach.CaloriesConsumedEntry> caloriesConsumed; caloriesConsumed = Traverse.Create(__instance.stomach).Field("caloriesConsumed").GetValue <List <CreatureCalorieMonitor.Stomach.CaloriesConsumedEntry> >(); if (caloriesConsumed == null || caloriesConsumed.Count == 0) { return; } for (int index = 0; index < caloriesConsumed.Count; ++index) { CreatureCalorieMonitor.Stomach.CaloriesConsumedEntry caloriesConsumedEntry = caloriesConsumed[index]; if (caloriesConsumedEntry.calories > 0) { Diet.Info dietInfo = __instance.stomach.diet.GetDietInfo(caloriesConsumedEntry.tag); if (dietInfo != null && (!(tag != Tag.Invalid) || !(tag != dietInfo.producedElement))) { amount += dietInfo.ConvertConsumptionMassToProducedMass(dietInfo.ConvertCaloriesToConsumptionMass(caloriesConsumedEntry.calories)); tag = dietInfo.producedElement; } } } amount *= bonus * maxBonus; Element element = ElementLoader.GetElement(tag); float temperature = go.GetComponent <PrimaryElement>().Temperature; int cell = Grid.PosToCell(go.transform.GetPosition()); if (!element.IsLiquid && amount > 0) { element.substance.SpawnResource(Grid.CellToPosCCC(cell, Grid.SceneLayer.Ore), amount, temperature, germIdx, higherGerms); } }
public static void Postfix(List <Diet.Info> __result) { Diet.Info resu = null; foreach (Diet.Info resua in __result) { resu = resua; break; } __result.Clear(); __result.Add(new Diet.Info(new HashSet <Tag>() { SimHashes.Carbon.CreateTag() }, SimHashes.SlimeMold.CreateTag(), resu.caloriesPerKg, resu.producedConversionRate, Db.Get().Diseases.FoodPoisoning.Id, 100000f)); __result.Add(new Diet.Info(new HashSet <Tag>() { SimHashes.IgneousRock.CreateTag() }, SimHashes.Obsidian.CreateTag(), resu.caloriesPerKg, resu.producedConversionRate, Db.Get().Diseases.FoodPoisoning.Id, 100000f)); __result.Add(new Diet.Info(new HashSet <Tag>() { SimHashes.SedimentaryRock.CreateTag() }, SimHashes.Granite.CreateTag(), resu.caloriesPerKg, resu.producedConversionRate, Db.Get().Diseases.FoodPoisoning.Id, 100000f)); }
public void Poop() { float num = 0f; Tag tag = Tag.Invalid; byte disease_idx = byte.MaxValue; int num2 = 0; bool flag = false; for (int i = 0; i < caloriesConsumed.Count; i++) { CaloriesConsumedEntry value = caloriesConsumed[i]; if (!(value.calories <= 0f)) { Diet.Info dietInfo = diet.GetDietInfo(value.tag); if (dietInfo != null && (!(tag != Tag.Invalid) || !(tag != dietInfo.producedElement))) { num += dietInfo.ConvertConsumptionMassToProducedMass(dietInfo.ConvertCaloriesToConsumptionMass(value.calories)); tag = dietInfo.producedElement; disease_idx = dietInfo.diseaseIdx; num2 = (int)(dietInfo.diseasePerKgProduced * num); value.calories = 0f; caloriesConsumed[i] = value; flag = (flag || dietInfo.produceSolidTile); } } } if (!(num <= 0f) && !(tag == Tag.Invalid)) { Element element = ElementLoader.GetElement(tag); Debug.Assert(element != null, "TODO: implement non-element tag spawning"); int num3 = Grid.PosToCell(owner.transform.GetPosition()); float temperature = owner.GetComponent <PrimaryElement>().Temperature; if (element.IsLiquid) { FallingWater.instance.AddParticle(num3, element.idx, num, temperature, disease_idx, num2, true, false, false, false); } else if (element.IsGas) { SimMessages.AddRemoveSubstance(num3, element.idx, CellEventLogger.Instance.ElementConsumerSimUpdate, num, temperature, disease_idx, num2, true, -1); } else if (flag) { Facing component = owner.GetComponent <Facing>(); int num4 = component.GetFrontCell(); if (!Grid.IsValidCell(num4)) { Debug.LogWarningFormat("{0} attemping to Poop {1} on invalid cell {2} from cell {3}", owner, element.name, num4, num3); num4 = num3; } SimMessages.AddRemoveSubstance(num4, element.idx, CellEventLogger.Instance.ElementConsumerSimUpdate, num, temperature, disease_idx, num2, true, -1); } else { element.substance.SpawnResource(Grid.CellToPosCCC(num3, Grid.SceneLayer.Ore), num, temperature, disease_idx, num2, false, false, false); } KPrefabID component2 = owner.GetComponent <KPrefabID>(); if (!Game.Instance.savedInfo.creaturePoopAmount.ContainsKey(component2.PrefabTag)) { Game.Instance.savedInfo.creaturePoopAmount.Add(component2.PrefabTag, 0f); } Dictionary <Tag, float> creaturePoopAmount; Tag prefabTag; (creaturePoopAmount = Game.Instance.savedInfo.creaturePoopAmount)[prefabTag = component2.PrefabTag] = creaturePoopAmount[prefabTag] + num; PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Resource, element.name, owner.transform, 1.5f, false); } }
public static bool Prefix(Stomach __instance, ref GameObject ___owner, ref List <CreatureCalorieMonitor.Stomach.CaloriesConsumedEntry> ___caloriesConsumed) { if (___owner.PrefabID() == CloudyPuftConfig.ID || ___owner.PrefabID() == CloudyPuftConfig.BABY_ID || ___owner.PrefabID() == SmoggyPuftConfig.ID || ___owner.PrefabID() == SmoggyPuftConfig.BABY_ID) { float deltaEmitTemperature = 0; if (___owner.PrefabID() == CloudyPuftConfig.ID || ___owner.PrefabID() == CloudyPuftConfig.BABY_ID) { deltaEmitTemperature = -5f * 2; } if (___owner.PrefabID() == SmoggyPuftConfig.ID || ___owner.PrefabID() == SmoggyPuftConfig.BABY_ID) { deltaEmitTemperature = 5f * 8; } float num1 = 0.0f; Tag tag = Tag.Invalid; byte disease_idx = byte.MaxValue; int num2 = 0; bool flag = false; for (int index = 0; index < ___caloriesConsumed.Count; ++index) { CreatureCalorieMonitor.Stomach.CaloriesConsumedEntry caloriesConsumedEntry = ___caloriesConsumed[index]; if ((double)caloriesConsumedEntry.calories > 0.0) { Diet.Info dietInfo = __instance.diet.GetDietInfo(caloriesConsumedEntry.tag); if (dietInfo != null && (!(tag != Tag.Invalid) || !(tag != dietInfo.producedElement))) { num1 += dietInfo.ConvertConsumptionMassToProducedMass(dietInfo.ConvertCaloriesToConsumptionMass(caloriesConsumedEntry.calories)); tag = dietInfo.producedElement; disease_idx = dietInfo.diseaseIdx; num2 = (int)((double)dietInfo.diseasePerKgProduced * (double)num1); caloriesConsumedEntry.calories = 0.0f; ___caloriesConsumed[index] = caloriesConsumedEntry; flag = flag || dietInfo.produceSolidTile; } } } if ((double)num1 <= 0.0 || tag == Tag.Invalid) { return(false); } Element element = ElementLoader.GetElement(tag); Debug.Assert(element != null, (object)"TODO: implement non-element tag spawning"); int cell = Grid.PosToCell(___owner.transform.GetPosition()); float temperature = ___owner.GetComponent <PrimaryElement>().Temperature; temperature = Mathf.Max(element.lowTemp + 5f, temperature + deltaEmitTemperature); if (element.IsLiquid) { FallingWater.instance.AddParticle(cell, element.idx, num1, temperature, disease_idx, num2, true, false, false, false); } else if (element.IsGas) { SimMessages.AddRemoveSubstance(cell, (int)element.idx, CellEventLogger.Instance.ElementConsumerSimUpdate, num1, temperature, disease_idx, num2, true, -1); } else if (flag) { int num3 = ___owner.GetComponent <Facing>().GetFrontCell(); if (!Grid.IsValidCell(num3)) { Debug.LogWarningFormat("{0} attemping to Poop {1} on invalid cell {2} from cell {3}", (object)___owner, (object)element.name, (object)num3, (object)cell); num3 = cell; } SimMessages.AddRemoveSubstance(num3, (int)element.idx, CellEventLogger.Instance.ElementConsumerSimUpdate, num1, temperature, disease_idx, num2, true, -1); } else { element.substance.SpawnResource(Grid.CellToPosCCC(cell, Grid.SceneLayer.Ore), num1, temperature, disease_idx, num2, false, false, false); } KPrefabID component = ___owner.GetComponent <KPrefabID>(); if (!Game.Instance.savedInfo.creaturePoopAmount.ContainsKey(component.PrefabTag)) { Game.Instance.savedInfo.creaturePoopAmount.Add(component.PrefabTag, 0.0f); } Dictionary <Tag, float> creaturePoopAmount; Tag prefabTag; (creaturePoopAmount = Game.Instance.savedInfo.creaturePoopAmount)[prefabTag = component.PrefabTag] = creaturePoopAmount[prefabTag] + num1; PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Resource, element.name, ___owner.transform, 1.5f, false); return(false); } else { return(true); } }
public static GameObject CreatePrefab(string id, string base_trait_id, string name, string description, string anim_file, bool is_baby, string symbol_prefix, float warnLowTemp, float warnHighTemp) { float mass = 200f; KAnimFile anim = Assets.GetAnim(anim_file); string initialAnim = "idle_loop"; EffectorValues tIER = DECOR.BONUS.TIER0; float defaultTemperature = (warnLowTemp + warnHighTemp) / 2f; GameObject gameObject = EntityTemplates.CreatePlacedEntity(id, name, description, mass, anim, initialAnim, Grid.SceneLayer.Creatures, 1, 1, tIER, default(EffectorValues), SimHashes.Creature, null, defaultTemperature); KPrefabID component = gameObject.GetComponent <KPrefabID>(); component.AddTag(GameTags.SwimmingCreature, false); component.AddTag(GameTags.Creatures.Swimmer, false); Trait trait = Db.Get().CreateTrait(base_trait_id, name, name, null, false, null, true, true); trait.Add(new AttributeModifier(Db.Get().Amounts.Calories.maxAttribute.Id, PacuTuning.STANDARD_STOMACH_SIZE, name, false, false, true)); trait.Add(new AttributeModifier(Db.Get().Amounts.Calories.deltaAttribute.Id, (0f - PacuTuning.STANDARD_CALORIES_PER_CYCLE) / 600f, name, false, false, true)); trait.Add(new AttributeModifier(Db.Get().Amounts.HitPoints.maxAttribute.Id, 25f, name, false, false, true)); trait.Add(new AttributeModifier(Db.Get().Amounts.Age.maxAttribute.Id, 25f, name, false, false, true)); EntityTemplates.CreateAndRegisterBaggedCreature(gameObject, false, false, true); EntityTemplates.ExtendEntityToBasicCreature(gameObject, FactionManager.FactionID.Prey, base_trait_id, "SwimmerNavGrid", NavType.Swim, 32, 2f, "FishMeat", 1, false, false, warnLowTemp, warnHighTemp, warnLowTemp - 20f, warnHighTemp + 20f); if (is_baby) { KBatchedAnimController component2 = gameObject.GetComponent <KBatchedAnimController>(); component2.animWidth = 0.5f; component2.animHeight = 0.5f; } ChoreTable.Builder chore_table = new ChoreTable.Builder().Add(new DeathStates.Def(), true).Add(new AnimInterruptStates.Def(), true).Add(new GrowUpStates.Def(), true) .Add(new TrappedStates.Def(), true) .Add(new IncubatingStates.Def(), true) .Add(new BaggedStates.Def(), true) .Add(new FallStates.Def { getLandAnim = new Func <FallStates.Instance, string>(GetLandAnim) }, true) .Add(new DebugGoToStates.Def(), true) .Add(new FlopStates.Def(), true) .PushInterruptGroup() .Add(new FixedCaptureStates.Def(), true) .Add(new LayEggStates.Def(), true) .Add(new EatStates.Def(), true) .Add(new PlayAnimsStates.Def(GameTags.Creatures.Poop, false, "lay_egg_pre", STRINGS.CREATURES.STATUSITEMS.EXPELLING_SOLID.NAME, STRINGS.CREATURES.STATUSITEMS.EXPELLING_SOLID.TOOLTIP), true) .Add(new MoveToLureStates.Def(), true) .PopInterruptGroup() .Add(new IdleStates.Def(), true); CreatureFallMonitor.Def def = gameObject.AddOrGetDef <CreatureFallMonitor.Def>(); def.canSwim = true; gameObject.AddOrGetDef <FlopMonitor.Def>(); gameObject.AddOrGetDef <FishOvercrowdingMonitor.Def>(); gameObject.AddOrGet <Trappable>(); gameObject.AddOrGet <LoopingSounds>(); EntityTemplates.AddCreatureBrain(gameObject, chore_table, GameTags.Creatures.Species.PacuSpecies, symbol_prefix); HashSet <Tag> hashSet = new HashSet <Tag>(); hashSet.Add(SimHashes.Algae.CreateTag()); Diet.Info[] infos = new Diet.Info[1] { new Diet.Info(hashSet, SimHashes.ToxicSand.CreateTag(), CALORIES_PER_KG_OF_ORE, TUNING.CREATURES.CONVERSION_EFFICIENCY.NORMAL, null, 0f, false, false) }; Diet diet = new Diet(infos); CreatureCalorieMonitor.Def def2 = gameObject.AddOrGetDef <CreatureCalorieMonitor.Def>(); def2.diet = diet; def2.minPoopSizeInCalories = CALORIES_PER_KG_OF_ORE * MIN_POOP_SIZE_IN_KG; SolidConsumerMonitor.Def def3 = gameObject.AddOrGetDef <SolidConsumerMonitor.Def>(); def3.diet = diet; LureableMonitor.Def def4 = gameObject.AddOrGetDef <LureableMonitor.Def>(); def4.lures = new Tag[1] { GameTags.Creatures.FishTrapLure }; if (!string.IsNullOrEmpty(symbol_prefix)) { gameObject.AddOrGet <SymbolOverrideController>().ApplySymbolOverridesByAffix(Assets.GetAnim("pacu_kanim"), symbol_prefix, null, 0); } return(gameObject); }
public static bool Prefix(Stomach __instance, ref GameObject ___owner, ref List <CreatureCalorieMonitor.Stomach.CaloriesConsumedEntry> ___caloriesConsumed) { if (___owner.PrefabID() == FloralHatchConfig.Id || ___owner.PrefabID() == FloralHatchConfig.BabyId || ___owner.PrefabID() == WoodenHatchConfig.Id || ___owner.PrefabID() == WoodenHatchConfig.BabyId) { float num = 0f;//consumed calories acumulated Tag tag = Tag.Invalid; byte disease_idx = byte.MaxValue; int num2 = 0;//total germs bool flag = false; for (int i = 0; i < ___caloriesConsumed.Count; i++) { CreatureCalorieMonitor.Stomach.CaloriesConsumedEntry value = ___caloriesConsumed[i]; if (value.calories > 0f) { Diet.Info dietInfo = __instance.diet.GetDietInfo(value.tag); if (dietInfo != null) { if (!(tag != Tag.Invalid) || !(tag != dietInfo.producedElement)) { num += dietInfo.ConvertConsumptionMassToProducedMass(dietInfo.ConvertCaloriesToConsumptionMass(value.calories)); tag = dietInfo.producedElement; disease_idx = dietInfo.diseaseIdx; num2 = (int)(dietInfo.diseasePerKgProduced * num); value.calories = 0f; ___caloriesConsumed[i] = value; flag = (flag || dietInfo.produceSolidTile); } } } } if (num <= 0f || tag == Tag.Invalid) { Debug.Log("tag invalid"); return(false); } Element element = ElementLoader.GetElement(tag); if (element == null) { //for food and others GameObject prefab = Assets.GetPrefab(tag); GameObject gameObject2 = GameUtil.KInstantiate(prefab, Grid.SceneLayer.Ore, null, 0); int units_c = 0; PrimaryElement component2 = null; if (___owner.PrefabID() == WoodenHatchConfig.Id || ___owner.PrefabID() == WoodenHatchConfig.BabyId) { // EdiblesManager.FoodInfo food_info = EdiblesManager.GetFoodInfo(tag.ToString()); var out_put = prefab.GetComponent <PrimaryElement>(); units_c = (int)(num / out_put.Mass); Facing component = ___owner.GetComponent <Facing>(); int num3 = Grid.PosToCell(___owner.transform.GetPosition()); var pos = Grid.CellToPosCCC(num3, Grid.SceneLayer.Ore); gameObject2.transform.SetPosition(pos); component2 = gameObject2.GetComponent <PrimaryElement>(); component2.Units = units_c; } else { var out_put_edible = prefab.GetComponent <Edible>(); var out_put_food_info = out_put_edible.FoodInfo; units_c = (int)(num / out_put_food_info.CaloriesPerUnit); Facing component = ___owner.GetComponent <Facing>(); int num3 = Grid.PosToCell(___owner.transform.GetPosition()); var pos = Grid.CellToPosCCC(num3, Grid.SceneLayer.Ore); gameObject2.transform.SetPosition(pos); component2 = gameObject2.GetComponent <PrimaryElement>(); component2.Mass = num; } float temperature = ___owner.GetComponent <PrimaryElement>().Temperature; component2.Temperature = temperature; gameObject2.SetActive(true); component2.AddDisease(disease_idx, num2, "ComplexFabricator.CompleteOrder"); KPrefabID component3 = ___owner.GetComponent <KPrefabID>(); if (!Game.Instance.savedInfo.creaturePoopAmount.ContainsKey(component3.PrefabTag)) { Game.Instance.savedInfo.creaturePoopAmount.Add(component3.PrefabTag, 0f); } Dictionary <Tag, float> creaturePoopAmount; Tag prefabTag; (creaturePoopAmount = Game.Instance.savedInfo.creaturePoopAmount)[prefabTag = component3.PrefabTag] = creaturePoopAmount[prefabTag] + num; PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Resource, prefab.name, ___owner.transform, 1.5f, false); } else { ///default option global::Debug.Assert(element != null, "Fail at default option"); int num3 = Grid.PosToCell(___owner.transform.GetPosition()); float temperature = ___owner.GetComponent <PrimaryElement>().Temperature; if (element.IsLiquid) { FallingWater.instance.AddParticle(num3, element.idx, num, temperature, disease_idx, num2, true, false, false, false); } else if (element.IsGas) { SimMessages.AddRemoveSubstance(num3, (int)element.idx, CellEventLogger.Instance.ElementConsumerSimUpdate, num, temperature, disease_idx, num2, true, -1); } else if (flag) { Facing component = ___owner.GetComponent <Facing>(); int num4 = component.GetFrontCell(); if (!Grid.IsValidCell(num4)) { global::Debug.LogWarningFormat("{0} attemping to Poop {1} on invalid cell {2} from cell {3}", new object[] { ___owner, element.name, num4, num3 }); num4 = num3; } SimMessages.AddRemoveSubstance(num4, (int)element.idx, CellEventLogger.Instance.ElementConsumerSimUpdate, num, temperature, disease_idx, num2, true, -1); } else { element.substance.SpawnResource(Grid.CellToPosCCC(num3, Grid.SceneLayer.Ore), num, temperature, disease_idx, num2, false, false, false); } KPrefabID component2 = ___owner.GetComponent <KPrefabID>(); if (!Game.Instance.savedInfo.creaturePoopAmount.ContainsKey(component2.PrefabTag)) { Game.Instance.savedInfo.creaturePoopAmount.Add(component2.PrefabTag, 0f); } Dictionary <Tag, float> creaturePoopAmount; Tag prefabTag; (creaturePoopAmount = Game.Instance.savedInfo.creaturePoopAmount)[prefabTag = component2.PrefabTag] = creaturePoopAmount[prefabTag] + num; PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Resource, element.name, ___owner.transform, 1.5f, false); } return(false); } else { return(true); } }