Exemplo n.º 1
0
 private static void HandleStone(ref OcItem item)
 {
     foreach (KeyValuePair <int, float> pair in EnchantHelper.Inst.StoneRandomDrop)
     {
         TryAddEnchant(pair, ref item);
     }
 }
Exemplo n.º 2
0
        private static bool TryAddEnchant(KeyValuePair <int, float> pair, ref OcItem item)
        {
            var v = UnityEngine.Random.value;

            if (v < pair.Value)
            {
                SoEnchantment byId_OrNull = OcResidentData.EnchantDataList.GetById_OrNull(pair.Key);
                if (byId_OrNull != null)
                {
                    return(item.TryAttachEnchant(byId_OrNull, false));
                }
            }
            return(false);
        }
Exemplo n.º 3
0
 private static void HandleEnemy(ref OcItem item, SoEnemyData EnemyData)
 {
     foreach (KeyValuePair <int, float> pair in EnchantHelper.Inst.UnspecifiedEnemyDrop)
     {
         TryAddEnchant(pair, ref item);
     }
     if (EnchantHelper.Inst.SpecifiedEnemyDrop.ContainsKey(EnemyData.ID))
     {
         foreach (KeyValuePair <int, float> pair in EnchantHelper.Inst.SpecifiedEnemyDrop[EnemyData.ID])
         {
             TryAddEnchant(pair, ref item);
         }
     }
 }
Exemplo n.º 4
0
        private static bool Prefix(OcEm_NPC_Event __instance)
        {
            try
            {
                if (!Plugin.PressClosed)
                {
                    var chestItemList = Traverse.Create(__instance).Field("_ChestItemList").GetValue <OcItem_ChestItemList>();
                    int chestSize     = (chestItemList?.ChestSize) ?? 0;

                    var inventoryMng  = SingletonMonoBehaviour <OcItemUI_InventoryMng> .Inst;
                    var ocItemDataMng = SingletonMonoBehaviour <OcItemDataMng> .Inst;

                    if (chestItemList != null && chestItemList.Item.Length != 0)
                    {
                        OcItem[] itemArray    = new OcItem[chestSize];
                        int[]    enchantArray = Plugin.selectedEncDic.Keys.ToArray();

                        for (int i = 0; i < chestSize; i++)
                        {
                            var chestItem = chestItemList.Item[i];

                            OcItem ocItem = ocItemDataMng.CreateItem(chestItem.Id, chestItem.Level, enchantArray);

                            ocItem.SortEnchantSlot();
                            itemArray[i] = ocItem;
                        }

                        int itemArrayLength = itemArray.Length;

                        for (int j = 0; j < itemArrayLength; j++)
                        {
                            if (chestItemList.Amount[j] != 0)
                            {
                                inventoryMng.TryTakeItem(itemArray[j], chestItemList.Amount[j], OcItemUI_InventoryMng.ItemTakeTrigger.Drop);
                                chestItemList.Item[j] = new OcItem(ocItemDataMng.EmptyData, 0);
                            }
                        }
                    }
                }

                Plugin.selectedEncDic = new Dictionary <int, SoEnchantment>();
            }
            catch
            {
            }

            return(true);
        }
Exemplo n.º 5
0
 static void PostfixOcInstallObjMngInstantiate_Dissolver_ForMaster(OcItem __1, OcPlEquip __result)
 {
     try
     {
         var id = __1.Id;
         if (!RegistryManager.Inst.Initialized)
         {
             Logger.Inst.LogInfo($"Put an item before initialized registry: {__1.DisplayName}({__1.Id})");
             return;
         }
         var registry = RegistryManager.Inst.GetRegistry <Item>();
         var item     = registry.GetElementById(id);
         item?.PutHandler?.OnPut(__result);
     }
     catch (Exception e)
     {
         Logger.Inst.LogException(e);
     }
 }
Exemplo n.º 6
0
 static bool PrefixOcPlcheckAct_Put(OcPlEquipCtrl ____EquipCtrl)
 {
     try
     {
         OcItem itemData = ____EquipCtrl.getWpMain()?.Item;
         if (itemData != null)
         {
             var id       = itemData.Id;
             var registry = RegistryManager.Inst.GetRegistry <Item>();
             var item     = registry.GetElementById(id);
             var result   = item?.PutHandler?.IsPuttable();
             return(!result.HasValue || result.Value);
         }
     }
     catch (Exception e)
     {
         Logger.Inst.LogException(e);
     }
     return(true);
 }
Exemplo n.º 7
0
        static void Postfix(OcItemDataMng __instance, int itemId, int level, List <OcItem> materialList, List <int> materialCount, ref OcItem __result)
        {
            if (materialList.IsNullOrEmpty <OcItem>())
            {
                __result = __instance.CreateItem(itemId, level);
            }

            List <int> list = new List <int>();

            SoEnchantment[] nonInheritables = OcResidentData.EnchantDataList.nonInheritables;

            for (int i = 0; i < materialList.Count; i++)
            {
                OcItem ocItem = materialList[i];
                for (int j = 0; j < ocItem.EnchantNum; j++)
                {
                    var sid = ocItem.GetEnchant(j).Source.ID;
                    if (sid != 0 && !(nonInheritables.FirstOrDefault((SoEnchantment source) => source.ID == sid) != null))
                    {
                        if (!list.Contains(sid))
                        {
                            list.Add(sid);
                        }
                    }
                }
            }

            int[] selectEnchantment = new int[4];
            int   enchantNumber     = Math.Min(list.Count, 4);

            for (int i = 0; i < enchantNumber; i++)
            {
                var randomIndex = UnityEngine.Random.Range(0, list.Count - 1);
                selectEnchantment[i] = list[randomIndex];
                list.RemoveAt(randomIndex);
            }
            selectEnchantment = (from a in selectEnchantment
                                 orderby Guid.NewGuid()
                                 select a).ToArray <int>();
            __result = __instance.CreateItem(itemId, level, selectEnchantment);
        }
Exemplo n.º 8
0
        static void Postfix(OcItemDropper __instance, ref OcItem item, SoEnemyData EnemyData)
        {
            var isEnemy = __instance.GetComponent <Oc.Em.OcEm>() != null;

            if (isEnemy)
            {
                HandleEnemy(ref item, EnemyData);
                return;
            }

            var obj = __instance.GetComponent <Oc.OcStaticObj>();

            if (obj.StaticObjType == OcStaticObjType.Tree)
            {
                HandleTree(ref item);
            }
            else if (obj.StaticObjType == OcStaticObjType.Stone || obj.StaticObjType == OcStaticObjType.BedRock)
            {
                HandleStone(ref item);
            }
        }
Exemplo n.º 9
0
 static bool Prefix(OcPlEquipCtrl __instance, OcItem item, OcEquipSlot equipSlot, out OcEquipSlot __state)
 {
     __state = equipSlot;
     return(true);
 }