Inheritance: ParticleBehavior
Exemplo n.º 1
0
        internal static void AddTotalCurrentLiters(float liters, GearItem excludeItem)
        {
            float remaining = liters;

            foreach (GameObject eachItem in GameManager.GetInventoryComponent().m_Items)
            {
                GearItem gearItem = eachItem.GetComponent <GearItem>();
                if (gearItem == null || gearItem == excludeItem)
                {
                    continue;
                }

                LiquidItem liquidItem = gearItem.m_LiquidItem;
                if (liquidItem == null || liquidItem.m_LiquidType != GearLiquidTypeEnum.Kerosene)
                {
                    continue;
                }

                float previousLiters = liquidItem.m_LiquidLiters;
                liquidItem.m_LiquidLiters = Mathf.Clamp(liquidItem.m_LiquidLiters + remaining, 0, liquidItem.m_LiquidCapacityLiters);
                float transferred = liquidItem.m_LiquidLiters - previousLiters;

                remaining -= transferred;

                if (Mathf.Abs(remaining) < MIN_LITERS)
                {
                    break;
                }
            }
        }
        internal static void Prefix(GearItem gi, ref bool __result)
        {
            if (gi == null)
            {
                return;
            }

            LiquidItem liquidItem = gi.m_LiquidItem;

            if (liquidItem == null || liquidItem.m_LiquidType != GearLiquidTypeEnum.Water)
            {
                return;
            }

            WaterSupply waterSupply = liquidItem.GetComponent <WaterSupply>();

            if (waterSupply == null)
            {
                waterSupply      = liquidItem.gameObject.AddComponent <WaterSupply>();
                gi.m_WaterSupply = waterSupply;
            }

            waterSupply.m_VolumeInLiters     = liquidItem.m_LiquidLiters;
            waterSupply.m_WaterQuality       = liquidItem.m_LiquidQuality;
            waterSupply.m_TimeToDrinkSeconds = liquidItem.m_TimeToDrinkSeconds;
            waterSupply.m_DrinkingAudio      = liquidItem.m_DrinkingAudio;
        }
        internal static void Prefix(ref GearItem gi, float volumeAvailable, ref bool __result)
        {
            //Added for replacing transpiler patch:
            //ref to gi
            //float volumeAvailable
            //this if clause
            if (UpdateInspectGearTracker.isExecuting && volumeAvailable > 0f)
            {
                gi = GameManager.GetPlayerManagerComponent().m_Gear;
            }

            if (!WaterUtils.IsWaterItem(gi))
            {
                return;
            }

            LiquidItem liquidItem = gi.m_LiquidItem;

            WaterSupply waterSupply = liquidItem.GetComponent <WaterSupply>();

            if (waterSupply == null)
            {
                waterSupply      = liquidItem.gameObject.AddComponent <WaterSupply>();
                gi.m_WaterSupply = waterSupply;
            }

            waterSupply.m_VolumeInLiters     = liquidItem.m_LiquidLiters;
            waterSupply.m_WaterQuality       = liquidItem.m_LiquidQuality;
            waterSupply.m_TimeToDrinkSeconds = liquidItem.m_TimeToDrinkSeconds;
            waterSupply.m_DrinkingAudio      = liquidItem.m_DrinkingAudio;
        }
        internal static void Postfix(GameObject go)
        {
            LiquidItem liquidItem = go.GetComponent <LiquidItem>();

            if (liquidItem && liquidItem.m_LiquidType == GearLiquidTypeEnum.Water)
            {
                Water.AdjustWaterSupplyToWater();
            }
        }
        internal static void Prefix(Inventory __instance, GameObject go)
        {
            LiquidItem liquidItem = go.GetComponent <LiquidItem>();

            if (liquidItem && liquidItem.m_LiquidType == GearLiquidTypeEnum.Water)
            {
                liquidItem.m_LiquidType = ModWater;
            }
        }
        internal static void Postfix(GearItem __instance)
        {
            LiquidItem liquidItem = __instance.m_LiquidItem;

            if (liquidItem && liquidItem.m_LiquidType == GearLiquidTypeEnum.Water)
            {
                WaterUtils.UpdateWaterBottle(__instance);
            }
        }
Exemplo n.º 7
0
 private static void Postfix(LiquidItem __instance)
 {
     if (!ModComponentMain.Settings.instance.randomPlasticWaterBottles && (__instance.name == "GEAR_Water500ml" || __instance.name == "GEAR_Water1000ml"))
     {
         return;
     }
     if (__instance.m_RandomizeQuantity && __instance.m_LiquidType == GearLiquidTypeEnum.Water)
     {
         __instance.m_LiquidLiters = ModComponentUtils.RandomUtils.Range(__instance.m_LiquidCapacityLiters / 8f, __instance.m_LiquidCapacityLiters);
     }
 }
        internal static string GetWaterSuffix(LiquidItem liquidItem)
        {
            if (Water.IsEmpty(liquidItem))
            {
                return("_empty");
            }

            if (liquidItem.m_LiquidQuality == LiquidQuality.NonPotable)
            {
                return("_nonpotable");
            }

            return("_potable");
        }
Exemplo n.º 9
0
        private static void OnFillFinished(bool success, bool playerCancel, float progress)
        {
            //MelonLoader.MelonLogger.Log("Fill Finished");
            LiquidItem liquidItem = WaterButtons.currentLiquidItemShowing;
            // Remove water and adjust the water supply.
            float maxWaterInBottle   = Mathf.Min(Water.GetActual(liquidItem.m_LiquidQuality), liquidItem.m_LiquidCapacityLiters);
            float maximumWaterRefuel = maxWaterInBottle - liquidItem.m_LiquidLiters;
            float finalWaterRefuel   = maximumWaterRefuel * progress;
            float finalWaterInBottle = finalWaterRefuel + liquidItem.m_LiquidLiters;

            liquidItem.m_LiquidLiters = 0;
            Water.WATER.Remove(finalWaterRefuel, liquidItem.m_LiquidQuality);
            liquidItem.m_LiquidLiters = finalWaterInBottle;
        }
        internal static bool Prefix(GearItem gi, ref Texture2D __result)
        {
            LiquidItem liquidItem = gi.m_LiquidItem;

            if (!liquidItem || liquidItem.m_LiquidType != GearLiquidTypeEnum.Water)
            {
                return(true);
            }

            string textureName = gi.name.Replace("GEAR_", "ico_GearItem__") + WaterUtils.GetWaterSuffix(liquidItem);

            __result = Utils.GetInventoryGridIconTexture(textureName);

            return(__result == null);
        }
        private static void UpdateWaterBottleTexture(LiquidItem liquidItem)
        {
            Texture texture = GetTexture(liquidItem);

            Renderer[] renderers = liquidItem.GetComponentsInChildren <Renderer>();
            foreach (Renderer eachRenderer in renderers)
            {
                foreach (Material eachMaterial in eachRenderer.materials)
                {
                    if ("GEAR_WaterBottle_Mat (Instance)" == eachMaterial.name)
                    {
                        eachMaterial.mainTexture = texture;
                    }
                }
            }
        }
Exemplo n.º 12
0
        private static void ConfigureLiquidItem(ModComponent modComponent)
        {
            ModLiquidItemComponent modLiquidItemComponent = modComponent as ModLiquidItemComponent;

            if (modLiquidItemComponent == null)
            {
                return;
            }

            LiquidItem liquidItem = ModUtils.GetOrCreateComponent <LiquidItem>(modComponent);

            liquidItem.m_LiquidCapacityLiters = modLiquidItemComponent.MaxLiters;
            liquidItem.m_LiquidType           = ModUtils.TranslateEnumValue <GearLiquidTypeEnum, LiquidType>(modLiquidItemComponent.LiquidType);
            liquidItem.m_RandomizeQuantity    = false;
            liquidItem.m_LiquidLiters         = 0;
            liquidItem.m_DrinkingAudio        = "Play_DrinkWater";
            liquidItem.m_TimeToDrinkSeconds   = 4;
        }
Exemplo n.º 13
0
        internal static void Postfix(WaterSupply ws, bool __result)
        {
            if (GameManager.GetThirstComponent().IsAddingThirstOverTime())
            {
                return;
            }

            LiquidItem liquidItem = ws.GetComponent <LiquidItem>();

            if (liquidItem == null)
            {
                return;
            }

            liquidItem.m_LiquidLiters = ws.m_VolumeInLiters;
            Object.Destroy(ws);
            liquidItem.GetComponent <GearItem>().m_WaterSupply = null;
        }
Exemplo n.º 14
0
        internal static void Configure(ModComponent modComponent)
        {
            ModLiquidComponent modLiquidComponent = modComponent.TryCast <ModLiquidComponent>();

            if (modLiquidComponent is null)
            {
                return;
            }

            LiquidItem liquidItem = ModComponentUtils.ComponentUtils.GetOrCreateComponent <LiquidItem>(modComponent);

            liquidItem.m_LiquidCapacityLiters = modLiquidComponent.LiquidCapacityLiters;
            liquidItem.m_LiquidType           = ModComponentUtils.EnumUtils.TranslateEnumValue <GearLiquidTypeEnum, LiquidType>(modLiquidComponent.LiquidType);
            liquidItem.m_RandomizeQuantity    = modLiquidComponent.RandomizeQuantity;
            liquidItem.m_LiquidLiters         = modLiquidComponent.LiquidLiters;
            liquidItem.m_DrinkingAudio        = "Play_DrinkWater";
            liquidItem.m_TimeToDrinkSeconds   = 4;
            liquidItem.m_LiquidQuality        = LiquidQuality.Potable;
        }
Exemplo n.º 15
0
        public void Update()
        {
            liquidItems.Clear();

            Inventory inventory = GameManager.GetInventoryComponent();

            foreach (GameObject eachItem in inventory.m_Items)
            {
                LiquidItem liquidItem = eachItem.GetComponent <LiquidItem>();
                if (liquidItem == null || liquidItem.m_LiquidType != GearLiquidTypeEnum.Water)
                {
                    continue;
                }

                liquidItems.Add(liquidItem);
            }

            UpdateAmounts();
            UpdateBottles();
        }
Exemplo n.º 16
0
        private static void OnDumpFinished(bool success, bool playerCancel, float progress)
        {
            //MelonLoader.MelonLogger.Log("Dump Finished");
            LiquidItem liquidItem = WaterButtons.currentLiquidItemShowing;
            float      lostLiters = liquidItem.m_LiquidLiters * progress;

            if (liquidItem.m_LiquidQuality == LiquidQuality.Potable)             // Potable water
            {
                WaterSupply potableWaterSupply = GameManager.GetInventoryComponent().GetPotableWaterSupply().m_WaterSupply;
                Water.ShowLostMessage(potableWaterSupply, "GAMEPLAY_WaterPotable", lostLiters);
            }
            else             // NonPotable water
            {
                WaterSupply nonPotableWaterSupply = GameManager.GetInventoryComponent().GetNonPotableWaterSupply().m_WaterSupply;
                Water.ShowLostMessage(nonPotableWaterSupply, "GAMEPLAY_WaterUnsafe", lostLiters);
            }

            // Remove water and adjust the water supply.
            liquidItem.m_LiquidLiters = Mathf.Max(liquidItem.m_LiquidLiters - lostLiters, 0);
            Water.AdjustWaterSupplyToWater();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Updates the list of water containers in the inventory
        /// Recalculates the total amounts of water held and the total capacities for each type
        /// Updates the sound and texture of each water bottle in the inventory
        /// </summary>
        public void Update()
        {
            liquidItems.Clear();

            Inventory inventory = GameManager.GetInventoryComponent();

            foreach (GameObject eachItem in inventory.m_Items)
            {
                LiquidItem liquidItem = eachItem.GetComponent <LiquidItem>();
                //if not a liquid item or not a water container
                if (liquidItem == null || liquidItem.m_LiquidType != GearLiquidTypeEnum.Water)
                {
                    continue;                     // move to the next item
                }
                //else add it to the list of water containers
                liquidItems.Add(liquidItem);
            }

            UpdateAmounts();
            UpdateBottles();
        }
Exemplo n.º 18
0
        private static void OnDump()
        {
            //MelonLoader.MelonLogger.Log("Dump");
            LiquidItem liquidItem = WaterButtons.currentLiquidItemShowing;

            if (liquidItem == null)
            {
                return;
            }
            if (liquidItem.m_LiquidLiters <= 0.001f)
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BWM_Empty"));
                GameAudioManager.PlayGUIError();
                return;
            }

            GameAudioManager.PlayGuiConfirm();
            float lostLitersDuration = Mathf.Max(liquidItem.m_LiquidLiters * 4, 1);

            InterfaceManager.m_Panel_GenericProgressBar.Launch(Localization.Get("GAMEPLAY_BWM_DumpingProgress"), lostLitersDuration, 0f, 0f,
                                                               "Play_SndActionRefuelLantern", null, false, true, new System.Action <bool, bool, float>(OnDumpFinished));
        }
        internal static void Postfix(PlayerManager __instance)
        {
            WaterSupply waterSupply = AccessTools.Field(__instance.GetType(), "m_WaterSourceToDrinkFrom").GetValue(__instance) as WaterSupply;

            if (waterSupply == null)
            {
                return;
            }

            LiquidItem liquidItem = waterSupply.GetComponent <LiquidItem>();

            if (liquidItem == null)
            {
                return;
            }

            liquidItem.m_LiquidLiters = waterSupply.m_VolumeInLiters;
            UnityEngine.Object.Destroy(waterSupply);
            liquidItem.GetComponent <GearItem>().m_WaterSupply = null;

            Water.AdjustWaterSupplyToWater();
        }
        internal static void Postfix(GearItem gearItem, ref string __result)
        {
            LiquidItem liquidItem = gearItem.m_LiquidItem;

            if (!liquidItem || liquidItem.m_LiquidType != GearLiquidTypeEnum.Water)
            {
                return;
            }

            if (Water.IsEmpty(liquidItem))
            {
                __result += " - " + Localization.Get("GAMEPLAY_Empty");
            }
            else if (liquidItem.m_LiquidQuality == LiquidQuality.Potable)
            {
                __result += " - " + Localization.Get("GAMEPLAY_WaterPotable");
            }
            else
            {
                __result += " - " + Localization.Get("GAMEPLAY_WaterUnsafe");
            }
        }
Exemplo n.º 21
0
        internal static float GetTotalCurrentLiters(GearItem excludeItem)
        {
            float result = 0;

            foreach (GameObject eachItem in GameManager.GetInventoryComponent().m_Items)
            {
                GearItem gearItem = eachItem.GetComponent <GearItem>();
                if (gearItem == null || gearItem == excludeItem)
                {
                    continue;
                }

                LiquidItem liquidItem = gearItem.m_LiquidItem;
                if (liquidItem == null || liquidItem.m_LiquidType != GearLiquidTypeEnum.Kerosene)
                {
                    continue;
                }

                result += liquidItem.m_LiquidLiters;
            }

            return(result);
        }
 private static Texture GetTexture(LiquidItem liquidItem)
 {
     return(Resources.Load("Textures/GEAR_WaterBottle" + GetWaterSuffix(liquidItem)) as Texture);
 }
Exemplo n.º 23
0
 internal static bool IsEmpty(LiquidItem liquidItem)
 {
     return(IsNone(liquidItem.m_LiquidLiters));
 }
    private void OnCollisionEnter(Collision collision)
    {
        // Check for player collision
        if (collision.gameObject.tag == "Player")
        {
            player.GetComponent <PlayerController>().RemoveObserver(this);

            Collider[] colliders = gameObject.GetComponents <Collider>();
            foreach (Collider collider in colliders)
            {
                colliderItems.Remove(collider.gameObject);
                collider.enabled = false;
            }

            foreach (Transform child in transform)
            {
                child.GetComponent <MeshRenderer>().enabled = false;
            }

            if (gameObject.GetComponent <MeshRenderer>() != null)
            {
                gameObject.GetComponent <MeshRenderer>().enabled = false;
            }

            ParticleBehavior pb = null;

            switch (itemType)
            {
            case ItemType.BREAD:
                pb = new BreadItem();
                break;

            case ItemType.CAN:
                pb = new CanItem();
                break;

            case ItemType.CHEESE:
                pb = new CheeseItem();
                break;

            case ItemType.FRUIT:
                pb = new FruitItem();
                break;

            case ItemType.LIQUID:
                pb = new LiquidItem();
                break;

            case ItemType.MEAT:
                pb = new MeatItem();
                break;

            case ItemType.SHELF:
                pb = new ShelfItem();
                break;
            }

            if (gameObject.transform.parent == true)
            {
                pb.InstantiateParticles(collision.contacts[0].point, gameObject.transform.parent.gameObject);
            }
            else
            {
                pb.InstantiateParticles(collision.contacts[0].point, gameObject);
            }
        }
    }