Beispiel #1
0
        static bool Prefix(WeaponPool __instance, ItemData item, ConfigWeapon w, Weapon weapon)
        {
            weapon.TypeId = item.id;
            weapon.Type   = w.Type;

            var par     = new object[] { w, item };
            var oMethod = typeof(WeaponPool).GetMethod("GetProto", BindingFlags.Instance | BindingFlags.NonPublic);
            var ret     = oMethod.Invoke(__instance, par);

            weapon.Proto = (IWeaponProto)ret;

            var ctrl = WeaponPool_Build_Patch_1.LoadAnimator(w.Animation);

            if (ctrl != null)
            {
                weapon.Animator.runtimeAnimatorController = ctrl;
            }

            weapon.name = ConfigItem.getName(item.id);
            weapon.SetWeaponImage("Weapon");
            if (ConfigWeapon.getAttackSound(item.id) != "0")
            {
                weapon.AttackSound.clip = (AudioClip)Resources.Load(ConfigWeapon.getAttackSound(item.id), typeof(AudioClip));
            }
            return(false);
        }
Beispiel #2
0
        static bool Prefix(WeaponPool __instance, int id, ConfigWeapon w, Weapon weapon)
        {
            weapon.TypeId = id;
            weapon.Type   = w.Type;
            weapon.Proto  = __instance.GetProto(w, id);
            if (weapon.Animator == null)
            {
                weapon.Animator = __instance.GetComponent <Animator>();
            }

            var ctrl = WeaponPool_Build_Patch_1.LoadAnimator(w.Animation);

            if (ctrl != null)
            {
                weapon.Animator.runtimeAnimatorController = ctrl;
            }

            if (id != 0)
            {
                ConfigItem configItem = ConfigItem.get(id);
                weapon.name = configItem.Name;
            }
            weapon.SetWeaponImage("Weapon");
            if (ConfigWeapon.getAttackSound(id) != "0")
            {
                weapon.AttackSound.clip = (AudioClip)Resources.Load(ConfigWeapon.getAttackSound(id), typeof(AudioClip));
            }
            return(false);
        }