public void EatFood() { myFood = GetComponentInParent <Pickupper2>(); if (myFood.IsHoldingObject()) { foodLoc = myFood.grabPoint; foreach (Transform child in foodLoc) { Eatable eatable = child.GetComponent <Eatable>(); if (child.gameObject != null && eatable != null) { Vector3 foodSize = child.gameObject.transform.localScale; StartCoroutine(EatTheShit(child, foodSize, duration)); if (eatable.name == "apple(Clone)") { foodEaten += 10; } else if (eatable.name == "chicken(Clone)") { foodEaten += 100; } else if (eatable.name == "water") { foodEaten += 2; } } } } }
public void Update(int id, Eatable eatable) { var item = _inventoryList.First(i => i.Id == id); _inventoryList.Remove(item); _inventoryList.Add(eatable); }
private static void Postfix(Creature __instance) { TechType techType = CraftData.GetTechType(__instance.gameObject); if (techType == TechType.Rockgrub) { // Add Pickupable component to the original fish Pickupable pickupable = __instance.gameObject.EnsureComponent <Pickupable>(); pickupable.isPickupable = true; pickupable.randomizeRotationWhenDropped = true; // Add WaterParkCreature component to the original fish __instance.gameObject.EnsureComponent <WaterParkCreature>().pickupable = pickupable; // Add Eatable component to the original fish Eatable eatable = __instance.gameObject.EnsureComponent <Eatable>(); eatable.foodValue = 10f; eatable.waterValue = 4f; // Clone the original fish and remove the extra Components from it GameObject obj = Object.Instantiate(__instance.gameObject); foreach (var component in obj.GetComponents <Component>()) { Object.Destroy(component); } // Add AquariumFish component to the original fish AquariumFish aquariumFish = __instance.gameObject.EnsureComponent <AquariumFish>(); aquariumFish.model = obj; // Set the Object inactive cause yes obj.SetActive(false); } }
void FixedUpdate() { myFood = GameObject.Find("Player").GetComponent <Pickupper2>(); if (myFood.IsHoldingObject()) { foodLoc = myFood.grabPoint; if (Input.GetButtonDown("Eat")) { foreach (Transform child in foodLoc) { Eatable eatable = child.GetComponent <Eatable>(); if (child.gameObject != null && eatable != null) { //If the variables are public, we can do this: //myFood.isHolding = false; //myFood.buttonDown = false; //myFood.pickup = null; // if No, I've created a function inside of Pickupper2 Script Vector3 foodSize = child.gameObject.transform.localScale; StartCoroutine(EatTheShit(child, foodSize, duration)); } } } } }
public static bool Prefix(Survival __instance, GameObject useObj) { if (useObj != null) { Eatable component = useObj.GetComponent <Eatable>(); if (component != null) { if (component.GetFoodValue() == -25f) { if (Config.FOOD_VEGAN.Equals(DeathRun.config.foodChallenge)) { DeathRunUtils.CenterMessage("Vegan Challenge: Negative Food Value!", 5); } else if (Config.FOOD_VEGETARIAN.Equals(DeathRun.config.foodChallenge)) { DeathRunUtils.CenterMessage("Vegetarian Challenge: Negative Food Value!", 5); } else if (Config.FOOD_PESCATARIAN.Equals(DeathRun.config.foodChallenge)) { DeathRunUtils.CenterMessage("Pescatarian Challenge: Negative Food Value!", 5); } } } } return(true); }
public void OnEatingUpdate() { for (var index = 0; index < _eatables.Length; index++) { Eatable eatable = _eatables[index]; if (!eatable.IsEaten) { return; } if (index == _eatables.Length - 1) { if (Level == 39) { ActivateRateUsPanel("Congratulations! You Completed Your Quest"); } else { ActivateRateUsPanel( FinalConstants.CongraMessages[ Random.Range(0, FinalConstants.CongraMessages.Length - 1)]); } Time.timeScale = 0; } } }
public void ObjectEaten(Eatable eatable) { var direction = 0; switch (eatable.EatableType) { case EatableType.Hot: direction = 1; break; case EatableType.Cold: direction = -1; break; } var changePercentage = (float)eatable.HotnessChangePercentage; if (direction != Mathf.RoundToInt(Mathf.Sign(HotnessLevel))) { changePercentage *= 1.5f; } HotnessLevel += direction * changePercentage / 100f; Score += Mathf.RoundToInt(eatable.ScoreAmount * ScoreMultiplier); }
public static bool IsEatableFishAlive(GameObject go) { Creature creature = go.GetComponent <Creature>(); Eatable eatable = go.GetComponent <Eatable>(); LiveMixin liveMixin = go.GetComponent <LiveMixin>(); return(creature && eatable && liveMixin && liveMixin.IsAlive()); }
static void KillFish(LiveMixin liveMixin) { //ErrorMessage.AddDebug("Kill " + liveMixin.gameObject.name); //Main.Log("Kill " + liveMixin.gameObject.name); liveMixin.health = 0f; liveMixin.tempDamage = 0f; liveMixin.SyncUpdatingState(); if (liveMixin.deathClip) { Utils.PlayEnvSound(liveMixin.deathClip, liveMixin.transform.position, 25f); } //if (this.deathEffect != null) // Utils.InstantiateWrap(this.deathEffect, this.transform.position, Quaternion.identity); if (liveMixin.passDamageDataOnDeath) { liveMixin.gameObject.BroadcastMessage("OnKill", DamageType.Normal, SendMessageOptions.DontRequireReceiver); } else if (liveMixin.broadcastKillOnDeath) { liveMixin.gameObject.BroadcastMessage("OnKill", SendMessageOptions.DontRequireReceiver); } CreatureDeath creatureDeath = liveMixin.GetComponent <CreatureDeath>(); Eatable eatable = liveMixin.GetComponent <Eatable>(); eatable.SetDecomposes(true); Rigidbody rb = liveMixin.GetComponent <Rigidbody>(); if (rb) { rb.isKinematic = false; rb.constraints = RigidbodyConstraints.None; WorldForces worldForces = liveMixin.GetComponent <WorldForces>(); if (worldForces) { worldForces.handleDrag = false; } rb.drag = Mathf.Max(rb.drag, 1f); rb.angularDrag = Mathf.Max(rb.angularDrag, 1f); } liveMixin.gameObject.EnsureComponent <EcoTarget>().SetTargetType(EcoTargetType.DeadMeat); if (creatureDeath) { if (creatureDeath.respawn && !creatureDeath.respawnOnlyIfKilledByCreature) { creatureDeath.SpawnRespawner(); } if (creatureDeath.removeCorpseAfterSeconds >= 0.0) { creatureDeath.Invoke("RemoveCorpse", creatureDeath.removeCorpseAfterSeconds); } creatureDeath.SyncFixedUpdatingState(); } }
public GameObject SpawnFood(Vector3 p_position, Quaternion p_rotation) { GameObject goFood = Instantiate(foodPrefab, p_position, p_rotation) as GameObject; Eatable e = goFood.GetComponent <Eatable>(); foodList.Add(e); e.SetFoodManager(this); return(goFood); }
public bool EatFood(GameObject p_eatable) { Eatable e = p_eatable.GetComponent <Eatable>(); if (e == null) { return(false); } return(EatFood(e)); }
public void ResetFood() { while (foodList.Count > 0) { Eatable food = foodList[0]; foodList.RemoveAt(0); Destroy(food.gameObject); } SpawnFood(INIT_FOOD_POSITION, INIT_FOOD_ROTATION); }
public Eatable Insert(Eatable eatable) { lock (_lock) { eatable.Id = GenerateUniqId(); _inventoryList.Add(eatable); BoradcastInventory(); } return(eatable); }
public void Start() { if (gameObject.GetComponent <Player>() != null) { return; } eatable = gameObject.AddComponent <Eatable>(); eatable.decomposes = false; eatable.despawns = false; eatable.foodValue = -10; eatable.waterValue = 5; }
public bool EatFood(Eatable p_eatable) { //if can remove from list, do cleanup bool result = foodList.Remove(p_eatable); if (result) { //TODO animate destruction Destroy(p_eatable.gameObject, 0.2f); if (onFoodEaten != null) { onFoodEaten(); } } return(result); }
// Use to process your families. protected override void onProcess(int familiesUpdateCount) { foreach (GameObject go in _Eaters) { InCollision3D collision = go.GetComponent <InCollision3D>(); Eater eater = go.GetComponent <Eater>(); foreach (GameObject target in collision.Targets) { Eatable eatable = target.GetComponent <Eatable>(); if (eatable != null && (eater.eatingMask & eatable.eatableMask) > 0 && Random.value <= eater.eatingProbability) { GameObjectManager.addComponent <Removed>(target); } } } }
public void EatFood() { myFood = GetComponentInParent <Pickupper>(); if (myFood.IsHoldingObject()) { foodLoc = myFood.grabPoint; foreach (Transform child in foodLoc) { Eatable eatable = child.GetComponent <Eatable>(); if (child.gameObject != null && eatable != null) { Vector3 foodSize = child.gameObject.transform.localScale; StartCoroutine(EatTheShit(child, foodSize, duration)); } } } }
public override GameObject GetGameObject() { GameObject prefab = CraftData.GetPrefabForTechType(FoodEntry.FoodPrefab); GameObject obj = UnityEngine.Object.Instantiate(prefab); Eatable eatable = obj.GetComponent <Eatable>(); if (eatable is null) { eatable = obj.AddComponent <Eatable>(); } eatable.foodValue = FoodEntry.FoodValue; eatable.waterValue = FoodEntry.WaterValue; eatable.decomposes = FoodEntry.Decomposes; eatable.kDecayRate = FoodEntry.DecayRateMod * StandardDecayRate; return(obj); }
// void Update() { // print("isChanging " + isChanging); // print("isSmall " + small); // } public void EatFood() { if (myFood.IsHoldingObject()) { foodLoc = myFood.grabPoint; foreach (Transform child in foodLoc) { Eatable eatable = child.GetComponent <Eatable>(); foodSize = child.gameObject.transform.localScale; if (child.gameObject != null && eatable != null) { if (!small && !isChanging) { StartCoroutine(EatTheObj(child, foodSize, playerSize, duration)); } } } } }
private void Freeze(BCell src) { Triggered3D trigerred = src.gameObject.GetComponent <Triggered3D>(); if (trigerred != null) { foreach (GameObject target in trigerred.Targets) { Eatable eatable = target.GetComponent <Eatable>(); if (eatable != null && (eatable.eatableMask & src.freezeMask) > 0 && target.GetComponent <Removed>() == null) { GameObjectManager.addComponent <Frozen>(target, new { remainingTime = src.freezeTime, totalTime = src.freezeTime }); } } if (trigerred.Targets.Length > 0) { src.cooldown = src.delay; } } }
// eats item, and shows text (COULDDOLATER: increasing healthbar) public void Eat(Eatable newItem) { Debug.Log(" Eat Item "); }
public Effect[] Eat(Eatable eatable) { return(eatable.ToBeEaten(this)); }
public override GameObject GetGameObject() { GameObject prefab = GameObject.Instantiate(this.GameObject); prefab.name = this.ClassID; GameObject.DestroyImmediate(prefab.GetComponent <PickPrefab>()); GameObject.DestroyImmediate(prefab.GetComponent <LiveMixin>()); PrefabsHelper.AddNewGenericSeed(ref prefab); var model = prefab.FindChild("farming_plant_01_02"); // Scale float scaleRatio = 0.75f; model.transform.localScale *= scaleRatio; // Update rigid body var rb = prefab.GetComponent <Rigidbody>(); // Add EntityTag var entityTag = prefab.AddComponent <EntityTag>(); entityTag.slotType = EntitySlot.Type.Small; // Add TechTag var techTag = prefab.AddComponent <TechTag>(); techTag.type = this.TechType; // Update prefab identifier var prefabId = prefab.GetComponent <PrefabIdentifier>(); prefabId.ClassId = this.ClassID; // Update large world entity var lwe = prefab.GetComponent <LargeWorldEntity>(); lwe.cellLevel = LargeWorldEntity.CellLevel.Near; // Add world forces var worldForces = prefab.AddComponent <WorldForces>(); worldForces.handleGravity = true; worldForces.aboveWaterGravity = 9.81f; worldForces.underwaterGravity = 1.0f; worldForces.handleDrag = true; worldForces.aboveWaterDrag = 0.0f; worldForces.underwaterDrag = 10.0f; worldForces.useRigidbody = rb; // Add pickupable var pickupable = prefab.AddComponent <Pickupable>(); pickupable.isPickupable = true; pickupable.destroyOnDeath = true; #if BELOWZERO pickupable.isLootCube = false; #else pickupable.cubeOnPickup = false; #endif pickupable.randomizeRotationWhenDropped = true; pickupable.usePackUpIcon = false; // Add eatable Eatable eatable = null; if (ConfigSwitcher.config_MarbleMelonTiny.Eatable) { eatable = prefab.AddComponent <Eatable>(); eatable.foodValue = ConfigSwitcher.config_MarbleMelonTiny.FoodValue; eatable.waterValue = ConfigSwitcher.config_MarbleMelonTiny.WaterValue; #if SUBNAUTICA eatable.stomachVolume = 10.0f; eatable.allowOverfill = false; #endif eatable.decomposes = ConfigSwitcher.config_MarbleMelonTiny.Decomposes; eatable.kDecayRate = ConfigSwitcher.config_MarbleMelonTiny.KDecayRate; eatable.despawns = ConfigSwitcher.config_MarbleMelonTiny.Despawns; eatable.despawnDelay = ConfigSwitcher.config_MarbleMelonTiny.DespawnDelay; } // Add plantable var plantable = prefab.AddComponent <Plantable>(); plantable.aboveWater = true; plantable.underwater = false; plantable.isSeedling = true; plantable.plantTechType = this.TechType; plantable.size = Plantable.PlantSize.Small; plantable.pickupable = pickupable; plantable.eatable = eatable; plantable.model = prefab; // prefab.FindChild("farming_plant_01_02"); plantable.linkedGrownPlant = new GrownPlant(); plantable.linkedGrownPlant.seed = plantable; plantable.linkedGrownPlant.seedUID = "MarbleMelonTinyFruit"; // Add live mixin var liveMixin = prefab.AddComponent <LiveMixin>(); liveMixin.health = ConfigSwitcher.config_MarbleMelonTiny.Health; liveMixin.data = ScriptableObject.CreateInstance <LiveMixinData>(); liveMixin.data.broadcastKillOnDeath = false; liveMixin.data.canResurrect = false; liveMixin.data.destroyOnDeath = true; #if SUBNAUTICA liveMixin.data.explodeOnDestroy = false; #endif liveMixin.data.invincibleInCreative = false; liveMixin.data.minDamageForSound = 10.0f; liveMixin.data.passDamageDataOnDeath = true; liveMixin.data.weldable = false; liveMixin.data.knifeable = false; liveMixin.data.maxHealth = ConfigSwitcher.config_MarbleMelonTiny.Health; //liveMixin.startHealthPercent = 1.0f; // Adjust sky applier SkyApplier sa = prefab.GetComponent <SkyApplier>(); sa.renderers = prefab.GetComponentsInChildren <MeshRenderer>(); sa.anchorSky = Skies.Auto; sa.dynamic = true; // Adjust colliders CapsuleCollider cc = prefab.GetComponentInChildren <CapsuleCollider>(); cc.radius *= scaleRatio; cc.height *= scaleRatio; SphereCollider sc = prefab.GetComponentInChildren <SphereCollider>(); sc.radius *= scaleRatio; // Add generic plant controller PlantGenericController plantController = prefab.AddComponent <PlantGenericController>(); plantController.GrowthDuration = ConfigSwitcher.config_MarbleMelonTiny.GrowthDuration; plantController.Health = ConfigSwitcher.config_MarbleMelonTiny.Health; plantController.Knifeable = ConfigSwitcher.config_MarbleMelonTiny.Knifeable; CustomFloraSerializer customSerializer = prefab.AddComponent <CustomFloraSerializer>(); // Hide plant and show seed PrefabsHelper.HidePlantAndShowSeed(prefab.transform, this.ClassID); return(prefab); }
/// <summary> /// This is a copy paste of the original <see cref="Survival.Eat(GameObject)"/> because there are too many things to transpile /// </summary> /// <param name="__instance"></param> /// <param name="useObj"></param> private void NewPrefixPatch(Survival __instance, GameObject useObj) { bool flag = false; if (useObj != null) { Eatable component = useObj.GetComponent <Eatable>(); if (component != null) { bool flag2 = component.maxCharges == 0 || component.charges > 0; if (component.GetFoodValue() != 0f && flag2) { if (__instance.food <= __instance.GetStomachSize() - 1) { __instance.food = Mathf.Clamp(__instance.food + component.GetFoodValue(), __instance.GetMinStomachSize(), __instance.GetStomachOverfillSize()); } __instance.onEat.Trigger(component.GetFoodValue()); if (component.GetFoodValue() > 0f) { GoalManager.main.OnCustomGoalEvent("Eat_Something"); } result = component.removeOnUse; flag = true; } if (component.GetWaterValue() != 0f && flag2) { __instance.water = Mathf.Clamp(__instance.water + component.GetWaterValue(), __instance.GetMinWater(), __instance.GetWaterOverfillSize()); __instance.onDrink.Trigger(component.GetWaterValue()); if (component.GetWaterValue() > 0f) { GoalManager.main.OnCustomGoalEvent("Drink_Something"); } result = component.removeOnUse; flag = true; } float healthValue = component.GetHealthValue(); if (healthValue != 0f && flag2) { if (healthValue > 0f) { __instance.liveMixin.AddHealth(healthValue); GoalManager.main.OnCustomGoalEvent("Heal_Damage"); } else if (healthValue <= -1f) { __instance.liveMixin.TakeDamage(-healthValue, default(Vector3), DamageType.FoodPoison, null); } result = component.removeOnUse; flag = true; } float coldMeterValue = component.GetColdMeterValue(); if (coldMeterValue != 0f && flag2) { __instance.bodyTemperature.AddCold(coldMeterValue); result = component.removeOnUse; flag = true; } if (!__instance.InConversation() && ((__instance.food > __instance.GetLowFoodThreshold() && __instance.food - component.GetFoodValue() < __instance.GetLowFoodThreshold()) || (__instance.water > __instance.GetLowWaterThreshold() && __instance.water - component.GetWaterValue() < __instance.GetLowWaterThreshold()))) { __instance.vitalsOkNotification.Play(); } } if (flag) { TechType techType = CraftData.GetTechType(useObj); if (techType == TechType.None) { Pickupable component2 = useObj.GetComponent <Pickupable>(); if (component2) { techType = component2.GetTechType(); } } FMODAsset useSound = __instance.player.GetUseSound(TechData.GetSoundType(techType)); if (useSound) { Utils.PlayFMODAsset(useSound, __instance.player.transform.position, 20f); } if (component.IsRotten()) { Utils.PlayFMODAsset(__instance.ateRottenFoodSound, __instance.player.transform.position, 20f); } if (techType == TechType.Bladderfish) { Player.main.GetComponent <OxygenManager>().AddOxygen(__instance.GetO2FromBlatterfish()); } if (component.maxCharges > 0) { component.ConsumeCharge(); } } } }
static void KillFish(LiveMixin liveMixin) { //AddDebug("KillFish " + liveMixin.gameObject.name); //Main.Log("Kill " + liveMixin.gameObject.name); liveMixin.health = 0f; liveMixin.tempDamage = 0f; liveMixin.SyncUpdatingState(); //if (liveMixin.deathClip) // liveMixin.deathClip.Play(); //if (liveMixin.deathSound) // Utils.PlayFMODAsset(liveMixin.deathSound, liveMixin.transform); //if (liveMixin.passDamageDataOnDeath) // liveMixin.gameObject.BroadcastMessage("OnKill", DamageType.Normal, SendMessageOptions.DontRequireReceiver); //else if (liveMixin.broadcastKillOnDeath) // liveMixin.gameObject.BroadcastMessage("OnKill", SendMessageOptions.DontRequireReceiver); //if (liveMixin.sendKillOnDeath) //{ // if (liveMixin.passDamageDataOnDeath) // liveMixin.gameObject.SendMessage("OnKill", DamageType.Normal, SendMessageOptions.DontRequireReceiver); // else // liveMixin.gameObject.SendMessage("OnKill", SendMessageOptions.DontRequireReceiver); //} AquariumFish af = liveMixin.GetComponent <AquariumFish>(); if (af) { UnityEngine.Object.Destroy(af); } Locomotion locomotion = liveMixin.GetComponent <Locomotion>(); locomotion.enabled = false; CreatureDeath creatureDeath = liveMixin.GetComponent <CreatureDeath>(); Eatable eatable = liveMixin.GetComponent <Eatable>(); eatable.SetDecomposes(true); Rigidbody rb = liveMixin.GetComponent <Rigidbody>(); if (rb) { rb.isKinematic = false; rb.constraints = RigidbodyConstraints.None; WorldForces worldForces = liveMixin.GetComponent <WorldForces>(); if (worldForces) { worldForces.handleDrag = false; } rb.drag = Mathf.Max(rb.drag, 1f); rb.angularDrag = Mathf.Max(rb.angularDrag, 1f); } liveMixin.gameObject.EnsureComponent <EcoTarget>().SetTargetType(EcoTargetType.DeadMeat); if (creatureDeath) { if (creatureDeath.respawn && !creatureDeath.respawnOnlyIfKilledByCreature) { creatureDeath.SpawnRespawner(); } if (creatureDeath.removeCorpseAfterSeconds >= 0.0) { creatureDeath.Invoke("RemoveCorpse", creatureDeath.removeCorpseAfterSeconds); } creatureDeath.SyncFixedUpdatingState(); } Pickupable pickupable = liveMixin.GetComponent <Pickupable>(); ItemsContainer container = pickupable.inventoryItem.container as ItemsContainer; if (container != null) { // fix offset decay bar container.RemoveItem(pickupable, true); container.AddItem(pickupable); } }
private void MakeDecision() { foreach (GameObject go in _Active) { Macrophage macrophage = go.GetComponent <Macrophage>(); MoveToward move = go.GetComponent <MoveToward>(); Triggered3D triggered = go.GetComponent <Triggered3D>(); bool shouldRecompute = false; // Is the a pathogene nearby ? if (triggered != null) { Eater eater = go.GetComponent <Eater>(); float minDistance = float.MaxValue; GameObject targetedPosition = null; // Compute closest eatable thing foreach (GameObject target in triggered.Targets) { Eatable eatable = target.GetComponent <Eatable>(); if (eatable != null && (eatable.eatableMask & eater.eatingMask) > 0) { float distance = Vector3.Distance(go.transform.position, target.transform.position); if (distance < minDistance) { minDistance = distance; targetedPosition = target; } } } if (targetedPosition != null) // Found something to eat { // Move to it move.target = targetedPosition.transform.position; // Update last decision made macrophage.lastDescision = DECISIONS.CHASE; continue; } if (macrophage.lastDescision.Equals(DECISIONS.CHASE)) // Last decision was chase but nothing is eatable in our range { shouldRecompute = true; // We need to recompute a path to the closest EndNode. } } if (macrophage.lastDescision.Equals(DECISIONS.CHASE) || shouldRecompute) // No pathogene to hunt in the area { // Recompute closest Waypoint GameObject _target = PathSystem.GetClosestWaypoint(go, _Waypoints); PathFollower follower = go.GetComponent <PathFollower>(); // Update destination follower.destination = PathSystem.ComputeDestination(_target.transform.position, _EndWaypoints); move.target = _target.transform.position; // Update decision macrophage.lastDescision = DECISIONS.FOLLOW_PATH; } } }
/// <summary> /// This is a copy paste of the original <see cref="Survival.Eat(GameObject)"/> because there are too many things to transpile /// </summary> /// <param name="__instance"></param> /// <param name="useObj"></param> private void NewPrefixPatch(Survival __instance, GameObject useObj) { flag = false; if (useObj != null) { Eatable component = useObj.GetComponent <Eatable>(); if (component != null) { if (component.GetFoodValue() != 0f) { float miniFoodOverfill = __instance.GetStomachSize() - 1; if (__instance.food <= miniFoodOverfill) { __instance.food = Mathf.Clamp(__instance.food + component.GetFoodValue(), 0f, __instance.GetStomachOverfillSize()); } __instance.onEat.Trigger(component.GetFoodValue()); if (component.GetFoodValue() > 0f) { GoalManager.main.OnCustomGoalEvent("Eat_Something"); } flag = true; } if (component.GetWaterValue() != 0f) { float minWaterOverfill = __instance.GetWaterCapacity() - 1; if (__instance.water <= minWaterOverfill) { __instance.water = Mathf.Clamp(__instance.water + component.GetWaterValue(), 0f, __instance.GetWaterOverfillSize()); } __instance.onDrink.Trigger(component.GetWaterValue()); if (component.GetWaterValue() > 0f) { GoalManager.main.OnCustomGoalEvent("Drink_Something"); } flag = true; } var lowFoodThreshold = __instance.GetLowFoodThreshold(); var lowWaterThreshold = __instance.GetLowWaterThreshold(); bool foodOkay = (__instance.food > lowFoodThreshold && __instance.food - component.GetFoodValue() < lowFoodThreshold); bool waterOkay = (__instance.water > lowWaterThreshold && __instance.water - component.GetWaterValue() < lowWaterThreshold); if (foodOkay || waterOkay) { __instance.vitalsOkNotification.Play(); } } if (flag) { TechType techType = CraftData.GetTechType(useObj); if (techType == TechType.None) { Pickupable component2 = useObj.GetComponent <Pickupable>(); if (component2) { techType = component2.GetTechType(); } } FMODUWE.PlayOneShot(CraftData.GetUseEatSound(techType), Player.main.transform.position, 1f); if (techType == TechType.Bladderfish) { Player.main.GetComponent <OxygenManager>().AddOxygen(__instance.GetO2FromBlatterfish()); } } } }
public void Eat(Eatable food) { Health += food.FoodValue; food.Delete(); }
public static void Postfix(Eatable __instance, ref float __result) { if (Config.FOOD_OMNIVORE.Equals(DeathRun.config.foodChallenge)) { return; } TechType t = CraftData.GetTechType(__instance.gameObject); if (Config.FOOD_VEGAN.Equals(DeathRun.config.foodChallenge) || Config.FOOD_PESCATARIAN.Equals(DeathRun.config.foodChallenge)) { if (t == TechType.NutrientBlock) { __result = -25f; return; } if (t == TechType.Snack1) { __result = -25f; return; } if (Config.FOOD_PESCATARIAN.Equals(DeathRun.config.foodChallenge)) { if ((t == TechType.Snack2) || (t == TechType.Snack3)) { __result = -25f; return; } } } if ((t == TechType.CookedPeeper) || (t == TechType.Peeper) || (t == TechType.CuredPeeper) || (t == TechType.CookedHoleFish) || (t == TechType.HoleFish) || (t == TechType.CuredHoleFish) || (t == TechType.CookedGarryFish) || (t == TechType.GarryFish) || (t == TechType.CuredGarryFish) || (t == TechType.CookedReginald) || (t == TechType.Reginald) || (t == TechType.CuredReginald) || (t == TechType.CookedBladderfish) || (t == TechType.Bladderfish) || (t == TechType.CuredBladderfish) || (t == TechType.CookedHoverfish) || (t == TechType.Hoverfish) || (t == TechType.CuredHoverfish) || (t == TechType.CookedSpadefish) || (t == TechType.Spadefish) || (t == TechType.CuredSpadefish) || (t == TechType.CookedBoomerang) || (t == TechType.Boomerang) || (t == TechType.CuredBoomerang) || (t == TechType.CookedLavaBoomerang) || (t == TechType.LavaBoomerang) || (t == TechType.CuredLavaBoomerang) || (t == TechType.CookedEyeye) || (t == TechType.Eyeye) || (t == TechType.CuredEyeye) || (t == TechType.CookedLavaEyeye) || (t == TechType.LavaEyeye) || (t == TechType.CuredLavaEyeye) || (t == TechType.CookedOculus) || (t == TechType.Oculus) || (t == TechType.CuredOculus) || (t == TechType.CookedHoopfish) || (t == TechType.Hoopfish) || (t == TechType.CuredHoopfish) || (t == TechType.CookedSpinefish) || (t == TechType.Spinefish) || (t == TechType.CuredSpinefish)) { if (!Config.FOOD_PESCATARIAN.Equals(DeathRun.config.foodChallenge)) { __result = -25f; } } else { if (Config.FOOD_PESCATARIAN.Equals(DeathRun.config.foodChallenge) && (__result > 0)) { __result = -25f; } } }