public void Start() { vp_FPSShooter shooter = this.GetComponent <vp_FPSShooter>(); if (shooter != null && shooter.MuzzleFlash != null) { shooter.MuzzleFlash.transform.parent = shooter.BulletEmissionLocator; } }
public static void Postfix(vp_FPSShooter __instance) { PlayerManager playerManager = GameManager.GetPlayerManagerComponent(); ModAnimationStateMachine animation = ModComponentUtils.ComponentUtils.GetComponent <ModAnimationStateMachine>(playerManager.m_ItemInHands); if (animation is null) { return; } if (__instance.MuzzleFlash != null) { __instance.MuzzleFlash.transform.localPosition = Vector3.zero; } }
/////////////////////////////////////////////////////////// // hooks up the FPSCamera object to the inspector target /////////////////////////////////////////////////////////// void OnEnable() { m_Component = (vp_FPSShooter)target; if (m_Persister == null) { m_Persister = new vp_ComponentPersister(); } m_Persister.Component = m_Component; m_Persister.IsActive = true; if (m_Component.DefaultState == null) { m_Component.RefreshDefaultState(); } }
/////////////////////////////////////////////////////////// // any child objects to the FPSCamera component are treated // as weapons. these are put in the 'm_Weapons' list in // alphabetical order. this method will first disable the // currently activated weapon, then activate the one with // index 'i'. if 'i' is zero, no child will be activated. /////////////////////////////////////////////////////////// public void SetWeapon(int i) { if (m_Weapons.Count < 1) { Debug.LogError("Error: Tried to set weapon with an empty weapon list."); return; } if (i < 0 || i > m_Weapons.Count) { Debug.LogError("Error: Weapon list does not have a weapon with index: " + i); return; } // clear current weapon, set all child objects inactive // and clear the shooter m_CurrentWeapon = null; foreach (Transform t in transform) { if (t.gameObject != m_WeaponCamera) { DeactivateWhenSilent(t); } } m_CurrentShooter = null; // activate the new weapon m_CurrentWeaponID = i; if (m_CurrentWeaponID > 0) { // set parent transform of new weapon active m_Weapons[m_CurrentWeaponID - 1].transform.parent.gameObject.SetActiveRecursively(true); // store the components of the new weapon and shooter m_CurrentWeapon = (vp_FPSWeapon)m_Weapons[m_CurrentWeaponID - 1].GetComponentInChildren(typeof(vp_FPSWeapon)); m_CurrentShooter = (vp_FPSShooter)m_Weapons[m_CurrentWeaponID - 1].GetComponentInChildren(typeof(vp_FPSShooter)); // activate the new shooter and camera, and make sure the weapon // renderer is enabled if (m_CurrentWeapon != null) { if (m_CurrentShooter != null) { if (m_CurrentShooter.MuzzleFlash != null) { m_CurrentShooter.MuzzleFlash.SetActiveRecursively(true); } } if (m_CurrentWeapon.gameObject.renderer != null) { m_CurrentWeapon.gameObject.renderer.enabled = true; } CurrentWeapon.PositionOffset = CurrentWeapon.DefaultPosition; CurrentWeapon.RotationOffset = CurrentWeapon.DefaultRotation; m_CurrentWeapon.SetPivotVisible(false); } } Refresh(); }
/////////////////////////////////////////////////////////// // any child objects to the FPSCamera component are treated // as weapons. these are put in the 'm_Weapons' list in // alphabetical order. this method will first disable the // currently activated weapon, then activate the one with // index 'i'. if 'i' is zero, no child will be activated. /////////////////////////////////////////////////////////// public void SetWeapon(int i) { if (m_Weapons.Count < 1) { Debug.LogError("Error: Tried to set weapon with an empty weapon list."); return; } if (i < 0 || i > m_Weapons.Count) { Debug.LogError("Error: Weapon list does not have a weapon with index: " + i); return; } // clear current weapon, set all child objects inactive // and clear the shooter m_CurrentWeapon = null; foreach (Transform t in transform) { if(t.gameObject != m_WeaponCamera) DeactivateWhenSilent(t); } m_CurrentShooter = null; // activate the new weapon m_CurrentWeaponID = i; if (m_CurrentWeaponID > 0) { // set parent transform of new weapon active m_Weapons[m_CurrentWeaponID - 1].transform.parent.gameObject.SetActiveRecursively(true); // store the components of the new weapon and shooter m_CurrentWeapon = (vp_FPSWeapon)m_Weapons[m_CurrentWeaponID - 1].GetComponentInChildren(typeof(vp_FPSWeapon)); m_CurrentShooter = (vp_FPSShooter)m_Weapons[m_CurrentWeaponID - 1].GetComponentInChildren(typeof(vp_FPSShooter)); // activate the new shooter and camera, and make sure the weapon // renderer is enabled if (m_CurrentWeapon != null) { if (m_CurrentShooter != null) { if (m_CurrentShooter.MuzzleFlash != null) m_CurrentShooter.MuzzleFlash.SetActiveRecursively(true); } if (m_CurrentWeapon.gameObject.renderer != null) m_CurrentWeapon.gameObject.renderer.enabled = true; CurrentWeapon.PositionOffset = CurrentWeapon.DefaultPosition; CurrentWeapon.RotationOffset = CurrentWeapon.DefaultRotation; m_CurrentWeapon.SetPivotVisible(false); } } Refresh(); }
/////////////////////////////////////////////////////////// // hooks up the FPSCamera object to the inspector target /////////////////////////////////////////////////////////// void OnEnable() { m_Component = (vp_FPSShooter)target; if (m_Persister == null) m_Persister = new vp_ComponentPersister(); m_Persister.Component = m_Component; m_Persister.IsActive = true; if (m_Component.DefaultState == null) m_Component.RefreshDefaultState(); }
/////////////////////////////////////////////////////////// // hooks up the FPSCamera object to the inspector target /////////////////////////////////////////////////////////// void OnEnable() { m_Component = (vp_FPSShooter)target; EditorApplication.playmodeStateChanged = delegate() { vp_ComponentPreset.m_Component = (Component)target; vp_ComponentPersister.m_Component = (Component)target; vp_ComponentPersister.PlayModeCallback(); }; }
/////////////////////////////////////////////////////////// // any child objects to the FPSCamera component are treated // as weapons. these are put in the 'm_Weapons' list in // alphabetical order. this method will first disable the // currently activated weapon, then activate the one with // index 'i'. if 'i' is zero, no child will be activated. /////////////////////////////////////////////////////////// public void SetWeapon(int i) { if (m_Weapons.Count < 1) { Debug.LogError("Error: Tried to set weapon with an empty weapon list."); return; } if (i < 0 || i > m_Weapons.Count) { Debug.LogError("Error: Weapon list does not have a weapon with index: " + i); return; } foreach (Transform t in transform) { t.gameObject.SetActiveRecursively(false); } m_CurrentWeaponID = i; if (m_CurrentWeaponID > 0) { m_Weapons[m_CurrentWeaponID - 1].transform.parent.gameObject.SetActiveRecursively(true); m_CurrentWeapon = (vp_FPSWeapon)m_Weapons[m_CurrentWeaponID - 1].GetComponentInChildren(typeof(vp_FPSWeapon)); m_CurrentShooter = (vp_FPSShooter)m_Weapons[m_CurrentWeaponID - 1].GetComponentInChildren(typeof(vp_FPSShooter)); if (m_CurrentWeapon != null) { if (m_CurrentWeapon.WeaponCamera != null) m_CurrentWeapon.WeaponCamera.SetActiveRecursively(true); if (m_CurrentShooter != null) { if (m_CurrentShooter.MuzzleFlash != null) m_CurrentShooter.MuzzleFlash.SetActiveRecursively(true); } m_CurrentWeapon.SetPivotVisible(false); } } }