protected void ReloadCharacterNew()
        {
            //base.ReloadCharacter();
            if (base.CharacterObject == null)
            {
                return;
            }
            //this.m_enableDifficultyIndicators = (GameState.Option.LevelScaling == LevelScalingOption.None && GameState.Option.ShowDifficultyIndicators);
            m_enableDifficultyIndicators = true; // always force

            Destructible component = ComponentUtils.GetComponent <Destructible>(base.CharacterObject as MonoBehaviour);

            if (component != null || SingletonBehavior <PartyManager> .Instance.IsActivePartyMember(base.CharacterObject as CharacterStats))
            {
                this.m_sprite.alpha = 0f;
                return;
            }
            if (this.m_onlyIfHostile)
            {
                Faction component2 = ComponentUtils.GetComponent <Faction>(base.CharacterObject as MonoBehaviour);
                if (component2 && component2.GetRelationshipToPlayer() != Relationship.Hostile)
                {
                    this.m_sprite.alpha = 0f;
                    return;
                }
            }
            else
            {
                string levelDifficultySprite = GetLevelDifficultySprite(base.CharacterObject);
                this.m_sprite.spriteName = levelDifficultySprite;
                this.m_sprite.MakePixelPerfect();
                this.m_sprite.alpha = (string.IsNullOrEmpty(levelDifficultySprite) ? 0f : 1f);
            }
        }
        static bool HoveringInteractable(RayEventData eventData, GameObject currentObject, out bool hasScrollHandler)
        {
            hasScrollHandler = false;

            var selectionFlags = ComponentUtils <ISelectionFlags> .GetComponent(currentObject);

            if (selectionFlags != null && selectionFlags.selectionFlags == SelectionFlags.Direct && !UIUtils.IsDirectEvent(eventData))
            {
                return(false);
            }

            hasScrollHandler = ExecuteEvents.GetEventHandler <IScrollHandler>(currentObject);

            return(ExecuteEvents.GetEventHandler <IPointerClickHandler>(currentObject) ||
                   ExecuteEvents.GetEventHandler <IPointerDownHandler>(currentObject) ||
                   ExecuteEvents.GetEventHandler <IPointerUpHandler>(currentObject) ||
                   ExecuteEvents.GetEventHandler <IDragHandler>(currentObject) ||
                   ExecuteEvents.GetEventHandler <IBeginDragHandler>(currentObject) ||
                   ExecuteEvents.GetEventHandler <IEndDragHandler>(currentObject) ||
                   ExecuteEvents.GetEventHandler <IRayDragHandler>(currentObject) ||
                   ExecuteEvents.GetEventHandler <IRayBeginDragHandler>(currentObject) ||
                   ExecuteEvents.GetEventHandler <IRayEndDragHandler>(currentObject) ||
                   ExecuteEvents.GetEventHandler <IRayClickHandler>(currentObject) ||
                   hasScrollHandler);
        }
示例#3
0
        private static void ChangeGameObject(GameObject item)
        {
            if (item is null)
            {
                return;
            }
            string name = NameUtils.NormalizeName(item.name);

            if (!modExistingEntries.ContainsKey(name))
            {
                return;
            }
            ModExistingEntry entry = modExistingEntries[name];

            if (entry.changeWeight)
            {
                ChangeWeight(item, entry.newWeight);
            }
            if (entry.behaviourChanges.Count > 0)
            {
                ProxyObject dict = JSON.Load(JSON.Dump(entry.behaviourChanges)) as ProxyObject;
                ComponentJson.InitializeComponents(ref item, dict);
                if (ComponentUtils.GetComponent <ModComponent>(item) is null)
                {
                    var placeholder = item.AddComponent <ModPlaceHolderComponent>();
                    Mapper.Map(item);
                    UnityEngine.Object.Destroy(placeholder);
                }
                else
                {
                    Mapper.Map(item);
                }
            }
        }
示例#4
0
        internal static float GetScentIntensity(GameObject prefab)
        {
            Scent scent = ComponentUtils.GetComponent <Scent>(prefab);

            if (scent is null)
            {
                return(0f);
            }

            switch (scent.m_ScentCategory)
            {
            case ScentRangeCategory.COOKED_MEAT:
                return(5f);

            case ScentRangeCategory.COOKED_FISH:
                return(5f);

            case ScentRangeCategory.GUTS:
                return(20f);

            case ScentRangeCategory.QUARTER:
                return(50f);

            case ScentRangeCategory.RAW_MEAT:
                return(15f);

            case ScentRangeCategory.RAW_FISH:
                return(15f);

            default:
                return(0f);
            }
        }
示例#5
0
        private static void ChangePrefabs()
        {
            foreach (var pair in modExistingEntries)
            {
                GameObject item = Resources.Load(pair.Key).TryCast <GameObject>();
                if (item is null)
                {
                    continue;
                }

                ModExistingEntry entry = pair.Value;
                if (entry.changeWeight)
                {
                    ChangeWeight(item, entry.newWeight);
                }
                if (entry.behaviourChanges.Count > 0)
                {
                    ProxyObject dict = JSON.Load(JSON.Dump(entry.behaviourChanges)) as ProxyObject;
                    ComponentJson.InitializeComponents(ref item, dict);
                    if (ComponentUtils.GetComponent <ModComponent>(item) is null)
                    {
                        var placeholder = item.AddComponent <ModPlaceHolderComponent>();
                        Mapper.Map(item);
                        UnityEngine.Object.Destroy(placeholder);
                    }
                    else
                    {
                        Mapper.Map(item);
                    }
                }
            }
        }
示例#6
0
        internal static void Configure(GameObject prefab)
        {
            ModMillableComponent modMillable = ComponentUtils.GetComponent <ModMillableComponent>(prefab);

            if (modMillable is null)
            {
                return;
            }

            Millable millable = ComponentUtils.GetOrCreateComponent <Millable>(modMillable);

            millable.m_CanRestoreFromWornOut   = modMillable.CanRestoreFromWornOut;
            millable.m_RecoveryDurationMinutes = modMillable.RecoveryDurationMinutes;
            millable.m_RepairDurationMinutes   = modMillable.RepairDurationMinutes;
            millable.m_Skill = EnumUtils.TranslateEnumValue <SkillType, ModComponentAPI.SkillType>(modMillable.skill);
            if (modMillable.RepairRequiredGear.Length != modMillable.RepairRequiredGearUnits.Length)
            {
                throw new ArgumentException("RepairRequiredGear and RepairRequiredGearUnits do not have the same length on gear item '" + modMillable.name + "'.");
            }
            millable.m_RepairRequiredGear      = ModUtils.GetItems <GearItem>(modMillable.RepairRequiredGear, modMillable.name);
            millable.m_RepairRequiredGearUnits = modMillable.RepairRequiredGearUnits;
            if (modMillable.RestoreRequiredGear.Length != modMillable.RestoreRequiredGearUnits.Length)
            {
                throw new ArgumentException("RestoreRequiredGear and RestoreRequiredGearUnits do not have the same length on gear item '" + modMillable.name + "'.");
            }
            millable.m_RestoreRequiredGear      = ModUtils.GetItems <GearItem>(modMillable.RestoreRequiredGear, modMillable.name);
            millable.m_RestoreRequiredGearUnits = modMillable.RestoreRequiredGearUnits;
        }
示例#7
0
        internal static void Configure(GameObject prefab)
        {
            ModHarvestableComponent modHarvestableComponent = ComponentUtils.GetComponent <ModHarvestableComponent>(prefab);

            if (modHarvestableComponent is null)
            {
                return;
            }

            Harvest harvest = ComponentUtils.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;

            harvest.m_AppliedSkillType = SkillType.None;
            harvest.m_RequiredTools    = ModUtils.GetItems <ToolsItem>(modHarvestableComponent.RequiredToolNames, modHarvestableComponent.name);
            harvest.m_GunpowderYield   = 0f;
        }
示例#8
0
        private static GearTypeEnum GetGearType(ModComponent modComponent)
        {
            if (modComponent.InventoryCategory != InventoryCategory.Auto)
            {
                return(EnumUtils.TranslateEnumValue <GearTypeEnum, InventoryCategory>(modComponent.InventoryCategory));
            }

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

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

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

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

            return(GearTypeEnum.Other);
        }
示例#9
0
        internal static bool Prefix(PlayerManager __instance, GearItem gi)
        {
            if (ComponentUtils.GetComponent <FirstPersonItem>(gi) != null)
            {
                return(true);
            }

            if (ComponentUtils.GetEquippableModComponent(gi) is null)
            {
                return(true);
            }

            var currentGi = __instance.m_ItemInHands;

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

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

            return(false);
        }
示例#10
0
        internal static void Configure(GameObject prefab)
        {
            ModRepairableComponent modRepairableComponent = ComponentUtils.GetComponent <ModRepairableComponent>(prefab);

            if (modRepairableComponent is null)
            {
                return;
            }

            Repairable repairable = ComponentUtils.GetOrCreateComponent <Repairable>(modRepairableComponent);

            repairable.m_RepairAudio       = modRepairableComponent.Audio;
            repairable.m_DurationMinutes   = modRepairableComponent.Minutes;
            repairable.m_ConditionIncrease = modRepairableComponent.Condition;

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

            repairable.m_RequiredGear      = ModUtils.GetItems <GearItem>(modRepairableComponent.MaterialNames, modRepairableComponent.name);
            repairable.m_RequiredGearUnits = modRepairableComponent.MaterialCounts;

            repairable.m_RepairToolChoices    = ModUtils.GetItems <ToolsItem>(modRepairableComponent.RequiredTools, modRepairableComponent.name);
            repairable.m_RequiresToolToRepair = repairable.m_RepairToolChoices.Length > 0;
        }
示例#11
0
        public void SetHighlight(GameObject go, bool active, Transform rayOrigin = null, Material material = null, bool force = false, float duration = 0f)
        {
            if (go == null)
            {
                return;
            }

            if (!force && active && this.IsLocked(go))
            {
                return;
            }

            if (material == null)
            {
                material = rayOrigin ? m_RayHighlightMaterial : m_DefaultHighlightMaterial;
            }

            if (active) // Highlight
            {
                Dictionary <GameObject, HighlightData> highlights;
                if (!m_Highlights.TryGetValue(material, out highlights))
                {
                    highlights             = new Dictionary <GameObject, HighlightData>();
                    m_Highlights[material] = highlights;
                }

                highlights[go] = new HighlightData {
                    startTime = Time.time, duration = duration
                };
            }
            else // Unhighlight
            {
                if (force)
                {
                    // A force removal removes the GameObject regardless of how it was highlighted (e.g. with a specific hand)
                    foreach (var gameObjects in m_Highlights.Values)
                    {
                        gameObjects.Remove(go);
                    }
                }
                else
                {
                    Dictionary <GameObject, HighlightData> highlights;
                    if (m_Highlights.TryGetValue(material, out highlights))
                    {
                        highlights.Remove(go);
                    }
                }

                var skinnedMeshRenderer = ComponentUtils <SkinnedMeshRenderer> .GetComponent(go);

                if (skinnedMeshRenderer)
                {
                    k_BakedMeshes.Remove(skinnedMeshRenderer);
                }
            }
        }
示例#12
0
        void OnDragStarted(GameObject gameObject, TrackedDeviceEventData eventData)
        {
            var droppable = ComponentUtils <IDroppable> .GetComponent(gameObject);

            if (droppable != null)
            {
                m_Droppables[eventData.interactor] = droppable;
            }
        }
示例#13
0
        public void OnDragStarted(GameObject gameObject, RayEventData eventData)
        {
            var droppable = ComponentUtils <IDroppable> .GetComponent(gameObject);

            if (droppable != null)
            {
                m_Droppables[eventData.rayOrigin] = droppable;
            }
        }
        public void GetComponent()
        {
            var gameObject = new GameObject();

            gameObject.AddComponent <MeshFilter>();
            gameObject.AddComponent <BoxCollider>();
            gameObject.AddComponent <MeshRenderer>();
            gameObject.AddComponent <BoxCollider>();
            Assert.AreEqual(gameObject.GetComponent <BoxCollider>(), ComponentUtils <BoxCollider> .GetComponent(gameObject));
        }
示例#15
0
        public void TriggerCountdown()
        {
            ModExplosiveSave explosiveSave = ComponentUtils.GetComponent <ModExplosiveSave>(this);

            if (explosiveSave is null)
            {
                Logger.LogError("Could not trigger countdown. No ModExplosiveSave!");
                return;
            }
            explosiveSave.TriggerCountdown(explosionDelay);
        }
示例#16
0
        private static void ChangeWeight(GameObject item, float newWeight)
        {
            GearItem gearItem = ComponentUtils.GetComponent <GearItem>(item);

            if (gearItem is null)
            {
                Logger.Log("Could not assign new weight. Item has no GearItem component.");
                return;
            }
            gearItem.m_WeightKG = newWeight;
        }
示例#17
0
        private void TriggerExplosion()
        {
            ModExplosiveComponent explosiveComponent = ComponentUtils.GetComponent <ModExplosiveComponent>(this);

            if (explosiveComponent is null)
            {
                Logger.LogError("Could not trigger explosion. No ModExplosiveComponent!");
                return;
            }
            explosiveComponent.OnExplode();
        }
示例#18
0
        internal static void Configure(GameObject prefab)
        {
            ModScentComponent modScentComponent = ComponentUtils.GetComponent <ModScentComponent>(prefab);

            if (modScentComponent is null)
            {
                return;
            }

            Scent scent = ComponentUtils.GetOrCreateComponent <Scent>(modScentComponent);

            scent.m_ScentCategory = EnumUtils.TranslateEnumValue <ScentRangeCategory, ScentCategory>(modScentComponent.scentCategory);
        }
示例#19
0
        public static void Map(GameObject prefab)
        {
            if (prefab is null)
            {
                throw new ArgumentException("The prefab was NULL.");
            }

            ModComponent modComponent = ComponentUtils.GetModComponent(prefab);

            if (modComponent is null)
            {
                throw new ArgumentException("Prefab " + prefab.name + " does not contain a ModComponent.");
            }

            bool hasModPlaceHolder = !(ComponentUtils.GetComponent <ModPlaceHolderComponent>(prefab) is null);

            if (prefab.GetComponent <GearItem>() is null || hasModPlaceHolder)
            {
                ConfigureBehaviours(modComponent);

                EquippableMapper.Configure(modComponent);
                LiquidMapper.Configure(modComponent);
                PowderMapper.Configure(modComponent);
                FoodMapper.Configure(modComponent);
                CookableMapper.Configure(modComponent);
                CookingPotMapper.Configure(modComponent);
                RifleMapper.Configure(modComponent);
                ClothingMapper.Configure(modComponent);
                CollectibleMapper.Configure(modComponent);
                CharcoalMapper.Configure(modComponent);
                PurificationMapper.Configure(modComponent);
                ResearchMapper.Configure(modComponent);
                FirstAidMapper.Configure(modComponent);
                ToolMapper.Configure(modComponent);
                GenericEquippableMapper.Configure(modComponent);
                BedMapper.Configure(modComponent);
                BodyHarvestMapper.Configure(modComponent);

                if (hasModPlaceHolder)
                {
                    return;
                }

                InspectMapper.Configure(modComponent);
                ConfigureGearItem(modComponent);

                mappedItems.Add(modComponent);

                PostProcess(modComponent);
            }
        }
        static bool HoveringInteractable(RayEventData eventData, GameObject currentObject, out bool hasScrollHandler)
        {
            hasScrollHandler = false;

            var selectionFlags = ComponentUtils <ISelectionFlags> .GetComponent(currentObject);

            if (selectionFlags != null && selectionFlags.selectionFlags == SelectionFlags.Direct && !UIUtils.IsDirectEvent(eventData))
            {
                return(false);
            }

            hasScrollHandler = ExecuteEvents.GetEventHandler <IScrollHandler>(currentObject);

            return(ExecuteEvents.GetEventHandler <IEventSystemHandler>(currentObject));
        }
        internal static void Postfix(GearItem placedGearNew)
        {
            if (placedGearNew == null || placedGearNew.m_CookingPotItem == null || !placedGearNew.m_CookingPotItem.AttachedFireIsBurning())
            {
                return;
            }

            CookingPotItem       cookingPotItem       = placedGearNew.m_CookingPotItem;
            OverrideCookingState overrideCookingState = ComponentUtils.GetComponent <OverrideCookingState>(cookingPotItem);

            if (overrideCookingState?.ForceReady ?? false)
            {
                WaterUtils.SetElapsedCookingTimeForWater(cookingPotItem, WaterUtils.GetWaterAmount(cookingPotItem));
            }
        }
示例#22
0
        void OnRayEntered(GameObject gameObject, TrackedDeviceEventData eventData)
        {
            var dropReceiver = ComponentUtils <IDropReceiver> .GetComponent(gameObject);

            if (dropReceiver != null)
            {
                var rayOrigin = eventData.interactor;
                if (dropReceiver.CanDrop(GetCurrentDropObject(rayOrigin)))
                {
                    dropReceiver.OnDropHoverStarted();
                    m_HoverObjects[rayOrigin] = gameObject;
                    SetCurrentDropReceiver(rayOrigin, dropReceiver);
                }
            }
        }
        internal static void Postfix(Panel_Cooking __instance)
        {
            Il2CppSystem.Collections.Generic.List <GearItem> foodList = __instance.m_FoodList;
            if (foodList == null)
            {
                return;
            }

            foreach (GearItem eachGearItem in foodList)
            {
                CookingModifier cookingModifier = ComponentUtils.GetComponent <CookingModifier>(eachGearItem);
                cookingModifier?.Revert();
                //if(cookingModifier) Implementation.Log("{0} reverted from Melt and Cook", eachGearItem.name);
            }
        }
示例#24
0
        public static void Configure(GameObject prefab)
        {
            ModAccelerantComponent modAccelerantComponent = ComponentUtils.GetComponent <ModAccelerantComponent>(prefab);

            if (modAccelerantComponent is null)
            {
                return;
            }

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

            fireStarterItem.m_IsAccelerant = true;
            fireStarterItem.m_FireStartDurationModifier = modAccelerantComponent.DurationOffset;
            fireStarterItem.m_FireStartSkillModifier    = modAccelerantComponent.SuccessModifier;
            fireStarterItem.m_ConsumeOnUse = modAccelerantComponent.DestroyedOnUse;
        }
示例#25
0
        internal static void Configure(GameObject prefab)
        {
            ModEvolveComponent modEvolveComponent = ComponentUtils.GetComponent <ModEvolveComponent>(prefab);

            if (modEvolveComponent is null)
            {
                return;
            }

            EvolveItem evolveItem = ComponentUtils.GetOrCreateComponent <EvolveItem>(modEvolveComponent);

            evolveItem.m_ForceNoAutoEvolve    = false;
            evolveItem.m_GearItemToBecome     = GetTargetItem(modEvolveComponent.TargetItemName, modEvolveComponent.name);
            evolveItem.m_RequireIndoors       = modEvolveComponent.IndoorsOnly;
            evolveItem.m_StartEvolvePercent   = 0;
            evolveItem.m_TimeToEvolveGameDays = Mathf.Clamp(modEvolveComponent.EvolveHours / 24f, 0.01f, 1000);
        }
示例#26
0
        void OnDragEnded(GameObject gameObject, TrackedDeviceEventData eventData)
        {
            var droppable = ComponentUtils <IDroppable> .GetComponent(gameObject);

            if (droppable != null)
            {
                var rayOrigin = eventData.interactor;
                m_Droppables.Remove(rayOrigin);

                var dropReceiver = GetCurrentDropReceiver(rayOrigin);
                var dropObject   = droppable.GetDropObject();
                if (dropReceiver != null && dropReceiver.CanDrop(dropObject))
                {
                    dropReceiver.ReceiveDrop(droppable.GetDropObject());
                }
            }
        }
        public static void Configure(GameObject prefab)
        {
            ModCarryingCapacityComponent capacityComponent = ComponentUtils.GetComponent <ModCarryingCapacityComponent>(prefab);

            if (capacityComponent is null)
            {
                return;
            }

            CarryingCapacityBuff capacityBuff = ComponentUtils.GetOrCreateComponent <CarryingCapacityBuff>(capacityComponent);

            capacityBuff.m_IsWorn = ComponentUtils.GetComponent <ModClothingComponent>(capacityComponent) != null ||
                                    ComponentUtils.GetComponent <ClothingItem>(capacityComponent) != null;

            capacityBuff.m_CarryingCapacityBuffValues = new CarryingCapacityBuff.BuffValues()
            {
                m_MaxCarryCapacityKGBuff = capacityComponent.MaxCarryCapacityKGBuff
            };
        }
示例#28
0
        public static void Configure(GameObject prefab)
        {
            ModSharpenableComponent modSharpenableComponent = ComponentUtils.GetComponent <ModSharpenableComponent>(prefab);

            if (modSharpenableComponent is null)
            {
                return;
            }

            Sharpenable sharpenable = ComponentUtils.GetOrCreateComponent <Sharpenable>(modSharpenableComponent);

            sharpenable.m_ConditionIncreaseMax = modSharpenableComponent.ConditionMax;
            sharpenable.m_ConditionIncreaseMin = modSharpenableComponent.ConditionMin;
            sharpenable.m_DurationMinutesMax   = modSharpenableComponent.MinutesMax;
            sharpenable.m_DurationMinutesMin   = modSharpenableComponent.MinutesMin;

            sharpenable.m_SharpenToolChoices    = ModUtils.GetItems <ToolsItem>(modSharpenableComponent.Tools, prefab.name + ": Tools");
            sharpenable.m_RequiresToolToSharpen = sharpenable.m_SharpenToolChoices.Count() > 0;
        }
示例#29
0
        void OnRayExited(GameObject gameObject, TrackedDeviceEventData eventData)
        {
            if (!gameObject)
            {
                return;
            }

            var dropReceiver = ComponentUtils <IDropReceiver> .GetComponent(gameObject);

            if (dropReceiver != null)
            {
                var rayOrigin = eventData.interactor;
                if (m_HoverObjects.Remove(rayOrigin))
                {
                    dropReceiver.OnDropHoverEnded();
                    SetCurrentDropReceiver(rayOrigin, null);
                }
            }
        }
        public static string GetLevelDifficultySpriteNew(object arg)
        {
            if (arg == null)
            {
                return(string.Empty);
            }
            int            characterLevel = ((IHasCharacterClasses)arg).GetCharacterLevel();
            CharacterStats component      = ComponentUtils.GetComponent <CharacterStats>(GameState.PlayerCharacter);

            if (component)
            {
                //Game.Console.AddMessage("Level diff is: Enemy: " + characterLevel + " and Player: " + component.Level);
                LevelDifficultyIcons difficultyIcons = GlobalGameSettingsGameData.Instance.CombatSettingsComponent.GetDifficultyIcons(component.Level, characterLevel);
                if (difficultyIcons != null)
                {
                    return(difficultyIcons.IconName);
                }
            }
            return(string.Empty);
        }