예제 #1
0
        internal static bool Prefix(PlayerManager __instance, GearItem gi)
        {
            if (ModUtils.GetComponent <FirstPersonItem>(gi) != null)
            {
                return(true);
            }

            if (ModUtils.GetEquippableModComponent(gi) == null)
            {
                return(true);
            }

            var currentGi = __instance.m_ItemInHands;

            if (currentGi != null)
            {
                __instance.UnequipItemInHands();
            }

            if (gi != currentGi)
            {
                __instance.EquipItem(gi, false);
            }

            return(false);
        }
예제 #2
0
        private static GearTypeEnum GetGearType(ModComponent modComponent)
        {
            if (modComponent.InventoryCategory != InventoryCategory.Auto)
            {
                return(ModUtils.TranslateEnumValue <GearTypeEnum, InventoryCategory>(modComponent.InventoryCategory));
            }

            if (modComponent is ModToolComponent)
            {
                return(GearTypeEnum.Tool);
            }

            if (modComponent is ModFoodComponent || modComponent is ModCookableComponent || (modComponent as ModLiquidItemComponent)?.LiquidType == LiquidType.Water)
            {
                return(GearTypeEnum.Food);
            }

            if (modComponent is ModClothingComponent)
            {
                return(GearTypeEnum.Clothing);
            }

            if (ModUtils.GetComponent <ModFireStartingComponent>(modComponent) != null || ModUtils.GetComponent <ModBurnableComponent>(modComponent) != null)
            {
                return(GearTypeEnum.Firestarting);
            }

            return(GearTypeEnum.Other);
        }
예제 #3
0
 public static void Prefix(bool enable)
 {
     if (enable)
     {
         PlayerManager playerManager = GameManager.GetPlayerManagerComponent();
         GearEquipper.Unequip(ModUtils.GetComponent <EquippableModComponent>(playerManager.m_ItemInHands));
     }
 }
        internal static void Postfix(GearItem gi)
        {
            ModClothingComponent modClothingComponent = ModUtils.GetComponent <ModClothingComponent>(gi);

            modClothingComponent?.OnTakeOff?.Invoke();

            Implementation.UpdateWolfIntimidationBuff();
        }
예제 #5
0
        public static void Prefix(FoodItem fi, ref float calories)
        {
            ModFoodComponent modFoodComponent = ModUtils.GetComponent <ModFoodComponent>(fi);

            if (modFoodComponent != null && modFoodComponent.Servings > 1)
            {
                calories = Math.Min(calories, (float)modFoodComponent.Calories / modFoodComponent.Servings);
            }
        }
예제 #6
0
        private static void MapBlueprint(GameObject prefab, string sourcePath)
        {
            ModBlueprint modBlueprint = ModUtils.GetComponent <ModBlueprint>(prefab);

            if (modBlueprint != null)
            {
                Mapper.RegisterBlueprint(modBlueprint, sourcePath);
            }
        }
예제 #7
0
        public static void Postfix(GearItem __instance, float normalizedValue)
        {
            AlcoholComponent alcoholComponent = ModUtils.GetComponent <AlcoholComponent>(__instance);

            if (alcoholComponent != null)
            {
                alcoholComponent.Apply(normalizedValue);
            }
        }
예제 #8
0
        private static void MapSkill(GameObject prefab)
        {
            ModSkill modSkill = ModUtils.GetComponent <ModSkill>(prefab);

            if (modSkill != null)
            {
                Mapper.RegisterSkill(modSkill);
            }
        }
예제 #9
0
        public static void Postfix(FatigueBuff __instance)
        {
            GearItem gearItem = ModUtils.GetComponent <GearItem>(__instance);

            if (gearItem != null)
            {
                BuffCauseTracker.setCause(AfflictionType.ReducedFatigue, gearItem.m_LocalizedDisplayName.Text());
            }
        }
예제 #10
0
        public static void Postfix(FoodItem __instance)
        {
            AlcoholComponent alcoholComponent = ModUtils.GetComponent <AlcoholComponent>(__instance);

            if (alcoholComponent != null)
            {
                alcoholComponent.AmountRemaining = __instance.m_CaloriesRemaining / __instance.m_CaloriesTotal * alcoholComponent.AmountTotal;
            }
        }
        public static void Prefix(vp_MuzzleFlash __instance, ref Transform tr)
        {
            PlayerManager            playerManager = GameManager.GetPlayerManagerComponent();
            ModAnimationStateMachine animation     = ModUtils.GetComponent <ModAnimationStateMachine>(playerManager.m_ItemInHands);

            if (animation != null)
            {
                tr = GameManager.GetVpFPSCamera().CurrentShooter.MuzzleFlash.transform.parent;
            }
        }
예제 #12
0
        internal static bool Prefix(PlayerManager __instance)
        {
            AlternativeAction alternativeAction = ModUtils.GetComponent <AlternativeAction>(__instance.m_InteractiveObjectUnderCrosshair);

            if (alternativeAction == null)
            {
                return(true);
            }

            alternativeAction.Execute();
            return(false);
        }
예제 #13
0
            public static bool Prefix()
            {
                PlayerManager            playerManager = GameManager.GetPlayerManagerComponent();
                ModAnimationStateMachine animation     = ModUtils.GetComponent <ModAnimationStateMachine>(playerManager.m_ItemInHands);

                if (animation == null)
                {
                    return(true);
                }

                return(false);
            }
예제 #14
0
            public static bool Prefix(OnAnimationEvent onAnimationComplete)
            {
                PlayerManager            playerManager = GameManager.GetPlayerManagerComponent();
                ModAnimationStateMachine animation     = ModUtils.GetComponent <ModAnimationStateMachine>(playerManager.m_ItemInHands);

                if (animation == null)
                {
                    return(true);
                }

                animation.TransitionToAndFire(FromAiming, onAnimationComplete);
                return(false);
            }
예제 #15
0
            public static bool Prefix(ref bool __result)
            {
                PlayerManager            playerManager = GameManager.GetPlayerManagerComponent();
                ModAnimationStateMachine animation     = ModUtils.GetComponent <ModAnimationStateMachine>(playerManager.m_ItemInHands);

                if (animation == null)
                {
                    return(true);
                }

                __result = animation.GetFirstPersonWeaponCanSwitch();
                return(false);
            }
예제 #16
0
            public static bool Prefix(PlayerAnimation __instance, PlayerAnimation.State state, ref bool __result)
            {
                PlayerManager            playerManager = GameManager.GetPlayerManagerComponent();
                ModAnimationStateMachine animation     = ModUtils.GetComponent <ModAnimationStateMachine>(playerManager.m_ItemInHands);

                if (animation == null)
                {
                    return(true);
                }

                __result = animation.CanTransitionTo(state);
                return(false);
            }
예제 #17
0
        public static bool Prefix(ClothingSlot __instance)
        {
            ModClothingComponent clothingComponent = ModUtils.GetComponent <ModClothingComponent>(__instance.m_GearItem);

            if (clothingComponent == null)
            {
                return(true);
            }

            int actualDrawLayer = Mathf.Max(40, clothingComponent.DrawLayer);

            ModUtils.ExecuteMethod(__instance, "UpdatePaperDollTextureLayer", actualDrawLayer);

            return(false);
        }
        public static void Postfix(vp_FPSShooter __instance)
        {
            PlayerManager            playerManager = GameManager.GetPlayerManagerComponent();
            ModAnimationStateMachine animation     = ModUtils.GetComponent <ModAnimationStateMachine>(playerManager.m_ItemInHands);

            if (animation == null)
            {
                return;
            }

            if (__instance.MuzzleFlash != null)
            {
                __instance.MuzzleFlash.transform.localPosition = Vector3.zero;
            }
        }
예제 #19
0
            public static bool Prefix()
            {
                PlayerManager            playerManager = GameManager.GetPlayerManagerComponent();
                ModAnimationStateMachine animation     = ModUtils.GetComponent <ModAnimationStateMachine>(playerManager.m_ItemInHands);

                if (animation == null)
                {
                    return(true);
                }

                animation.TransitionTo(Firing);
                GameManager.GetVpFPSCamera().AddForce2(0f, 0.25f, 0.25f);

                return(false);
            }
예제 #20
0
        private static void ConfigureAccelerant(ModComponent modComponent)
        {
            ModAccelerantComponent modAccelerantComponent = ModUtils.GetComponent <ModAccelerantComponent>(modComponent);

            if (modAccelerantComponent == null)
            {
                return;
            }

            FireStarterItem fireStarterItem = ModUtils.GetOrCreateComponent <FireStarterItem>(modAccelerantComponent);

            fireStarterItem.m_IsAccelerant = true;
            fireStarterItem.m_FireStartDurationModifier = modAccelerantComponent.DurationOffset;
            fireStarterItem.m_FireStartSkillModifier    = modAccelerantComponent.SuccessModifier;
            fireStarterItem.m_ConsumeOnUse = modAccelerantComponent.DestroyedOnUse;
        }
예제 #21
0
        private static void ConfigureBurnable(ModComponent modComponent)
        {
            ModBurnableComponent modBurnableComponent = ModUtils.GetComponent <ModBurnableComponent>(modComponent);

            if (modBurnableComponent == null)
            {
                return;
            }

            FuelSourceItem fuelSourceItem = ModUtils.GetOrCreateComponent <FuelSourceItem>(modComponent);

            fuelSourceItem.m_BurnDurationHours          = modBurnableComponent.BurningMinutes / 60f;
            fuelSourceItem.m_FireAgeMinutesBeforeAdding = modBurnableComponent.BurningMinutesBeforeAllowedToAdd;
            fuelSourceItem.m_FireStartSkillModifier     = modBurnableComponent.SuccessModifier;
            fuelSourceItem.m_HeatIncrease    = modBurnableComponent.TempIncrease;
            fuelSourceItem.m_HeatInnerRadius = 2.5f;
            fuelSourceItem.m_HeatOuterRadius = 6f;
        }
예제 #22
0
            public static bool Prefix(float fatigue)
            {
                PlayerManager            playerManager = GameManager.GetPlayerManagerComponent();
                ModAnimationStateMachine animation     = ModUtils.GetComponent <ModAnimationStateMachine>(playerManager.m_ItemInHands);

                if (animation == null)
                {
                    return(true);
                }

                var          camera        = GameManager.GetVpFPSCamera();
                vp_FPSWeapon currentWeapon = camera.CurrentWeapon;

                if (currentWeapon != null)
                {
                    currentWeapon.ShakeSpeed     = 0.5f;
                    currentWeapon.ShakeAmplitude = MAX_SHAKE_AMPLITUDE * fatigue;
                }

                return(false);
            }
예제 #23
0
        private static void ConfigureFireStarter(ModComponent modComponent)
        {
            ModFireStarterComponent modFireStarterComponent = ModUtils.GetComponent <ModFireStarterComponent>(modComponent);

            if (modFireStarterComponent == null)
            {
                return;
            }

            FireStarterItem fireStarterItem = ModUtils.GetOrCreateComponent <FireStarterItem>(modFireStarterComponent);

            fireStarterItem.m_SecondsToIgniteTinder = modFireStarterComponent.SecondsToIgniteTinder;
            fireStarterItem.m_SecondsToIgniteTorch  = modFireStarterComponent.SecondsToIgniteTorch;

            fireStarterItem.m_FireStartSkillModifier = modFireStarterComponent.SuccessModifier;

            fireStarterItem.m_ConditionDegradeOnUse = GetDecayPerStep(modFireStarterComponent.NumberOfUses, modComponent.MaxHP);
            fireStarterItem.m_ConsumeOnUse          = modFireStarterComponent.DestroyedOnUse;
            fireStarterItem.m_RequiresSunLight      = modFireStarterComponent.RequiresSunLight;
            fireStarterItem.m_OnUseSoundEvent       = modFireStarterComponent.OnUseSoundEvent;
        }
        internal static void Postfix(FireStarterItem starter, bool __result)
        {
            if (!__result)
            {
                return;
            }

            ModFireStarterComponent modFireStarterComponent = ModUtils.GetComponent <ModFireStarterComponent>(starter);

            if (modFireStarterComponent == null || !modFireStarterComponent.RuinedAfterUse)
            {
                return;
            }

            GearItem gearItem = starter.GetComponent <GearItem>();

            if (gearItem != null)
            {
                gearItem.BreakOnUse();
            }
        }
예제 #25
0
            public static bool Prefix(int bulletsToReload, OnAnimationEvent roundLoadedEventCallback, OnAnimationEvent clipLoadedEventCallback, OnAnimationEvent reloadCompleteEventCallback)
            {
                PlayerManager            playerManager = GameManager.GetPlayerManagerComponent();
                ModAnimationStateMachine animation     = ModUtils.GetComponent <ModAnimationStateMachine>(playerManager.m_ItemInHands);

                if (animation == null)
                {
                    return(true);
                }

                ReloadProcess process = new ReloadProcess();

                process.remainingBullets            = bulletsToReload;
                process.reloadCompleteEventCallback = reloadCompleteEventCallback;
                process.roundLoadedEventCallback    = roundLoadedEventCallback;
                process.clipLoadedEventCallback     = clipLoadedEventCallback;
                process.animation = animation;
                process.Start();

                return(false);
            }
예제 #26
0
        private static void ConfigureHarvestable(ModComponent modComponent)
        {
            ModHarvestableComponent modHarvestableComponent = ModUtils.GetComponent <ModHarvestableComponent>(modComponent);

            if (modHarvestableComponent == null)
            {
                return;
            }

            Harvest harvest = ModUtils.GetOrCreateComponent <Harvest>(modHarvestableComponent);

            harvest.m_Audio           = modHarvestableComponent.Audio;
            harvest.m_DurationMinutes = modHarvestableComponent.Minutes;

            if (modHarvestableComponent.YieldNames.Length != modHarvestableComponent.YieldCounts.Length)
            {
                throw new ArgumentException("YieldNames and YieldCounts do not have the same length on gear item '" + modHarvestableComponent.name + "'.");
            }

            harvest.m_YieldGear      = ModUtils.GetItems <GearItem>(modHarvestableComponent.YieldNames, modHarvestableComponent.name);
            harvest.m_YieldGearUnits = modHarvestableComponent.YieldCounts;
        }
예제 #27
0
        private static void ConfigureStackable(ModComponent modComponent)
        {
            ModStackableComponent modStackableComponent = ModUtils.GetComponent <ModStackableComponent>(modComponent);

            if (modStackableComponent == null)
            {
                return;
            }

            StackableItem stackableItem = ModUtils.GetOrCreateComponent <StackableItem>(modComponent);

            stackableItem.m_LocalizedMultipleUnitText = new LocalizedString {
                m_LocalizationID = modStackableComponent.MultipleUnitText
            };
            stackableItem.m_LocalizedSingleUnitText = new LocalizedString {
                m_LocalizationID = modComponent.DisplayNameLocalizationId
            };

            stackableItem.m_StackSpriteName = modStackableComponent.StackSprite;

            stackableItem.m_ShareStackWithGear = new StackableItem[0];
            stackableItem.m_Units        = 1;
            stackableItem.m_UnitsPerItem = 1;
        }
예제 #28
0
        internal static void Postfix(GearItem gi)
        {
            ModClothingComponent modClothingComponent = ModUtils.GetComponent <ModClothingComponent>(gi);

            modClothingComponent?.OnTakeOff?.Invoke();
        }
예제 #29
0
 public static void Postfix(GearItem gi, ref bool __result)
 {
     // guns can always be examined
     __result |= ModUtils.GetComponent <GunItem>(gi) != null;
 }