public static void RemoveViewModel() { if (CameraFX.mainViewModel) { CameraFX.ReplaceViewModel(null, false); } }
internal static void ApplyTransitionAlterations(Camera camera, CameraFX fx, bool useFX) { Matrix4x4G matrix4x4G; Matrix4x4G matrix4x4G1; if (!useFX) { camera.ExtractCameraMatrixWorldToCamera(out matrix4x4G); camera.ExtractCameraMatrixProjection(out matrix4x4G1); int num = CameraFX.g_trans.Update(ref matrix4x4G, ref matrix4x4G1); if ((num & 1) == 1) { camera.ResetWorldToCameraMatrix(); camera.worldToCameraMatrix = matrix4x4G.f; } if ((num & 2) == 2) { camera.ResetProjectionMatrix(); camera.projectionMatrix = matrix4x4G1.f; } } else { int num1 = CameraFX.g_trans.Update(ref fx.worldToCameraMatrix, ref fx.projectionMatrix); if ((num1 & 1) == 1) { camera.worldToCameraMatrix = fx.worldToCameraMatrix.f; Matrix4x4G.Inverse(ref fx.worldToCameraMatrix, out fx.cameraToWorldMatrix); } if ((num1 & 2) == 2) { camera.projectionMatrix = fx.projectionMatrix.f; } } }
protected virtual void DestroyViewModel() { if (this._vm != null) { CameraFX.RemoveViewModel(ref this._vm, true, false); } }
internal static void ApplyTransitionAlterations(Camera camera, CameraFX fx, bool useFX) { if (useFX) { int num = g_trans.Update(ref fx.worldToCameraMatrix, ref fx.projectionMatrix); if ((num & 1) == 1) { camera.worldToCameraMatrix = fx.worldToCameraMatrix.f; Matrix4x4G.Inverse(ref fx.worldToCameraMatrix, out fx.cameraToWorldMatrix); } if ((num & 2) == 2) { camera.projectionMatrix = fx.projectionMatrix.f; } } else { Matrix4x4G matrixxg; Matrix4x4G matrixxg2; camera.ExtractCameraMatrixWorldToCamera(out matrixxg); camera.ExtractCameraMatrixProjection(out matrixxg2); int num2 = g_trans.Update(ref matrixxg, ref matrixxg2); if ((num2 & 1) == 1) { camera.ResetWorldToCameraMatrix(); camera.worldToCameraMatrix = matrixxg.f; } if ((num2 & 2) == 2) { camera.ResetProjectionMatrix(); camera.projectionMatrix = matrixxg2.f; } } }
private void Awake() { this.awoke = true; if (this.camera == null) { this.camera = base.camera; } this.camera.enabled = false; if (creatingTemporaryCameraMount) { temporaryCameraMount = this; if (temporaryCameraMountHasParent) { Transform transform = base.transform; transform.parent = temporaryCameraMountParent; Transform transform2 = temporaryCameraMountSource.transform; transform.localPosition = transform2.localPosition; transform.localRotation = transform2.localRotation; transform.localScale = transform2.localScale; } this.camera.CopyFrom(temporaryCameraMountSource.camera); this.cameraFX = temporaryCameraMountSource.cameraFX; if (temporaryCameraMountSource.open) { this.Bind(); } } else if (this.autoBind) { this.Bind(); } }
private int flashFrames; // Number of frames to flash upon a hit. // Set up the singleton design pattern. private void Awake() { if (instance == null) { instance = this; } }
protected Vector3 GetPoint(PlacementSpace space, Vector3 input) { switch (space) { case PlacementSpace.World: { Vector3?nullable = CameraFX.World2Screen(input); input = Target.camera.ScreenToWorldPoint(!nullable.HasValue ? Vector3.zero : nullable.Value); return(input); } case PlacementSpace.Screen: input = Target.camera.ScreenToWorldPoint(input); return(input); case PlacementSpace.Viewport: input = Target.camera.ViewportToWorldPoint(input); return(input); case PlacementSpace.Anchor: input = this.anchor.transform.TransformPoint(input); return(input); } return(input); }
private static HUDIndicator InstantiateIndicator(ref Target target, HUDIndicator prefab, PlacementSpace space, Vector3 position, float rotation) { UIAnchor anchor = target.anchor; Quaternion quaternion = Quaternion.AngleAxis(rotation, Vector3.back); switch (space) { case PlacementSpace.World: { Vector3?nullable = CameraFX.World2Screen(position); position = Target.camera.ScreenToWorldPoint(!nullable.HasValue ? Vector3.zero : nullable.Value); break; } case PlacementSpace.Screen: position = Target.camera.ScreenToWorldPoint(position); break; case PlacementSpace.Viewport: position = Target.camera.ViewportToWorldPoint(position); break; case PlacementSpace.Anchor: position = anchor.transform.TransformPoint(position); quaternion = anchor.transform.rotation * quaternion; break; } position.z = anchor.transform.position.z; HUDIndicator indicator = (HUDIndicator)Object.Instantiate(prefab, position, quaternion); indicator.transform.parent = anchor.transform; indicator.transform.localScale = Vector3.one; indicator.anchor = target.anchor; return(indicator); }
protected Vector3 GetPoint(HUDIndicator.PlacementSpace space, Vector3 input) { switch (space) { case HUDIndicator.PlacementSpace.World: { Camera camera = HUDIndicator.Target.camera; Vector3?nullable = CameraFX.World2Screen(input); input = camera.ScreenToWorldPoint((!nullable.HasValue ? Vector3.zero : nullable.Value)); break; } case HUDIndicator.PlacementSpace.Screen: { input = HUDIndicator.Target.camera.ScreenToWorldPoint(input); break; } case HUDIndicator.PlacementSpace.Viewport: { input = HUDIndicator.Target.camera.ViewportToWorldPoint(input); break; } case HUDIndicator.PlacementSpace.Anchor: { input = this.anchor.transform.TransformPoint(input); break; } } return(input); }
public void PreCullBegin() { CameraMount cameraMount = CameraMount.current; if (cameraMount != this.mount) { if (!cameraMount) { this._cameraFX = null; } else { this._cameraFX = cameraMount.cameraFX; } CameraFXPre.cameraFX = this._cameraFX; CameraFXPost.cameraFX = this._cameraFX; this.mount = cameraMount; } if (this.mount) { Camera camera = this.mount.camera; camera.ResetAspect(); camera.ResetProjectionMatrix(); camera.ResetWorldToCameraMatrix(); this.mount.OnPreMount(this); } }
public static void RemoveViewModel(ref ViewModel vm, bool deleteEvenIfNotCurrent, bool removeCurrentIfNotVM) { if (!vm) { if (removeCurrentIfNotVM) { CameraFX.RemoveViewModel(); } return; } if (CameraFX.mainViewModel != vm) { if (deleteEvenIfNotCurrent) { UnityEngine.Object.Destroy(vm.gameObject); vm = null; } if (removeCurrentIfNotVM) { CameraFX.ReplaceViewModel(null, false); } } else { CameraFX.ReplaceViewModel(null, false); vm = null; } }
void OnDestroy() { // RELEASE SINGLETON REF if (inst == this) { inst = null; } }
public ClientMPPlayer(MasterRenderer renderer, World world, Camera camera, Vector3 position, Team team) : base(renderer, world, camera, position, team) { this.camera = camera; camfx = new CameraFX(this, camera); // Setup ClientInput Snapshot AOSClient client = AOSClient.Instance; SnapshotNetComponent snc = client.GetComponent <SnapshotNetComponent>(); SnapshotSystem ss = snc.SnapshotSystem; ClientSnapshot = new ClientPlayerSnapshot(ss, client.ServerConnection); Camera.Active.FOV = Camera.Active.DefaultFOV; Camera.Active.FPSMouseSensitivity = Camera.Active.DefaultFPSMouseSensitivity; Camera.Active.ArcBallMouseSensitivity = Camera.Active.DefaultArcBallMouseSensitivity; CreateStarterBackpack(); AudioBuffer hitAudioBuffer = AssetManager.LoadSound("Impacts/hit-player-local.wav"); if (hitAudioBuffer != null) { hitAudioSource = new AudioSource(hitAudioBuffer); hitAudioSource.IsSourceRelative = true; hitAudioSource.Gain = 0.2f; } AudioBuffer flashlightAudioBuffer = AssetManager.LoadSound("Player/flashlight.wav"); if (flashlightAudioBuffer != null) { flashlightAudioSource = new AudioSource(flashlightAudioBuffer); flashlightAudioSource.IsSourceRelative = true; flashlightAudioSource.Gain = 0.2f; } AudioBuffer jumpAudioBuffer = AssetManager.LoadSound("Player/jump.wav"); if (jumpAudioBuffer != null) { jumpAudioSource = new AudioSource(jumpAudioBuffer); jumpAudioSource.IsSourceRelative = true; jumpAudioSource.Gain = 0.2f; } AudioBuffer landAudioBuffer = AssetManager.LoadSound("Player/land.wav"); if (landAudioBuffer != null) { landAudioSource = new AudioSource(landAudioBuffer); landAudioSource.IsSourceRelative = true; landAudioSource.Gain = 0.2f; } walkingAudioSource = new CyclicAudioSource("Player/footstep.wav", 8, 0f); runningAudioSource = new CyclicAudioSource("Player/run.wav", 12, 0f); }
public void PreCullEnd(bool postCamFX) { if (this.mount != null) { Transform transform = this.mount.transform; base.transform.position = transform.position; base.transform.rotation = transform.rotation; CameraClearFlags clearFlags = this.camera.clearFlags; int cullingMask = this.camera.cullingMask; DepthTextureMode depthTextureMode = this.camera.depthTextureMode; this.camera.ResetProjectionMatrix(); this.camera.ResetWorldToCameraMatrix(); this.mount.camera.depthTextureMode = depthTextureMode; this.camera.CopyFrom(this.mount.camera); if (!postCamFX) { CameraFX.ApplyTransitionAlterations(this.camera, null, false); } this.camera.clearFlags = clearFlags; this.camera.cullingMask = cullingMask; if (this.camera.depthTextureMode != depthTextureMode) { Debug.Log("Yea this is changing depth texture mode!", this.mount); this.camera.depthTextureMode = depthTextureMode; } this.mount.OnPostMount(this); this.lastView = this.camera.worldToCameraMatrix; this.lastProj = this.camera.projectionMatrix; this.once = true; } else { if (!this.once) { this.lastView = this.camera.worldToCameraMatrix; this.lastProj = this.camera.projectionMatrix; this.once = true; } this.camera.ResetProjectionMatrix(); this.camera.ResetWorldToCameraMatrix(); this.camera.worldToCameraMatrix = this.lastView; this.camera.projectionMatrix = this.lastProj; if (!postCamFX) { CameraFX.ApplyTransitionAlterations(this.camera, null, false); } } Matrix4x4 cameraToWorldMatrix = this.camera.cameraToWorldMatrix; base.transform.position = cameraToWorldMatrix.MultiplyPoint(Vector3.zero); Vector3 forward = cameraToWorldMatrix.MultiplyVector(-Vector3.forward); base.transform.rotation = Quaternion.LookRotation(forward, cameraToWorldMatrix.MultiplyVector(Vector3.up)); Shader.SetGlobalMatrix("_RUST_MATRIX_CAMERA_TO_WORLD", cameraToWorldMatrix * negateZMatrix); Shader.SetGlobalMatrix("_RUST_MATRIX_WORLD_TO_CAMERA", this.camera.worldToCameraMatrix * negateZMatrix); }
protected void OnDestroy() { base.OnDestroy(); if (_mainCameraFX == this) { _mainCamera = null; _mainCameraFX = null; _hasMainCameraFX = false; } }
protected new void OnDestroy() { base.OnDestroy(); if (CameraFX._mainCameraFX == this) { CameraFX._mainCamera = null; CameraFX._mainCameraFX = null; CameraFX._hasMainCameraFX = false; } }
public void Start() { oldSecondCamera = secondCamera; cameraFX = GetComponent <CameraFX>(); mainCamera = GetComponent <Camera>(); if (secondCamera) { cameraFX.Transition(1); } }
public void EnableTransition(float duration, TransitionFunction function) { if (!this.open) { this.open = true; if (this.isActiveMount) { CameraFX.TransitionNow(duration, function); } } }
public void OnCollisionEnter2D(Collision2D coll) { EnemyData data = coll.gameObject.GetComponent <EnemyData>(); if (data != null && data.isHeavy && coll.relativeVelocity.sqrMagnitude >= Mathf.Pow(velocityNeededToBreak, 2)) { CameraFX.Screenshake(cameraShakeDuration, shakeIntensity, shakeIntensity); alive = false; Instantiate(onBreakEffect, transform.position, Quaternion.identity); } }
public override void exit() { if (BattleEnded != null) { BattleEnded.Invoke(); } AudioManager.PlayDefaultBGM(); CameraFX.FadeOut(); camScript.enabled = true; camScript.UpdateToMapBounds(); }
private void Awake() { // Ensure that there is only one instance of the CameraFX. if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
public static Vector3?Viewport2World(Vector3 point) { if (CameraFX.Bind()) { return(new Vector3?(CameraFX._mainCameraFX.ScreenToWorldPoint(point))); } if (!CameraFX._hasMainCamera) { return(null); } return(new Vector3?(CameraFX._mainCamera.ScreenToWorldPoint(point))); }
public static Vector3?Viewport2Screen(Vector3 point) { if (CameraFX.Bind()) { return(new Vector3?(CameraFX._mainCameraFX.ViewportToScreenPoint(point))); } if (!CameraFX._hasMainCamera) { return(null); } return(new Vector3?(CameraFX._mainCamera.ViewportToScreenPoint(point))); }
public static Ray?Viewport2Ray(Vector3 point) { if (CameraFX.Bind()) { return(new Ray?(CameraFX._mainCameraFX.ScreenPointToRay(point))); } if (!CameraFX._hasMainCamera) { return(null); } return(new Ray?(CameraFX._mainCamera.ScreenPointToRay(point))); }
public static Vector3?World2Viewport(Vector3 point) { if (CameraFX.Bind()) { return(new Vector3?(CameraFX._mainCameraFX.WorldToViewportPoint(point))); } if (!CameraFX._hasMainCamera) { return(null); } return(new Vector3?(CameraFX._mainCamera.WorldToViewportPoint(point))); }
public static void ReplaceViewModel(ViewModel vm, ItemRepresentation rep, IHeldItem item, bool butDontDestroyOld) { CameraFX mainCameraFX = CameraFX.mainCameraFX; if ((mainCameraFX != null) && (mainCameraFX.viewModel != vm)) { ViewModel viewModel = mainCameraFX.viewModel; mainCameraFX.SetViewModel(vm, rep, item); if (!butDontDestroyOld && (viewModel != null)) { Object.Destroy(viewModel.gameObject); } } }
protected virtual void CreateViewModel() { this.DestroyViewModel(); if ((base.datablock._viewModelPrefab != null) && !actor.forceThirdPerson) { this._vm = (ViewModel)UnityEngine.Object.Instantiate(base.datablock._viewModelPrefab); this._vm.PlayDeployAnimation(); if (base.datablock.deploySound != null) { base.datablock.deploySound.Play((float)1f); } CameraFX.ReplaceViewModel(this._vm, this._itemRep, base.iface as IHeldItem, false); } }
public static void ReplaceViewModel(ViewModel vm, ItemRepresentation rep, IHeldItem item, bool butDontDestroyOld) { CameraFX cameraFX = CameraFX.mainCameraFX; if (cameraFX && cameraFX.viewModel != vm) { ViewModel viewModel = cameraFX.viewModel; cameraFX.SetViewModel(vm, rep, item); if (!butDontDestroyOld && viewModel) { UnityEngine.Object.Destroy(viewModel.gameObject); } } }
IEnumerator StartBattle() { CameraFX.ZoomIn(1f); yield return(new WaitForSecondsRealtime(0.5f)); CameraFX.FadeIn(); camScript.enabled = false; yield return(new WaitForSecondsRealtime(1f)); CameraFX.ResetRenderScreen(); CameraFX.FadeOut(); camScript.enabled = false; Time.timeScale = 1; BattleScene.instance.StartBattle(); }
void Awake() { if (camTransform == null) { camTransform = GetComponent(typeof(Transform)) as Transform; cam = camTransform.GetComponent <Camera> (); } ca = GetComponent <AdvancedCA> (); if (instance == null) { instance = this; } }
private void Awake() { this.awoke = true; if (!this.camera) { this.camera = base.camera; } this.camera.enabled = false; if (CameraMount.creatingTemporaryCameraMount) { CameraMount.temporaryCameraMount = this; if (CameraMount.temporaryCameraMountHasParent) { Transform transforms = base.transform; transforms.parent = CameraMount.temporaryCameraMountParent; Transform transforms1 = CameraMount.temporaryCameraMountSource.transform; transforms.localPosition = transforms1.localPosition; transforms.localRotation = transforms1.localRotation; transforms.localScale = transforms1.localScale; } this.camera.CopyFrom(CameraMount.temporaryCameraMountSource.camera); this.cameraFX = CameraMount.temporaryCameraMountSource.cameraFX; if (CameraMount.temporaryCameraMountSource.open) { this.Bind(); } } else if (this.autoBind) { this.Bind(); } }
//-------------------------------------------------------------------------------- // EVENTS //-------------------------------------------------------------------------------- void Awake() { // EAGERLY ACQUIRE SINGLETON REF inst = this; // CACHE BASE CAMERA PARAMS xform = this.transform; body = this.rigidbody; cam = GetComponent<Camera>(); baseColor = cam.backgroundColor; p0 = xform.position; // ADJUST KILL COLLIDER var box = GetComponent<BoxCollider>(); if (box) { var c = box.center; box.center = Vec(c.x, HalfHeight + 0.5f * box.size.y, c.z); } }