static bool tick_Prefix(Animal __instance) { var pet = PetsPlugin.Instance.PetsService.GetPet(__instance); if (pet == null) { return(true); } Vector3 playerPos = pet.Player.transform.position; Vector3 spawnPos = playerPos + ((pet.Player.transform.right + pet.Player.transform.forward) * PetsPlugin.Instance.Configuration.Instance.MinDistance); spawnPos.y = LevelGround.getHeight(spawnPos); float delta = Time.time - (float)ReflectionUtil.getValue("lastTick", __instance); ReflectionUtil.setValue("lastTick", Time.time, __instance); ReflectionUtil.setValue("target", spawnPos, __instance); ReflectionUtil.setValue("_isFleeing", true, __instance); ReflectionUtil.setValue("player", null, __instance); ReflectionUtil.setValue("isAttacking", false, __instance); ReflectionUtil.setValue("_isFleeing", true, pet.Animal); ReflectionUtil.setValue("isWandering", false, pet.Animal); ReflectionUtil.setValue("isHunting", false, pet.Animal); ReflectionUtil.callMethod("move", __instance, delta); return(false); }
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: 0x06002666 RID: 9830 RVA: 0x000E1A3C File Offset: 0x000DFE3C public void getTrackPosition(float t, out int index, out Vector3 position, out Vector3 normal) { position = this.getPosition(t, out index); normal = Vector3.up; if (!this.joints[index].ignoreTerrain) { position.y = LevelGround.getHeight(position); normal = LevelGround.getNormal(position); } position += normal * (LevelRoads.materials[(int)this.material].depth + LevelRoads.materials[(int)this.material].offset); }
// Token: 0x0600267A RID: 9850 RVA: 0x000E3CAC File Offset: 0x000E20AC public void updatePoints() { for (int i = 0; i < this.joints.Count; i++) { RoadJoint roadJoint = this.joints[i]; if (!roadJoint.ignoreTerrain) { roadJoint.vertex.y = LevelGround.getHeight(roadJoint.vertex); } } for (int j = 0; j < this.joints.Count; j++) { RoadPath roadPath = this.paths[j]; roadPath.vertex.position = this.joints[j].vertex; roadPath.tangents[0].gameObject.SetActive(j > 0 || this.isLoop); roadPath.tangents[1].gameObject.SetActive(j < this.joints.Count - 1 || this.isLoop); roadPath.setTangent(0, this.joints[j].getTangent(0)); roadPath.setTangent(1, this.joints[j].getTangent(1)); } if (this.joints.Count < 2) { this.lineRenderer.numPositions = 0; return; } this.updateSamples(); this.lineRenderer.numPositions = this.samples.Count; for (int k = 0; k < this.samples.Count; k++) { RoadSample roadSample = this.samples[k]; RoadJoint roadJoint2 = this.joints[roadSample.index]; Vector3 position = this.getPosition(roadSample.index, roadSample.time); if (!roadJoint2.ignoreTerrain) { position.y = LevelGround.getHeight(position); } if (roadSample.index < this.joints.Count - 1) { position.y += Mathf.Lerp(roadJoint2.offset, this.joints[roadSample.index + 1].offset, roadSample.time); } else if (this.isLoop) { position.y += Mathf.Lerp(roadJoint2.offset, this.joints[0].offset, roadSample.time); } else { position.y += roadJoint2.offset; } this.lineRenderer.SetPosition(k, position); } }
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); }
// Token: 0x06002677 RID: 9847 RVA: 0x000E25D0 File Offset: 0x000E09D0 public void buildMesh() { for (int i = 0; i < this.road.childCount; i++) { UnityEngine.Object.Destroy(this.road.GetChild(i).gameObject); } if (this.joints.Count < 2) { return; } this.updateSamples(); if (!Level.isEditor) { bool flag = false; foreach (LevelTrainAssociation levelTrainAssociation in Level.info.configData.Trains) { if (levelTrainAssociation.RoadIndex == this.roadIndex) { flag = true; break; } } if (flag) { this.updateTrackSamples(); } } Vector3[] array = new Vector3[this.samples.Count * 4 + ((!this.isLoop) ? 8 : 0)]; Vector3[] array2 = new Vector3[this.samples.Count * 4 + ((!this.isLoop) ? 8 : 0)]; Vector2[] array3 = new Vector2[this.samples.Count * 4 + ((!this.isLoop) ? 8 : 0)]; float num = 0f; Vector3 b = Vector3.zero; Vector3 vector = Vector3.zero; Vector3 vector2 = Vector3.zero; Vector3 vector3 = Vector3.zero; Vector3 a = Vector3.zero; Vector2 b2 = Vector2.zero; int j; for (j = 0; j < this.samples.Count; j++) { RoadSample roadSample = this.samples[j]; RoadJoint roadJoint = this.joints[roadSample.index]; vector = this.getPosition(roadSample.index, roadSample.time); if (!roadJoint.ignoreTerrain) { vector.y = LevelGround.getHeight(vector); } vector2 = this.getVelocity(roadSample.index, roadSample.time).normalized; if (roadJoint.ignoreTerrain) { vector3 = Vector3.up; } else { vector3 = LevelGround.getNormal(vector); } a = Vector3.Cross(vector2, vector3); if (!roadJoint.ignoreTerrain) { Vector3 point = vector + a * LevelRoads.materials[(int)this.material].width; float num2 = LevelGround.getHeight(point) - point.y; if (num2 > 0f) { vector.y += num2; } Vector3 point2 = vector - a * LevelRoads.materials[(int)this.material].width; float num3 = LevelGround.getHeight(point2) - point2.y; if (num3 > 0f) { vector.y += num3; } } if (roadSample.index < this.joints.Count - 1) { vector.y += Mathf.Lerp(roadJoint.offset, this.joints[roadSample.index + 1].offset, roadSample.time); } else if (this.isLoop) { vector.y += Mathf.Lerp(roadJoint.offset, this.joints[0].offset, roadSample.time); } else { vector.y += roadJoint.offset; } array[((!this.isLoop) ? 4 : 0) + j * 4] = vector + a * (LevelRoads.materials[(int)this.material].width + LevelRoads.materials[(int)this.material].depth * 2f) - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset; array[((!this.isLoop) ? 4 : 0) + j * 4 + 1] = vector + a * LevelRoads.materials[(int)this.material].width + vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset; array[((!this.isLoop) ? 4 : 0) + j * 4 + 2] = vector - a * LevelRoads.materials[(int)this.material].width + vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset; array[((!this.isLoop) ? 4 : 0) + j * 4 + 3] = vector - a * (LevelRoads.materials[(int)this.material].width + LevelRoads.materials[(int)this.material].depth * 2f) - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset; array2[((!this.isLoop) ? 4 : 0) + j * 4] = vector3; array2[((!this.isLoop) ? 4 : 0) + j * 4 + 1] = vector3; array2[((!this.isLoop) ? 4 : 0) + j * 4 + 2] = vector3; array2[((!this.isLoop) ? 4 : 0) + j * 4 + 3] = vector3; if (j == 0) { b = vector; array3[((!this.isLoop) ? 4 : 0) + j * 4] = Vector2.zero; array3[((!this.isLoop) ? 4 : 0) + j * 4 + 1] = Vector2.zero; array3[((!this.isLoop) ? 4 : 0) + j * 4 + 2] = Vector2.right; array3[((!this.isLoop) ? 4 : 0) + j * 4 + 3] = Vector2.right; } else { num += (vector - b).magnitude; b = vector; b2 = Vector2.up * num / (float)LevelRoads.materials[(int)this.material].material.mainTexture.height * LevelRoads.materials[(int)this.material].height; array3[((!this.isLoop) ? 4 : 0) + j * 4] = Vector2.zero + b2; array3[((!this.isLoop) ? 4 : 0) + j * 4 + 1] = Vector2.zero + b2; array3[((!this.isLoop) ? 4 : 0) + j * 4 + 2] = Vector2.right + b2; array3[((!this.isLoop) ? 4 : 0) + j * 4 + 3] = Vector2.right + b2; } } if (!this.isLoop) { array[4 + j * 4] = vector + a * (LevelRoads.materials[(int)this.material].width + LevelRoads.materials[(int)this.material].depth * 2f) - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset + vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array[4 + j * 4 + 1] = vector + a * LevelRoads.materials[(int)this.material].width - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset + vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array[4 + j * 4 + 2] = vector - a * LevelRoads.materials[(int)this.material].width - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset + vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array[4 + j * 4 + 3] = vector - a * (LevelRoads.materials[(int)this.material].width + LevelRoads.materials[(int)this.material].depth * 2f) - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset + vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array2[4 + j * 4] = vector3; array2[4 + j * 4 + 1] = vector3; array2[4 + j * 4 + 2] = vector3; array2[4 + j * 4 + 3] = vector3; b2 = Vector2.up * num / (float)LevelRoads.materials[(int)this.material].material.mainTexture.height * LevelRoads.materials[(int)this.material].height; array3[4 + j * 4] = Vector2.zero + b2; array3[4 + j * 4 + 1] = Vector2.zero + b2; array3[4 + j * 4 + 2] = Vector2.right + b2; array3[4 + j * 4 + 3] = Vector2.right + b2; j = 0; vector = this.getPosition(this.samples[0].index, this.samples[0].time); if (!this.joints[0].ignoreTerrain) { vector.y = LevelGround.getHeight(vector); } vector2 = this.getVelocity(this.samples[0].index, this.samples[0].time).normalized; if (this.joints[0].ignoreTerrain) { vector3 = LevelGround.getNormal(this.joints[0].vertex); } else { vector3 = LevelGround.getNormal(vector); } a = Vector3.Cross(vector2, vector3); if (!this.joints[0].ignoreTerrain) { Vector3 point3 = vector + a * LevelRoads.materials[(int)this.material].width; float num4 = LevelGround.getHeight(point3) - point3.y; if (num4 > 0f) { vector.y += num4; } Vector3 point4 = vector - a * LevelRoads.materials[(int)this.material].width; float num5 = LevelGround.getHeight(point4) - point4.y; if (num5 > 0f) { vector.y += num5; } } vector.y += this.joints[0].offset; array[j * 4] = vector + a * (LevelRoads.materials[(int)this.material].width + LevelRoads.materials[(int)this.material].depth * 2f) - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset - vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array[j * 4 + 1] = vector + a * LevelRoads.materials[(int)this.material].width - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset - vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array[j * 4 + 2] = vector - a * LevelRoads.materials[(int)this.material].width - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset - vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array[j * 4 + 3] = vector - a * (LevelRoads.materials[(int)this.material].width + LevelRoads.materials[(int)this.material].depth * 2f) - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset - vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array2[j * 4] = vector3; array2[j * 4 + 1] = vector3; array2[j * 4 + 2] = vector3; array2[j * 4 + 3] = vector3; array3[j * 4] = Vector2.zero; array3[j * 4 + 1] = Vector2.zero; array3[j * 4 + 2] = Vector2.right; array3[j * 4 + 3] = Vector2.right; } int num6 = 0; for (int k = 0; k < this.samples.Count; k += 20) { int num7 = Mathf.Min(k + 20, this.samples.Count - 1); int num8 = num7 - k + 1; if (!this.isLoop) { if (k == 0) { num8++; } if (num7 == this.samples.Count - 1) { num8++; } } Vector3[] array4 = new Vector3[num8 * 4]; Vector3[] array5 = new Vector3[num8 * 4]; Vector2[] array6 = new Vector2[num8 * 4]; int[] array7 = new int[num8 * 18]; int num9 = k; if (!this.isLoop && k > 0) { num9++; } Array.Copy(array, num9 * 4, array4, 0, array4.Length); Array.Copy(array2, num9 * 4, array5, 0, array4.Length); Array.Copy(array3, num9 * 4, array6, 0, array4.Length); for (int l = 0; l < num8 - 1; l++) { array7[l * 18] = l * 4 + 5; array7[l * 18 + 1] = l * 4 + 1; array7[l * 18 + 2] = l * 4 + 4; array7[l * 18 + 3] = l * 4; array7[l * 18 + 4] = l * 4 + 4; array7[l * 18 + 5] = l * 4 + 1; array7[l * 18 + 6] = l * 4 + 6; array7[l * 18 + 7] = l * 4 + 2; array7[l * 18 + 8] = l * 4 + 5; array7[l * 18 + 9] = l * 4 + 1; array7[l * 18 + 10] = l * 4 + 5; array7[l * 18 + 11] = l * 4 + 2; array7[l * 18 + 12] = l * 4 + 7; array7[l * 18 + 13] = l * 4 + 3; array7[l * 18 + 14] = l * 4 + 6; array7[l * 18 + 15] = l * 4 + 2; array7[l * 18 + 16] = l * 4 + 6; array7[l * 18 + 17] = l * 4 + 3; } Transform transform = new GameObject().transform; transform.name = "Segment_" + num6; transform.parent = this.road; transform.tag = "Environment"; transform.gameObject.layer = LayerMasks.ENVIRONMENT; transform.gameObject.AddComponent <MeshCollider>(); if (!Dedicator.isDedicated) { transform.gameObject.AddComponent <MeshFilter>(); MeshRenderer meshRenderer = transform.gameObject.AddComponent <MeshRenderer>(); meshRenderer.reflectionProbeUsage = ReflectionProbeUsage.Simple; meshRenderer.shadowCastingMode = ShadowCastingMode.Off; } if (LevelRoads.materials[(int)this.material].isConcrete) { transform.GetComponent <Collider>().sharedMaterial = (PhysicMaterial)Resources.Load("Physics/Concrete_Static"); } else { transform.GetComponent <Collider>().sharedMaterial = (PhysicMaterial)Resources.Load("Physics/Gravel_Static"); } Mesh mesh = new Mesh(); mesh.name = "Road_Segment_" + num6; mesh.vertices = array4; mesh.normals = array5; mesh.uv = array6; mesh.triangles = array7; transform.GetComponent <MeshCollider>().sharedMesh = mesh; if (!Dedicator.isDedicated) { transform.GetComponent <MeshFilter>().sharedMesh = mesh; transform.GetComponent <Renderer>().sharedMaterial = LevelRoads.materials[(int)this.material].material; } num6++; } }