public static ushort GetVehicle(Vector3 airdropPos) { int max = cf.AirdropVehicles.Sum(v => v.weight); int rnd = Rand.Next(0, max); foreach (Vehicle v in cf.AirdropVehicles) { VehicleAsset va = (VehicleAsset)Assets.find(EAssetType.VEHICLE, (ushort)v.id); if (va.engine != EEngine.BOAT) //TODO: Find a better replacement, temporary fix { if (WaterUtility.isPointUnderwater(airdropPos) && !cf.AllowDropInWater) { continue; } } if (rnd < v.weight) { return((ushort)v.id); } rnd -= v.weight; } return(0); }
private void ComputeVisibleAreas(Bounds waterfallBounds) { _clipeePoints.Clear(); _clipeePoints.Add(_renderingCameraFrustum.TopLeft); _clipeePoints.Add(_renderingCameraFrustum.TopRight); _clipeePoints.Add(_renderingCameraFrustum.BottomRight); _clipeePoints.Add(_renderingCameraFrustum.BottomLeft); bool isRenderingCameraFullyContainedInWaterBox = true; //Finding visible Waterfall Area Vector2 waterfallBoundsMin = waterfallBounds.min; Vector2 waterfallBoundsMax = waterfallBounds.max; //Clip camera frustrum against waterfall box edges to find the visible water area //top edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: true, isBottomOrLeftEdge: false, edgePosition: waterfallBoundsMax.y); //right edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: false, isBottomOrLeftEdge: false, edgePosition: waterfallBoundsMax.x); //bottom edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: true, isBottomOrLeftEdge: true, edgePosition: waterfallBoundsMin.y); //left edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: false, isBottomOrLeftEdge: true, edgePosition: waterfallBoundsMin.x); _visibleArea.UpdateArea(_clipeePoints, _renderingCameraFrustum, isRenderingCameraFullyContainedInWaterBox, true, _farClipPlane); }
// Token: 0x06002083 RID: 8323 RVA: 0x000B29A0 File Offset: 0x000B0DA0 private void FixedUpdate() { for (int i = 0; i < this.voxels.Count; i++) { Vector3 vector = base.transform.TransformPoint(this.voxels[i]); bool flag; float num; if (this.overrideSurfaceElevation < 0f) { WaterUtility.getUnderwaterInfo(vector, out flag, out num); } else { flag = (vector.y < this.overrideSurfaceElevation); num = this.overrideSurfaceElevation; } if (flag) { if (!Dedicator.isDedicated) { num += Mathf.Sin((vector.x + vector.z) * 8f + Time.time) * 0.1f; } if (vector.y - this.voxelHalfHeight < num) { Vector3 pointVelocity = this.rootRigidbody.GetPointVelocity(vector); Vector3 a = -pointVelocity * Buoyancy.DAMPER * this.rootRigidbody.mass; Vector3 force = a + Mathf.Sqrt(Mathf.Clamp01((num - vector.y) / (2f * this.voxelHalfHeight) + 0.5f)) * this.localArchimedesForce; this.rootRigidbody.AddForceAtPosition(force, vector); } } } }
// Token: 0x06003979 RID: 14713 RVA: 0x001AABFC File Offset: 0x001A8FFC private void Update() { if (this.bob != null) { if (this.isLuring) { bool flag; float num; WaterUtility.getUnderwaterInfo(this.bob.position, out flag, out num); if (flag && this.bob.position.y < num - 4f) { this.bob.GetComponent <Rigidbody>().useGravity = false; this.bob.GetComponent <Rigidbody>().isKinematic = true; this.water = this.bob.position; this.water.y = num; this.isLuring = false; } } else { if (Time.realtimeSinceStartup - this.lastLuck > this.luckTime) { if (!this.isReeling) { this.resetLuck(); this.hasLuckReset = true; } } else if (Time.realtimeSinceStartup - this.lastLuck > this.luckTime - 1.4f) { if (!this.hasTugged) { this.hasTugged = true; base.player.playSound(((ItemFisherAsset)base.player.equipment.asset).tug); base.player.animator.play("Tug", false); } } else if (Time.realtimeSinceStartup - this.lastLuck > this.luckTime - 2.4f && !this.hasSplashed) { this.hasSplashed = true; Transform transform = ((GameObject)UnityEngine.Object.Instantiate(Resources.Load("Fishers/Splash"))).transform; transform.name = "Splash"; transform.parent = Level.effects; transform.position = this.water; transform.rotation = Quaternion.Euler(-90f, UnityEngine.Random.Range(0f, 360f), 0f); UnityEngine.Object.Destroy(transform.gameObject, 8f); } if (Time.realtimeSinceStartup - this.lastLuck > this.luckTime - 1.4f) { this.bob.GetComponent <Rigidbody>().MovePosition(Vector3.Lerp(this.bob.position, this.water + Vector3.down * 4f + Vector3.left * UnityEngine.Random.Range(-4f, 4f) + Vector3.forward * UnityEngine.Random.Range(-4f, 4f), 4f * Time.deltaTime)); } else { this.bob.GetComponent <Rigidbody>().MovePosition(Vector3.Lerp(this.bob.position, this.water + Vector3.up * Mathf.Sin(Time.time) * 0.25f, 4f * Time.deltaTime)); } } } }
private void DestroyMaskObject(MeshRenderer mask) { if (mask != null) { WaterUtility.SafeDestroyObject(mask.GetComponent <MeshFilter>().sharedMesh); WaterUtility.SafeDestroyObject(mask.sharedMaterial); WaterUtility.SafeDestroyObject(mask.gameObject); } }
private bool checkTargetValid(Vector3 point) { if (!Level.checkSafeIncludingClipVolumes(point)) { return(false); } float height = LevelGround.getHeight(point); return(!WaterUtility.isPointUnderwater(new Vector3(point.x, height - 1f, point.z))); }
// Token: 0x060033E4 RID: 13284 RVA: 0x00152031 File Offset: 0x00150431 public static EPhysicsMaterial getMaterial(Vector3 point, Transform transform, Collider collider) { if (WaterUtility.isPointUnderwater(point)) { return(EPhysicsMaterial.WATER_STATIC); } if (transform.CompareTag("Ground")) { return(PhysicsTool.checkMaterial(point)); } return(PhysicsTool.checkMaterial(collider)); }
private static void OnAllWaterKitObjectsDestroyed() { if (_g2dwCamera != null) { WaterUtility.SafeDestroyObject(_g2dwCamera.gameObject); } if (_refractionMask != null) { WaterUtility.SafeDestroyObject(_refractionMask.gameObject); } }
private void ComputeVisibleAreas(Bounds waterBounds) { var materialModule = _materialModule as WaterMaterialModule; bool isReflectionEnabled = materialModule.IsReflectionEnabled; _clipeePoints.Clear(); _clipeePoints.Add(_renderingCameraFrustum.TopLeft); _clipeePoints.Add(_renderingCameraFrustum.TopRight); _clipeePoints.Add(_renderingCameraFrustum.BottomRight); _clipeePoints.Add(_renderingCameraFrustum.BottomLeft); bool isRenderingCameraFullyContainedInWaterBox = true; //Finding visible Water Area Vector2 waterBoundsMin = waterBounds.min; Vector2 waterBoundsMax = waterBounds.max; //Clip camera frustrum against water box edges to find the visible water area //top edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: true, isBottomOrLeftEdge: false, edgePosition: waterBoundsMax.y); //right edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: false, isBottomOrLeftEdge: false, edgePosition: waterBoundsMax.x); //bottom edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: true, isBottomOrLeftEdge: true, edgePosition: waterBoundsMin.y); //left edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: false, isBottomOrLeftEdge: true, edgePosition: waterBoundsMin.x); bool isFakePerspectiveEnabled = materialModule.IsFakePerspectiveEnabled; bool computePixelSize = !Refraction.RenderTextureUseFixedSize || !(isFakePerspectiveEnabled ? RefractionPartiallySubmergedObjects.RenderTextureUseFixedSize : Reflection.RenderTextureUseFixedSize); _wholeWaterVisibleArea.UpdateArea(_clipeePoints, _renderingCameraFrustum, isRenderingCameraFullyContainedInWaterBox, computePixelSize, _farClipPlane, true, isReflectionEnabled && !isFakePerspectiveEnabled, reflectionYOffset: ReflectionYOffset, reflectionZOffset: ReflectionZOffset, reflectionAxis: -waterBoundsMin.y, reflectionFrustumHeightScalingFactor: Reflection.ViewingFrustumHeightScalingFactor); if (isFakePerspectiveEnabled) { float waterBoxHeight = waterBoundsMax.y - waterBoundsMin.y; bool computeRefractionProperties = !materialModule.IsRefractionEnabled; float surfaceLevel = waterBoundsMin.y + waterBoxHeight * materialModule.GetSurfaceLevelNormalized(); float submergeLevel = waterBoundsMin.y + waterBoxHeight * materialModule.GetSubmergeLevelNormalized(); //Finding visible Surface Area isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: true, isBottomOrLeftEdge: true, edgePosition: surfaceLevel); _surfaceVisibleArea.UpdateArea(_clipeePoints, _renderingCameraFrustum, isRenderingCameraFullyContainedInWaterBox, !Reflection.RenderTextureUseFixedSize, _farClipPlane, computeRefractionProperties, isReflectionEnabled, reflectionYOffset: ReflectionYOffset, reflectionZOffset: ReflectionZOffset, reflectionAxis: waterBoundsMax.y, reflectionFrustumHeightScalingFactor: Reflection.ViewingFrustumHeightScalingFactor); //Finding visible Surface Area below submerge level isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: true, isBottomOrLeftEdge: false, edgePosition: submergeLevel); _surfaceBelowSubmergeLevelVisibleArea.UpdateArea(_clipeePoints, _renderingCameraFrustum, isRenderingCameraFullyContainedInWaterBox, !ReflectionPartiallySubmergedObjects.RenderTextureUseFixedSize, _farClipPlane, false, isReflectionEnabled, reflectionYOffset: ReflectionYOffset, reflectionZOffset: ReflectionZOffset, reflectionAxis: submergeLevel, reflectionFrustumHeightScalingFactor: ReflectionPartiallySubmergedObjects.ViewingFrustumHeightScalingFactor); } }
protected override void Cleanup() { if (_ripplesEffectsRoot != null) { WaterUtility.SafeDestroyObject(_ripplesEffectsRoot.gameObject); } if (_areModulesInitialized) { _renderingModule.MeshMask.Cleanup(); } _areModulesInitialized = false; }
void UpdateMaterial() { if (!sunLight) { sunLight = FindObjectOfType <Light>(); } // make up our own light direction if no light could be found // (just avoids tedious null checks later on) var lightDir = sunLight ? sunLight.transform.forward : -Vector3.one.normalized; var transmittance = WaterUtility.GetTransmittance(lightDir, settings.sunExtinction.ToVector3()); float sunFade = Mathf.Clamp01((.1f - lightDir.y) * 10); float scatterFade = Mathf.Clamp01((.15f - lightDir.y) * 4); if (surfaceMaterial) { surfaceMaterial.SetTexture("_NormalTex", settings.normalTexture); surfaceMaterial.SetVector("_WindDirection", settings.windDirection); surfaceMaterial.SetFloat("_WindSpeed", settings.windSpeed); surfaceMaterial.SetFloat("_Visibility", settings.visibility); surfaceMaterial.SetFloat("_WaveScale", settings.waveScale); surfaceMaterial.SetFloat("_ScatterAmount", settings.scatterAmount); surfaceMaterial.SetColor("_ScatterColor", settings.scatterColor); surfaceMaterial.SetFloat("_ReflDistortionAmount", settings.reflectionDistortionAmount); surfaceMaterial.SetFloat("_RefrDistortionAmount", settings.refractionDistortionAmount); surfaceMaterial.SetFloat("_AberrationAmount", settings.aberrationAmount); surfaceMaterial.SetColor("_WaterExtinction", settings.waterExtinction); surfaceMaterial.SetVector("_SunTransmittance", transmittance); surfaceMaterial.SetFloat("_SunFade", sunFade); surfaceMaterial.SetFloat("_ScatterFade", scatterFade); } if (groundMaterial) { groundMaterial.SetTexture("_NormalTex", settings.normalTexture); groundMaterial.SetVector("_WindDirection", settings.windDirection); groundMaterial.SetFloat("_WindSpeed", settings.windSpeed); groundMaterial.SetFloat("_Visibility", settings.visibility); groundMaterial.SetFloat("_WaveScale", settings.waveScale); groundMaterial.SetColor("_MudExtinction", settings.mudExtinction); groundMaterial.SetColor("_WaterExtinction", settings.waterExtinction); groundMaterial.SetVector("_SunTransmittance", transmittance); groundMaterial.SetFloat("_SunFade", sunFade); groundMaterial.SetFloat("_ScatterFade", scatterFade); } }
private void ComputeVisibleAreas(Camera currentRenderingCamera, Bounds waterBounds) { bool isReflectionEnabled = _materialModule.IsReflectionEnabled; _clipeePoints.Clear(); _clipeePoints.Add(_renderingCameraFrustum.WaterLocalSpace.TopLeft); _clipeePoints.Add(_renderingCameraFrustum.WaterLocalSpace.TopRight); _clipeePoints.Add(_renderingCameraFrustum.WaterLocalSpace.BottomRight); _clipeePoints.Add(_renderingCameraFrustum.WaterLocalSpace.BottomLeft); bool isRenderingCameraFullyContainedInWaterBox = true; //Fidning visible Water Area Vector2 waterBoundsMin = waterBounds.min; Vector2 waterBoundsMax = waterBounds.max; //Clip camera frustrum against water box edges to find the visible water area //top edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstEdge(_clipeePoints, isHorizontalEdge: true, keepInside: false, edgeValue: waterBoundsMax.y); //right edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstEdge(_clipeePoints, isHorizontalEdge: false, keepInside: false, edgeValue: waterBoundsMax.x); //bottom edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstEdge(_clipeePoints, isHorizontalEdge: true, keepInside: true, edgeValue: waterBoundsMin.y); //left edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstEdge(_clipeePoints, isHorizontalEdge: false, keepInside: true, edgeValue: waterBoundsMin.x); _fullWaterVisibleArea.UpdateArea(_clipeePoints, _renderingCameraFrustum, isRenderingCameraFullyContainedInWaterBox, _farClipPlane, isReflectionEnabled, reflectionAxis: -waterBoundsMin.y); if (_materialModule.IsFakePerspectiveEnabled) { float waterBoxHeight = waterBoundsMax.y - waterBoundsMin.y; //Finding visible Surface Area float surfaceLevel = waterBoundsMin.y + waterBoxHeight * _materialModule.SurfaceLevel; isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstEdge(_clipeePoints, isHorizontalEdge: true, keepInside: true, edgeValue: surfaceLevel); _surfaceVisibleArea.UpdateArea(_clipeePoints, _renderingCameraFrustum, isRenderingCameraFullyContainedInWaterBox, _farClipPlane, isReflectionEnabled, reflectionAxis: waterBoundsMax.y, viewingFrustrumHeightScalingFactor: _reflection.ViewingFrustumHeightScalingFactor); //Finding visible Surface Area below submerge level float submergeLevel = waterBoundsMin.y + waterBoxHeight * _materialModule.SurfaceSubmergeLevel; isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstEdge(_clipeePoints, isHorizontalEdge: true, keepInside: false, edgeValue: submergeLevel); _surfaceBelowSubmergeLevelVisibleArea.UpdateArea(_clipeePoints, _renderingCameraFrustum, isRenderingCameraFullyContainedInWaterBox, _farClipPlane, isReflectionEnabled, reflectionAxis: submergeLevel, viewingFrustrumHeightScalingFactor: _reflectionPartiallySubmergedObjects.ViewingFrustumHeightScalingFactor); } }
protected void updateRenderQueue() { if (WaterUtility.isPointUnderwater(base.transform.position)) { if (LevelLighting.isSea) { this.material.renderQueue = 3100; } else { this.material.renderQueue = 2900; } } else if (LevelLighting.isSea) { this.material.renderQueue = 2900; } else { this.material.renderQueue = 3100; } }
private Vector3[] ComputeVertices() { var vertices = new List <Vector3>(); int vertexCount = 0; for (int i = 0, imax = _controlPoints.Count; i < imax; i++) { var currentSegment = _controlPoints[i]; var nextSegment = _controlPoints[i + 1 < imax ? i + 1 : 0]; for (int j = 0, jmax = _subdivisions + 1; j < jmax; j++) { float t = j / (float)jmax; var vertexPosition = (1f - t) * (1f - t) * (1f - t) * currentSegment.anchorPointPosition + t * t * t * nextSegment.anchorPointPosition + 3f * t * (1f - t) * (1f - t) * currentSegment.secondHandlePosition + 3f * (1f - t) * t * t * nextSegment.firstHandlePosition; if (vertexCount > 1 && WaterUtility.AreColinear(vertices[vertexCount - 2], vertices[vertexCount - 1], vertexPosition)) { vertices[vertexCount - 1] = vertexPosition; } else { vertices.Add(vertexPosition); vertexCount++; } } } if (WaterUtility.AreColinear(vertices[vertexCount - 2], vertices[vertexCount - 1], vertices[0])) { vertices.RemoveAt(vertexCount - 1); } return(vertices.ToArray()); }
public static void chartify() { Bundle bundle = Bundles.getBundle(Level.info.path + "/Charts.unity3d", false); if (bundle == null) { return; } Texture2D texture2D = (Texture2D)bundle.load("Height_Strip"); Texture2D texture2D2 = (Texture2D)bundle.load("Layer_Strip"); bundle.unload(); if (texture2D == null || texture2D2 == null) { return; } Texture2D texture2D3 = new Texture2D((int)Level.size, (int)Level.size); texture2D3.name = "Chartify"; texture2D3.hideFlags = 61; texture2D3.filterMode = 2; float num = Mathf.Clamp01(WaterSystem.worldSeaLevel / Level.TERRAIN); float num2 = 1f; for (byte b = 0; b < Regions.WORLD_SIZE; b += 1) { for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1) { if (!LevelObjects.regions[(int)b, (int)b2]) { List<LevelObject> list = LevelObjects.objects[(int)b, (int)b2]; for (int i = 0; i < list.Count; i++) { list[i].enableCollision(); list[i].enableVisual(); } } if (!LevelGround.regions[(int)b, (int)b2]) { List<ResourceSpawnpoint> list2 = LevelGround.trees[(int)b, (int)b2]; for (int j = 0; j < list2.Count; j++) { list2[j].enable(); } } } } GameObject gameObject = new GameObject(); gameObject.layer = LayerMasks.GROUND; for (int k = 0; k < texture2D3.width; k++) { for (int l = 0; l < texture2D3.height; l++) { Vector3 vector; vector..ctor((float)(-(float)Level.size) / 2f + (float)Level.border + (float)k / (float)texture2D3.width * ((float)Level.size - (float)Level.border * 2f), Level.HEIGHT, (float)(-(float)Level.size) / 2f + (float)Level.border + (float)l / (float)texture2D3.height * ((float)Level.size - (float)Level.border * 2f)); EObjectChart eobjectChart; RaycastHit raycastHit; Level.findChartHit(vector, out eobjectChart, out raycastHit); Transform transform = raycastHit.transform; Vector3 point = raycastHit.point; if (transform == null) { transform = gameObject.transform; point = vector; point.y = LevelGround.getHeight(vector); } int num3 = transform.gameObject.layer; if (eobjectChart == EObjectChart.GROUND) { num3 = LayerMasks.GROUND; } else if (eobjectChart == EObjectChart.HIGHWAY) { num3 = 0; } else if (eobjectChart == EObjectChart.ROAD) { num3 = 1; } else if (eobjectChart == EObjectChart.STREET) { num3 = 2; } else if (eobjectChart == EObjectChart.PATH) { num3 = 3; } else if (eobjectChart == EObjectChart.LARGE) { num3 = LayerMasks.LARGE; } else if (eobjectChart == EObjectChart.MEDIUM) { num3 = LayerMasks.MEDIUM; } else if (eobjectChart == EObjectChart.CLIFF) { num3 = 4; } if (num3 == LayerMasks.ENVIRONMENT) { RoadMaterial roadMaterial = LevelRoads.getRoadMaterial(transform); if (roadMaterial != null) { if (!roadMaterial.isConcrete) { num3 = 3; } else if (roadMaterial.width > 8f) { num3 = 0; } else { num3 = 1; } } } Color pixel; if (eobjectChart == EObjectChart.WATER) { pixel = texture2D.GetPixel(0, 0); } else if (num3 == LayerMasks.GROUND) { if (WaterUtility.isPointUnderwater(point)) { pixel = texture2D.GetPixel(0, 0); } else { float num4 = point.y / Level.TERRAIN; num4 = (num4 - num) / (num2 - num); num4 = Mathf.Clamp01(num4); pixel = texture2D.GetPixel((int)(num4 * (float)(texture2D.width - 1)) + 1, 0); } } else { pixel = texture2D2.GetPixel(num3, 0); } texture2D3.SetPixel(k, l, pixel); } } texture2D3.Apply(); for (byte b3 = 0; b3 < Regions.WORLD_SIZE; b3 += 1) { for (byte b4 = 0; b4 < Regions.WORLD_SIZE; b4 += 1) { if (!LevelObjects.regions[(int)b3, (int)b4]) { List<LevelObject> list3 = LevelObjects.objects[(int)b3, (int)b4]; for (int m = 0; m < list3.Count; m++) { list3[m].disableCollision(); list3[m].disableVisual(); } } if (!LevelGround.regions[(int)b3, (int)b4]) { List<ResourceSpawnpoint> list4 = LevelGround.trees[(int)b3, (int)b4]; for (int n = 0; n < list4.Count; n++) { list4[n].disable(); } } } } byte[] bytes = texture2D3.EncodeToPNG(); ReadWrite.writeBytes(Level.info.path + "/Chart.png", false, false, bytes); Object.DestroyImmediate(texture2D3); }
private void ComputeIsometricViewingFrustum(WaterRenderingCameraFrustum renderingCameraFrustum, bool computePixelSize, Vector2 boundingBoxMin, Vector2 boundingBoxMax, float zFar, bool renderRefraction, bool renderReflection, float reflectionAxis, float reflectionZOffset, float reflectionFrustumHeightScalingFactor) { var currentCamera = renderingCameraFrustum.CurrentCamera; var waterLocalSpaceToCameraSpaceMatrix = currentCamera.worldToCameraMatrix * _mainModule.LocalToWorldMatrix; Vector3 cBoundingBoxMin = waterLocalSpaceToCameraSpaceMatrix.MultiplyPoint3x4(boundingBoxMin); Vector3 cBoundingBoxMax = waterLocalSpaceToCameraSpaceMatrix.MultiplyPoint3x4(boundingBoxMax); Vector3 cBoundingBoxMinXMaxY = waterLocalSpaceToCameraSpaceMatrix.MultiplyPoint3x4(new Vector3(boundingBoxMin.x, boundingBoxMax.y)); Vector3 cBoundingBoxMaxXMinY = waterLocalSpaceToCameraSpaceMatrix.MultiplyPoint3x4(new Vector3(boundingBoxMax.x, boundingBoxMin.y)); Vector3 frustumBottomLeft, frustumTopRight; frustumBottomLeft.x = WaterUtility.Min(cBoundingBoxMin.x, cBoundingBoxMinXMaxY.x, cBoundingBoxMax.x, cBoundingBoxMaxXMinY.x); frustumBottomLeft.y = WaterUtility.Min(cBoundingBoxMin.y, cBoundingBoxMinXMaxY.y, cBoundingBoxMax.y, cBoundingBoxMaxXMinY.y); frustumTopRight.x = WaterUtility.Max(cBoundingBoxMin.x, cBoundingBoxMinXMaxY.x, cBoundingBoxMax.x, cBoundingBoxMaxXMinY.x); frustumTopRight.y = WaterUtility.Max(cBoundingBoxMin.y, cBoundingBoxMinXMaxY.y, cBoundingBoxMax.y, cBoundingBoxMaxXMinY.y); float nearClipPlane = -WaterUtility.Max(cBoundingBoxMin.z, cBoundingBoxMinXMaxY.z, cBoundingBoxMax.z, cBoundingBoxMaxXMinY.z); float frustumWidth = frustumTopRight.x - frustumBottomLeft.x; float frustumHeight = frustumTopRight.y - frustumBottomLeft.y; if (computePixelSize) { float pixelsPerUnit = currentCamera.pixelHeight * 0.5f / currentCamera.orthographicSize; PixelWidth = (int)(frustumWidth * pixelsPerUnit); PixelHeight = (int)(frustumHeight * pixelsPerUnit); if (!IsValid) { return; } } float farClipPlane = nearClipPlane + zFar; Vector3 position = currentCamera.cameraToWorldMatrix.MultiplyPoint3x4(new Vector3((frustumBottomLeft.x + frustumTopRight.x) * 0.5f, (frustumBottomLeft.y + frustumTopRight.y) * 0.5f)); if (renderRefraction) { RefractionProperties.Position = position; RefractionProperties.Rotation = currentCamera.transform.rotation; RefractionProperties.ProjectionMatrix = ComputeObliqueOrthographicMatrix(frustumWidth, frustumHeight, nearClipPlane, farClipPlane, RefractionProperties.Position, RefractionProperties.Rotation, _mainModule.Position, _mainModule.ForwardDirection, -0.001f, 1f); RefractionProperties.NearClipPlane = nearClipPlane; } if (renderReflection) { Vector3 lPosition = _mainModule.TransformPointWorldToLocal(position); lPosition.y = 2f * reflectionAxis - lPosition.y; Vector3 rotationEulerAngles = renderingCameraFrustum.Rotation; rotationEulerAngles.x *= -1f; rotationEulerAngles.z = -rotationEulerAngles.z + _mainModule.ZRotation; ReflectionProperties.Position = _mainModule.TransformPointLocalToWorld(lPosition); ReflectionProperties.Rotation = Quaternion.Euler(rotationEulerAngles); ReflectionProperties.NearClipPlane = nearClipPlane + reflectionZOffset; ReflectionProperties.ProjectionMatrix = ComputeObliqueOrthographicMatrix(frustumWidth, frustumHeight, ReflectionProperties.NearClipPlane, farClipPlane, ReflectionProperties.Position, ReflectionProperties.Rotation, _mainModule.Position, _mainModule.ForwardDirection, reflectionZOffset, reflectionFrustumHeightScalingFactor); } IsOrthographicCamera = true; OrthographicSize = frustumHeight * 0.5f; Aspect = frustumWidth / frustumHeight; FarClipPlane = farClipPlane; }
public void simulate(uint simulation, bool inputCrouch, bool inputProne, bool inputSprint) { this._isSubmerged = WaterUtility.isPointUnderwater(base.player.look.aim.position); if (this.stance == EPlayerStance.CLIMB || ((this.stance == EPlayerStance.STAND || this.stance == EPlayerStance.SPRINT || this.stance == EPlayerStance.SWIM) && !base.player.equipment.isBusy)) { Physics.Raycast(base.transform.position + Vector3.up * 0.5f, base.transform.forward, ref this.ladder, 0.75f, RayMasks.LADDER_INTERACT); if (this.ladder.transform != null && this.ladder.transform.CompareTag("Ladder") && Mathf.Abs(Vector3.Dot(this.ladder.normal, this.ladder.transform.up)) > 0.9f) { if (this.stance != EPlayerStance.CLIMB) { Vector3 vector = new Vector3(this.ladder.transform.position.x, this.ladder.point.y - 0.5f, this.ladder.transform.position.z) + this.ladder.normal * 0.5f; if (!Physics.CapsuleCast(base.transform.position + new Vector3(0f, PlayerStance.RADIUS, 0f), base.transform.position + new Vector3(0f, PlayerMovement.HEIGHT_STAND - PlayerStance.RADIUS, 0f), PlayerStance.RADIUS, (vector - base.transform.position).normalized, (vector - base.transform.position).magnitude, RayMasks.BLOCK_LADDER, 1)) { base.transform.position = vector; this.checkStance(EPlayerStance.CLIMB); } } if (this.stance == EPlayerStance.CLIMB) { return; } } else if (this.stance == EPlayerStance.CLIMB) { this.checkStance(EPlayerStance.STAND); } } bool flag = WaterUtility.isPointUnderwater(base.transform.position); if (WaterUtility.isPointUnderwater(base.transform.position + new Vector3(0f, 1.25f, 0f))) { if (this.stance != EPlayerStance.SWIM) { this.checkStance(EPlayerStance.SWIM); } return; } if (flag) { if (this.stance != EPlayerStance.STAND && this.stance != EPlayerStance.SPRINT) { this.checkStance(EPlayerStance.STAND); } } else if (this.stance == EPlayerStance.SWIM) { this.checkStance(EPlayerStance.STAND); } if (this.stance != EPlayerStance.CLIMB && this.stance != EPlayerStance.SITTING && this.stance != EPlayerStance.DRIVING) { if (inputCrouch != this.lastCrouch) { this.lastCrouch = inputCrouch; if (!flag) { if (inputCrouch) { this.checkStance(EPlayerStance.CROUCH); } else if (this.stance == EPlayerStance.CROUCH) { this.checkStance(EPlayerStance.STAND); } } } if (inputProne != this.lastProne) { this.lastProne = inputProne; if (!flag) { if (inputProne) { this.checkStance(EPlayerStance.PRONE); } else if (this.stance == EPlayerStance.PRONE) { this.checkStance(EPlayerStance.STAND); } } } if (inputSprint != this.lastSprint) { this.lastSprint = inputSprint; if (inputSprint) { if (this.stance == EPlayerStance.STAND && !base.player.life.isBroken && base.player.life.stamina > 0 && (double)base.player.movement.multiplier > 0.9 && base.player.movement.isMoving) { this.checkStance(EPlayerStance.SPRINT); } } else if (this.stance == EPlayerStance.SPRINT) { this.checkStance(EPlayerStance.STAND); } } if (this.stance == EPlayerStance.SPRINT && (base.player.life.isBroken || base.player.life.stamina == 0 || (double)base.player.movement.multiplier < 0.9 || !base.player.movement.isMoving)) { this.checkStance(EPlayerStance.STAND); } } else { this.lastCrouch = false; this.lastProne = false; this.lastSprint = false; } }
// Token: 0x060039EC RID: 14828 RVA: 0x001BA558 File Offset: 0x001B8958 private bool fire(bool mode, out ERefillWaterType newWaterType) { newWaterType = ERefillWaterType.EMPTY; if (base.channel.isOwner) { Ray ray = new Ray(base.player.look.aim.position, base.player.look.aim.forward); RaycastInfo raycastInfo = DamageTool.raycast(ray, 3f, RayMasks.DAMAGE_CLIENT); if (!(raycastInfo.transform != null)) { return(false); } InteractableRainBarrel component = raycastInfo.transform.GetComponent <InteractableRainBarrel>(); InteractableTank component2 = raycastInfo.transform.GetComponent <InteractableTank>(); InteractableObjectResource component3 = raycastInfo.transform.GetComponent <InteractableObjectResource>(); WaterVolume waterVolume; if (WaterUtility.isPointUnderwater(raycastInfo.point, out waterVolume)) { if (mode) { return(false); } if (this.waterType != ERefillWaterType.EMPTY) { return(false); } if (waterVolume == null) { newWaterType = ERefillWaterType.SALTY; } else { newWaterType = waterVolume.waterType; } } else if (component != null) { if (mode) { if (this.waterType != ERefillWaterType.CLEAN) { return(false); } if (component.isFull) { return(false); } newWaterType = ERefillWaterType.EMPTY; } else { if (this.waterType == ERefillWaterType.CLEAN) { return(false); } if (!component.isFull) { return(false); } newWaterType = ERefillWaterType.CLEAN; } } else if (component2 != null) { if (component2.source != ETankSource.WATER) { return(false); } if (mode) { if (this.waterType != ERefillWaterType.CLEAN) { return(false); } if (component2.amount == component2.capacity) { return(false); } newWaterType = ERefillWaterType.EMPTY; } else { if (this.waterType == ERefillWaterType.CLEAN) { return(false); } if (component2.amount == 0) { return(false); } newWaterType = ERefillWaterType.CLEAN; } } else { if (!(component3 != null)) { return(false); } if (component3.objectAsset.interactability != EObjectInteractability.WATER) { return(false); } if (mode) { if (this.waterType == ERefillWaterType.EMPTY) { return(false); } if (component3.amount == component3.capacity) { return(false); } newWaterType = ERefillWaterType.EMPTY; } else { if (this.waterType == ERefillWaterType.CLEAN || this.waterType == ERefillWaterType.DIRTY) { return(false); } if (component3.amount == 0) { return(false); } newWaterType = ERefillWaterType.DIRTY; } } base.player.input.sendRaycast(raycastInfo); } if (Provider.isServer) { if (!base.player.input.hasInputs()) { return(false); } InputInfo input = base.player.input.getInput(true); if (input == null) { return(false); } if ((input.point - base.player.look.aim.position).sqrMagnitude > 49f) { return(false); } WaterVolume waterVolume2; if (WaterUtility.isPointUnderwater(input.point, out waterVolume2)) { if (mode) { return(false); } if (this.waterType != ERefillWaterType.EMPTY) { return(false); } if (waterVolume2 == null) { newWaterType = ERefillWaterType.SALTY; } else { newWaterType = waterVolume2.waterType; } } else if (input.type == ERaycastInfoType.BARRICADE) { if (input.transform == null || !input.transform.CompareTag("Barricade")) { return(false); } InteractableRainBarrel component4 = input.transform.GetComponent <InteractableRainBarrel>(); InteractableTank component5 = input.transform.GetComponent <InteractableTank>(); if (component4 != null) { if (mode) { if (this.waterType != ERefillWaterType.CLEAN) { return(false); } if (component4.isFull) { return(false); } BarricadeManager.updateRainBarrel(component4.transform, true, true); newWaterType = ERefillWaterType.EMPTY; } else { if (this.waterType == ERefillWaterType.CLEAN) { return(false); } if (!component4.isFull) { return(false); } BarricadeManager.updateRainBarrel(component4.transform, false, true); newWaterType = ERefillWaterType.CLEAN; } } else { if (!(component5 != null)) { return(false); } if (component5.source != ETankSource.WATER) { return(false); } if (mode) { if (this.waterType != ERefillWaterType.CLEAN) { return(false); } if (component5.amount == component5.capacity) { return(false); } BarricadeManager.updateTank(input.transform, (ushort)((byte)(component5.amount + 1))); newWaterType = ERefillWaterType.EMPTY; } else { if (this.waterType == ERefillWaterType.CLEAN) { return(false); } if (component5.amount == 0) { return(false); } BarricadeManager.updateTank(input.transform, (ushort)((byte)(component5.amount - 1))); newWaterType = ERefillWaterType.CLEAN; } } } else if (input.type == ERaycastInfoType.OBJECT) { if (input.transform == null) { return(false); } InteractableObjectResource component6 = input.transform.GetComponent <InteractableObjectResource>(); if (component6 == null || component6.objectAsset.interactability != EObjectInteractability.WATER) { return(false); } if (mode) { if (this.waterType == ERefillWaterType.EMPTY) { return(false); } if (component6.amount == component6.capacity) { return(false); } ObjectManager.updateObjectResource(component6.transform, (ushort)((byte)(component6.amount + 1)), true); newWaterType = ERefillWaterType.EMPTY; } else { if (this.waterType == ERefillWaterType.CLEAN || this.waterType == ERefillWaterType.DIRTY) { return(false); } if (component6.amount == 0) { return(false); } ObjectManager.updateObjectResource(component6.transform, (ushort)((byte)(component6.amount - 1)), true); newWaterType = ERefillWaterType.DIRTY; } } } return(true); }