public static void GetPoint() { vp_FPSCamera cam = GameManager.GetVpFPSPlayer().FPSCamera; RaycastHit raycastHit = DoRayCast(cam.transform.position, cam.transform.forward); Debug.Log(raycastHit.point); }
/////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////// new void Awake() { base.Awake(); m_Camera = transform.root.GetComponentInChildren <vp_FPSCamera>(); if (m_Camera == null) { Debug.LogError("Camera is null."); return; } // instantiate muzzleflash if (MuzzleFlashPrefab != null) { m_MuzzleFlash = (GameObject)Object.Instantiate(MuzzleFlashPrefab, m_Camera.transform.position, m_Camera.transform.rotation); m_MuzzleFlash.name = transform.name + "MuzzleFlash"; m_MuzzleFlash.transform.parent = m_Camera.transform; } // reset the next allowed fire time m_NextAllowedFireTime = Time.time; m_NextAllowedReloadTime = Time.time; m_AmmoCount = AmmoMaxCount; }
/////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////// void Awake() { // get hold of the vp_FPSCamera and vp_FPSController attached to // this game object. NOTE: vp_FPSWeapons and vp_FPSShooters are // accessed via 'CurrentWeapon' and 'CurrentShooter' Camera = gameObject.GetComponentInChildren <vp_FPSCamera>(); Controller = gameObject.GetComponent <vp_FPSController>(); }
private void ZoomCamera() { vp_FPSCamera camera = GameManager.GetVpFPSCamera(); originalFOV = GetFieldValue <float>(camera, "m_RenderingFieldOfView"); camera.ToggleZoom(true); camera.SetFOVFromOptions(originalFOV * 0.1f); }
private void ZoomCamera() { vp_FPSCamera camera = GameManager.GetVpFPSCamera(); originalFOV = camera.m_RenderingFieldOfView; camera.ToggleZoom(true); camera.SetFOVFromOptions(originalFOV * Settings.GetFovScalar()); }
internal static void GetObjectNameUnderPoint() { vp_FPSCamera cam = GameManager.GetVpFPSPlayer().FPSCamera; RaycastHit raycastHit = DoRayCast(cam.transform.position, cam.transform.forward); GameObject go = raycastHit.collider.gameObject; HUDMessage.AddMessage(go.name); Debug.Log("[remove-clutter] Object under crosshair:>>>>> " + go.name); }
public static void GetPoint() { vp_FPSCamera cam = GameManager.GetVpFPSPlayer().FPSCamera; RaycastHit raycastHit = DoRayCast(cam.transform.position, cam.transform.forward); Log("Point: " + raycastHit.point.x + "," + raycastHit.point.y + "," + raycastHit.point.z, true, false, true); /*Debug.Log(raycastHit.point.x+","+ raycastHit.point.y+","+ raycastHit.point.z); * HUDMessage.AddMessage(raycastHit.point.x + "," + raycastHit.point.y + "," + raycastHit.point.z); * MelonLoader.MelonLogger.Log("Point: "+ raycastHit.point.x + "," + raycastHit.point.y + "," + raycastHit.point.z);*/ }
static void Prefix(vp_FPSCamera __instance) { if (__instance.MouseAcceleration != MouseModGlobals.MouseAcceleration) { __instance.MouseAcceleration = MouseModGlobals.MouseAcceleration; } if (__instance.MouseSmoothSteps != MouseModGlobals.MouseSmoothingSteps) { __instance.MouseSmoothSteps = MouseModGlobals.MouseSmoothingSteps; } }
private static void Shoot() { if (uConsole.GetNumParameters() != 6) { Debug.Log("6 parameters required"); return; } vp_FPSCamera camera = GameManager.GetVpFPSCamera(); camera.AddForce2(uConsole.GetFloat(), uConsole.GetFloat(), uConsole.GetFloat()); camera.AddRotationForce(uConsole.GetFloat(), uConsole.GetFloat(), uConsole.GetFloat()); }
/////////////////////////////////////////////////////////// // hooks up the FPSCamera object to the inspector target /////////////////////////////////////////////////////////// void OnEnable() { m_Component = (vp_FPSCamera)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(); } }
/////////////////////////////////////////////////////////// // in 'Awake' we do things that need to be run once at the // very beginning. NOTE: as of Unity 4, gameobject hierarchy // can not be altered in 'Awake' /////////////////////////////////////////////////////////// protected new void Awake() { base.Awake(); m_Camera = transform.root.GetComponentInChildren <vp_FPSCamera>(); if (m_Camera == null) { Debug.LogError("Camera is null."); return; } // reset the next allowed fire time m_NextAllowedFireTime = Time.time; m_NextAllowedReloadTime = Time.time; m_AmmoCount = AmmoMaxCount; }
/////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////// void Start() { // get hold of the FPSCamera and FPSController components // attached to this game object m_Camera = gameObject.GetComponentInChildren<vp_FPSCamera>(); m_Controller = gameObject.GetComponent<vp_FPSController>(); // load crosshair texture //m_ImageCrosshair = (Texture)Resources.Load("Examples/Images/Crosshair"); // load 'modern shooter' camera and controller presets //m_Camera.Load("Precam"); //m_Controller.Load("Precon"); // try to set weapon 1 //if ( Guns && m_Camera.WeaponCount > 0) // SetWeapon(1); }
/////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////// void Awake() { // get hold of the vp_FPSCamera and vp_FPSController attached to // this game object. NOTE: vp_FPSWeapons and vp_FPSShooters are // accessed via 'CurrentWeapon' and 'CurrentShooter' Camera = gameObject.GetComponentInChildren<vp_FPSCamera>(); Controller = gameObject.GetComponent<vp_FPSController>(); }
/////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////// new void Awake() { base.Awake(); m_Camera = transform.root.GetComponentInChildren<vp_FPSCamera>(); if (m_Camera == null) { Debug.LogError("Camera is null."); return; } // instantiate muzzleflash if (MuzzleFlashPrefab != null) { m_MuzzleFlash = (GameObject)Object.Instantiate(MuzzleFlashPrefab, m_Camera.transform.position, m_Camera.transform.rotation); m_MuzzleFlash.name = transform.name + "MuzzleFlash"; m_MuzzleFlash.transform.parent = m_Camera.transform; } // reset the next allowed fire time m_NextAllowedFireTime = Time.time; m_NextAllowedReloadTime = Time.time; m_AmmoCount = AmmoMaxCount; }
/////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////// void Awake() { m_Camera = transform.root.GetComponentInChildren<vp_FPSCamera>(); if (m_Camera == null) { Debug.LogError("Camera is null."); return; } // instantiate muzzleflash if (MuzzleFlashPrefab != null) { m_MuzzleFlash = (GameObject)Object.Instantiate(MuzzleFlashPrefab, m_Camera.transform.position, m_Camera.transform.rotation); m_MuzzleFlash.name = transform.name + "MuzzleFlash"; m_MuzzleFlash.transform.parent = m_Camera.transform; } RefreshSettings(); }
public List <GameObject> FXPrefabs = new List <GameObject>(); // list of special effects objects to spawn /////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////// void Awake() { // spawn effects gameobjects foreach (GameObject fx in FXPrefabs) { Component[] c; c = fx.GetComponents <vp_Explosion>(); if (c.Length == 0) { Object.Instantiate(fx, transform.position, transform.rotation); } else { Debug.LogError("Error: vp_Explosion->FXPrefab must not be a vp_Explosion (risk of infinite loop)."); } } // apply shockwave to all rigidbodies and FPSPlayers within range Collider[] colliders = Physics.OverlapSphere(transform.position, Radius); foreach (Collider hit in colliders) { if (hit != this.collider) { //Debug.Log(hit.transform.name + Time.time); // snippet to dump affected objects if (hit.rigidbody) { float distanceModifier = (1 - Vector3.Distance(transform.position, hit.transform.position) / Radius); // explosion up force should only work on grounded objects, // otherwise object may acquire extreme speeds Ray ray = new Ray(hit.transform.position, -Vector3.up); RaycastHit hit2; if (!Physics.Raycast(ray, out hit2, 1)) { UpForce = 0.0f; } // bash all objects within range hit.rigidbody.AddExplosionForce(Force, transform.position, Radius, UpForce); if (hit.gameObject.layer != vp_Layer.Debris) { hit.gameObject.SendMessage(DamageMethodName, distanceModifier * Damage, SendMessageOptions.DontRequireReceiver); } } else { vp_FPSController controller = hit.GetComponent <vp_FPSController>(); if (controller) { float distanceModifier = (1 - Vector3.Distance(transform.position, hit.transform.position) / Radius) * 0.5f; controller.AddForce((controller.transform.position - transform.position).normalized * Force * 0.001f * distanceModifier); vp_FPSCamera camera = hit.GetComponentInChildren <vp_FPSCamera>(); if (camera) { camera.DoBomb(distanceModifier * CameraShake); } if (hit.gameObject.layer != vp_Layer.Debris) { hit.gameObject.SendMessage(DamageMethodName, distanceModifier * Damage, SendMessageOptions.DontRequireReceiver); } } } } } // play explosion sound audio.clip = Sound; audio.rolloffMode = AudioRolloffMode.Linear; audio.minDistance = 3; audio.maxDistance = 250; audio.dopplerLevel = 2.5f; audio.pitch = Random.Range(SoundMinPitch, SoundMaxPitch); audio.playOnAwake = false; // 'playOnAwake' seems unreliable, so play manually audio.Play(); }
/////////////////////////////////////////////////////////// // in 'Awake' we do things that need to be run once at the // very beginning. NOTE: as of Unity 4, gameobject hierarchy // can not be altered in 'Awake' /////////////////////////////////////////////////////////// protected new void Awake() { base.Awake(); m_Camera = transform.root.GetComponentInChildren<vp_FPSCamera>(); if (m_Camera == null) { Debug.LogError("Camera is null."); return; } // reset the next allowed fire time m_NextAllowedFireTime = Time.time; m_NextAllowedReloadTime = Time.time; m_AmmoCount = AmmoMaxCount; }
private static void Postfix(PlayerManager __instance, ref MeshLocationCategory __result) { if (__instance == null) { return; } GameObject gameObject = __instance.GetObjectToPlace(); if (!PlacingAnywhere.isPlacing) { PlacingAnywhere.isPlacing = true; PlacingAnywhere.lastRotation = gameObject.transform.eulerAngles; } if (gameObject == null) { return; } vp_FPSCamera cam = GameManager.GetVpFPSPlayer().FPSCamera; RaycastHit raycastHit = PlacingAnywhere.DoRayCast(cam.transform.position, cam.transform.forward, true); GearPlacePoint gearPlacePoint = null; if (raycastHit.collider != null) { gearPlacePoint = __instance.GetGearPlacePoint(raycastHit.collider.gameObject, raycastHit.point); } if (gearPlacePoint == null) { gameObject.transform.eulerAngles = PlacingAnywhere.lastRotation; } //Z Rotation - G/H if (KeyboardUtilities.InputManager.GetKey(Settings.options.rotateZRight) && Time.time > PlacingAnywhere.nextRotate) { PlacingAnywhere.nextRotate = Time.time + PlacingAnywhere.rotateRate; if (KeyboardUtilities.InputManager.GetKey(KeyCode.LeftShift)) { gameObject.transform.Rotate(Vector3.right, PlacingAnywhere.rotateAngle / 4f, Space.Self); } else { gameObject.transform.Rotate(Vector3.right, PlacingAnywhere.rotateAngle, Space.Self); } } else if (KeyboardUtilities.InputManager.GetKey(Settings.options.rotateZLeft) && Time.time > PlacingAnywhere.nextRotate) { PlacingAnywhere.nextRotate = Time.time + PlacingAnywhere.rotateRate; if (KeyboardUtilities.InputManager.GetKey(KeyCode.LeftShift)) { gameObject.transform.Rotate(Vector3.right, -(PlacingAnywhere.rotateAngle / 4f), Space.Self); } else { gameObject.transform.Rotate(Vector3.right, -PlacingAnywhere.rotateAngle, Space.Self); } } //Y Rotation - Q/E - Handled by vanilla //X Rotation - T/Y if (KeyboardUtilities.InputManager.GetKey(Settings.options.rotateXRight) && Time.time > PlacingAnywhere.nextRotate) { PlacingAnywhere.nextRotate = Time.time + PlacingAnywhere.rotateRate; if (KeyboardUtilities.InputManager.GetKey(KeyCode.LeftShift)) { gameObject.transform.Rotate(Vector3.forward, PlacingAnywhere.rotateAngle / 4f, Space.Self); } else { gameObject.transform.Rotate(Vector3.forward, PlacingAnywhere.rotateAngle, Space.Self); } } else if (KeyboardUtilities.InputManager.GetKey(Settings.options.rotateXLeft) && Time.time > PlacingAnywhere.nextRotate) { PlacingAnywhere.nextRotate = Time.time + PlacingAnywhere.rotateRate; if (KeyboardUtilities.InputManager.GetKey(KeyCode.LeftShift)) { gameObject.transform.Rotate(Vector3.forward, -(PlacingAnywhere.rotateAngle / 4f), Space.Self); } else { gameObject.transform.Rotate(Vector3.forward, -PlacingAnywhere.rotateAngle, Space.Self); } } //Y Position - B/N if (KeyboardUtilities.InputManager.GetKey(Settings.options.moveUp) && Time.time > PlacingAnywhere.nextRotate) { PlacingAnywhere.nextRotate = Time.time + PlacingAnywhere.rotateRate; if (KeyboardUtilities.InputManager.GetKey(KeyCode.LeftShift)) { PlacingAnywhere.positionYOffset += (PlacingAnywhere.positionOffset / 4f); } else { PlacingAnywhere.positionYOffset += PlacingAnywhere.positionOffset; } } else if (KeyboardUtilities.InputManager.GetKey(Settings.options.moveDown) && Time.time > PlacingAnywhere.nextRotate) { PlacingAnywhere.nextRotate = Time.time + PlacingAnywhere.rotateRate; if (KeyboardUtilities.InputManager.GetKey(KeyCode.LeftShift)) { PlacingAnywhere.positionYOffset -= (PlacingAnywhere.positionOffset / 4f); } else { PlacingAnywhere.positionYOffset -= PlacingAnywhere.positionOffset; } } if (KeyboardUtilities.InputManager.GetKeyDown(Settings.options.resetRotation)) { float diff = Vector3.Dot(Vector3.up, raycastHit.normal); if (diff > 0.05f) { Quaternion lhs = Quaternion.FromToRotation(Vector3.up, raycastHit.normal); gameObject.transform.rotation = Quaternion.Euler(0f, gameObject.transform.rotation.eulerAngles.y, 0f); gameObject.transform.rotation = lhs * gameObject.transform.rotation; gameObject.transform.rotation = Quaternion.Euler(gameObject.transform.rotation.eulerAngles.x, gameObject.transform.rotation.eulerAngles.y, gameObject.transform.rotation.eulerAngles.z); } } //Conform to surface if (KeyboardUtilities.InputManager.GetKeyDown(Settings.options.conformToggleKey)) { if (PlacingAnywhere.conformToggle) { PlacingAnywhere.conformToggle = false; HUDMessage.AddMessage("Conform to surface: off"); PlacingAnywhere.RemoveItemsFromPhysicalCollisionMask(); } else { PlacingAnywhere.conformToggle = true; PlacingAnywhere.positionYOffset = 0; HUDMessage.AddMessage("Conform to surface: on"); PlacingAnywhere.AddItemsToPhysicalCollisionMask(); } } //Snap to object below if (KeyboardUtilities.InputManager.GetKeyDown(Settings.options.snapKey)) { if (PlacingAnywhere.snapToggle) { PlacingAnywhere.snapToggle = false; HUDMessage.AddMessage("Snap to objects: off"); } else { PlacingAnywhere.snapToggle = true; HUDMessage.AddMessage("Snap to objects: on"); } } Vector2 cameraMovementMouse = InputManager.GetCameraMovementMouse(__instance); Transform transform = GameManager.GetMainCamera().transform; if (KeyboardUtilities.InputManager.GetKey(KeyCode.LeftAlt)) { //Stop camera movement cam.MouseSensitivity = 0f; float angleForward = cameraMovementMouse.x * 1f; float angleRight = cameraMovementMouse.y * 1f; if (KeyboardUtilities.InputManager.GetKey(KeyCode.LeftShift)) { angleForward *= 0.25f; angleRight *= 0.25f; } if (Mathf.Abs(angleForward) > Mathf.Abs(angleRight)) { gameObject.transform.Rotate(Vector3.forward, -angleForward, Space.World); } else { gameObject.transform.Rotate(Vector3.right, -angleRight, Space.World); } } else { //Restore camera movement if (PlacingAnywhere.mouseSensivity > 0) { cam.MouseSensitivity = PlacingAnywhere.mouseSensivity; } } gameObject.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y + PlacingAnywhere.positionYOffset, gameObject.transform.position.z); if (PlacingAnywhere.snapToggle && gearPlacePoint == null) { if (raycastHit.collider != null) { GameObject goHit = raycastHit.collider.gameObject; if (goHit.GetComponent <GearItem>() != null) { gameObject.transform.rotation = goHit.transform.rotation; gameObject.transform.position = new Vector3(goHit.transform.position.x, gameObject.transform.position.y, goHit.transform.position.z); } } } if (PlacingAnywhere.snapToggle && gearPlacePoint == null) { PlacingAnywhere.SnapToPositionBelow(gameObject); PlacingAnywhere.SnapToRotationBelow(gameObject); } PlacingAnywhere.lastRotation = gameObject.transform.eulerAngles; __result = MeshLocationCategory.Valid; }
internal static void Postfix(vp_FPSCamera __instance) { __instance.m_MaxAmbientSwayAngleDegreesA = 0; }
/////////////////////////////////////////////////////////// // hooks up the FPSCamera object to the inspector target /////////////////////////////////////////////////////////// void OnEnable() { m_Component = (vp_FPSCamera)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(); }
/////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////// void Start() { // get hold of the FPSCamera and FPSController components // attached to this game object m_Camera = gameObject.GetComponentInChildren<vp_FPSCamera>(); m_Controller = gameObject.GetComponent<vp_FPSController>(); // load textures if (m_DemoMode) { LoadCamera("Examples/ImmobileCamera"); m_Camera.SetWeapon(1); m_ImageAllParams = (Texture)Resources.Load("Examples/Images/AllParams"); m_ImageEditorPreview = (Texture)Resources.Load("Examples/Images/EditorPreview"); m_ImageEditorPreviewShow = (Texture)Resources.Load("Examples/Images/EditorPreviewShow"); m_ImageCameraMouse = (Texture)Resources.Load("Examples/Images/CameraMouse"); m_ImagePresetDialogs = (Texture)Resources.Load("Examples/Images/PresetDialogs"); m_ImageShooter = (Texture)Resources.Load("Examples/Images/Shooter"); m_ImageWeaponPosition = (Texture)Resources.Load("Examples/Images/WeaponPosition"); m_ImageWeaponPerspective = (Texture)Resources.Load("Examples/Images/WeaponRendering"); m_ImageWeaponPivot = (Texture)Resources.Load("Examples/Images/WeaponPivot"); m_ImageEditorScreenshot = (Texture)Resources.Load("Examples/Images/EditorScreenshot"); m_ImageLeftArrow = (Texture)Resources.Load("Examples/Images/LeftArrow"); m_ImageRightArrow = (Texture)Resources.Load("Examples/Images/RightArrow"); m_ImageCheck = (Texture)Resources.Load("Examples/Images/Check"); m_ImageLeftPointer = (Texture)Resources.Load("Examples/Images/LeftPointer"); m_ImageRightPointer = (Texture)Resources.Load("Examples/Images/RightPointer"); m_ImageUpPointer = (Texture)Resources.Load("Examples/Images/UpPointer"); m_ImageCrosshair = (Texture)Resources.Load("Examples/Images/Crosshair"); m_ImageFullScreen = (Texture)Resources.Load("Examples/Images/Fullscreen"); // on small screen resolutions the editor preview screenshot // panel is minimized by default, otherwise expanded if (Screen.width < 1024) m_EditorPreviewSectionExpanded = false; // add an audio source to the camera, for playing various demo sounds m_AudioSource = (AudioSource)m_Camera.gameObject.AddComponent("AudioSource"); } }