Ejemplo n.º 1
0
        private static void RegisterRifle(ModRifleComponent modRifleComponent, Transform weaponViewTransform)
        {
            string name = ModUtils.NormalizeName(modRifleComponent.name);

            if (weaponViewTransform.Find(name) != null)
            {
                // already registered
                return;
            }

            LogUtils.Log("Registering '{0}'", name);

            GameObject template = weaponViewTransform.Find("Rifle").gameObject;
            GameObject weapon   = Object.Instantiate(template, weaponViewTransform);

            weapon.name = name;
            weapon.AddComponent <FixMuzzleFlashTransformParent>();
            weapon.GetComponent <vp_FPSWeapon>().m_UseFirstPersonHands = false;

            Transform rifle_rig = weapon.transform.Find("rifle_rig");

            if (rifle_rig != null)
            {
                rifle_rig.transform.parent = null;
                Object.Destroy(rifle_rig.gameObject);
            }

            GameObject equippedModel = Object.Instantiate(modRifleComponent.EquippedModelPrefab, weapon.transform);

            equippedModel.name = (name + "_rig").ToLower();
        }
Ejemplo n.º 2
0
        private static FirstPersonItem ConfiguredRifleFirstPersonItem(ModRifleComponent modRifleComponent)
        {
            FirstPersonItem result = ModUtils.GetOrCreateComponent <FirstPersonItem>(modRifleComponent);

            FirstPersonItem template = Resources.Load <GameObject>("GEAR_Rifle").GetComponent <FirstPersonItem>();

            result.m_FirstPersonObjectName  = ModUtils.NormalizeName(modRifleComponent.name);
            result.m_UnWieldAudio           = template.m_UnWieldAudio;
            result.m_WieldAudio             = template.m_WieldAudio;
            result.m_PlayerStateTransitions = UnityEngine.Object.Instantiate(template.m_PlayerStateTransitions);
            result.Awake();

            return(result);
        }