private void SetLodBase(LOD_Base lodbase) { CustomActiveValueGreeble component = lodbase.GetComponent <CustomActiveValueGreeble>(); if (component.Data != null && component.Index < component.Data._instancesState.Length) { base.Data = component.Data; base.Index = component.Index; this.InitFromData(); } }
private void SetLodBase(LOD_Base lodbase) { CustomActiveValueGreeble component = lodbase.GetComponent <CustomActiveValueGreeble>(); if (component.Data != null && component.Index < component.Data._instancesState.Length) { base.Data = component.Data; base.Index = component.Index; bool flag = base.Data._instancesState[base.Index] < 252; for (int i = 0; i < this._targets.Length; i++) { bool flag2 = !flag || ((int)base.Data._instancesState[base.Index] & 1 << i) == 0; if (this._targets[i] && flag2 != this._targets[i].activeSelf) { this._targets[i].SetActive(flag2); } } } }
private void OnSerializing() { if (this._proxy) { int num = Mathf.Min(new int[] { this._zoneCount, this._proxy._greebleZones.Length, this._greebleZonesData.Length }); int i; for (i = 0; i < num; i++) { GreebleZone greebleZone = this._proxy._greebleZones[i]; GreebleZonesManager.GZData gzdata = this._greebleZonesData[i]; if (greebleZone && greebleZone.CurrentlyVisible && gzdata != null && gzdata._instancesState != null && gzdata._instancesState.Length == greebleZone.Instances.Length) { int j; for (j = 0; j < greebleZone.Instances.Length; j++) { if (greebleZone.Instances[j]) { if (gzdata._instancesState[j] > 252) { gzdata._instancesState[j] = 253; } else if (gzdata._instancesState[j] == 252) { CustomActiveValueGreeble component = greebleZone.Instances[j].GetComponent <CustomActiveValueGreeble>(); if (component) { component.UpdateGreebleData(); } } } else { gzdata._instancesState[j] = byte.MaxValue; } } int maxInstancesModified = this._proxy._greebleZones[i].MaxInstancesModified; while (j < maxInstancesModified) { gzdata._instancesState[j] = 254; j++; } } else if (greebleZone && gzdata == null) { gzdata = (this._greebleZonesData[i] = new GreebleZonesManager.GZData()); gzdata._instancesState = new byte[greebleZone.MaxInstancesModified]; for (int k = 0; k < gzdata._instancesState.Length; k++) { gzdata._instancesState[k] = 254; } } } for (int l = 0; l < this._nonProxiedZones.Length; l++) { GreebleZone greebleZone2 = this._nonProxiedZones[l]; GreebleZonesManager.GZData gzdata2 = this._greebleZonesData[i]; if (greebleZone2 && greebleZone2.CurrentlyVisible && gzdata2 != null && gzdata2._instancesState != null && gzdata2._instancesState.Length == greebleZone2.Instances.Length) { int m; for (m = 0; m < greebleZone2.Instances.Length; m++) { if (greebleZone2.Instances[m]) { if (gzdata2._instancesState[m] > 252) { gzdata2._instancesState[m] = 253; } else if (gzdata2._instancesState[m] == 252) { CustomActiveValueGreeble component2 = greebleZone2.Instances[m].GetComponent <CustomActiveValueGreeble>(); if (component2) { component2.UpdateGreebleData(); } } } else if (greebleZone2.CurrentlyVisible) { gzdata2._instancesState[m] = byte.MaxValue; } } int maxInstancesModified2 = this._nonProxiedZones[l].MaxInstancesModified; while (m < maxInstancesModified2) { gzdata2._instancesState[m] = 254; m++; } } else if (greebleZone2 && gzdata2 == null) { gzdata2 = (this._greebleZonesData[i] = new GreebleZonesManager.GZData()); gzdata2._instancesState = new byte[greebleZone2.MaxInstancesModified]; for (int n = 0; n < gzdata2._instancesState.Length; n++) { gzdata2._instancesState[n] = 254; } } i++; } this._savedVersion = this._proxy._currentVersion; } }
private void SpawnIndex(int index) { if (this.InstanceData[index].Destroyed) { return; } UnityEngine.Random.seed = this.GetRandomSeed() + index; GreebleDefinition greebleDefinition = GreebleUtility.ProceduralGreebleType(this.GreebleDefinitions, (Time.timeSinceLevelLoad - this.InstanceData[index].CreationTime) / 60f); if (greebleDefinition == null) { UnityEngine.Random.seed = this.GetRandomSeed(); return; } Vector3 vector = Vector3.zero; Vector3 vector2 = Vector3.down; float distance = this.Radius; GreebleShape shape = this.Shape; if (shape != GreebleShape.Sphere) { if (shape == GreebleShape.Box) { Vector3 vector3 = this.Size * 0.5f; Vector3 b = new Vector3(GreebleUtility.ProceduralValue(-vector3.x, vector3.x), GreebleUtility.ProceduralValue(-vector3.y, vector3.y), GreebleUtility.ProceduralValue(-vector3.z, vector3.z)); int num = 0; switch (this.Direction) { case GreebleRayDirection.Floor: num = 4; break; case GreebleRayDirection.Ceiling: num = 5; break; case GreebleRayDirection.Walls: num = GreebleUtility.ProceduralValue(0, 4); break; case GreebleRayDirection.AllDirections: num = GreebleUtility.ProceduralValue(0, 6); break; } switch (num) { case 0: vector2 = Vector3.left; b.x = vector3.x; distance = this.Size.x; break; case 1: vector2 = Vector3.right; b.x = -vector3.x; distance = this.Size.x; break; case 2: vector2 = Vector3.back; b.z = vector3.z; distance = this.Size.z; break; case 3: vector2 = Vector3.forward; b.z = -vector3.z; distance = this.Size.z; break; case 4: vector2 = Vector3.down; b.y = vector3.y; distance = this.Size.y; break; case 5: vector2 = Vector3.up; b.y = -vector3.y; distance = this.Size.y; break; } vector += b; } } else { distance = this.Radius; Vector3 zero = Vector3.zero; do { zero = new Vector3(GreebleUtility.ProceduralValue(-this.Radius, this.Radius), GreebleUtility.ProceduralValue(-this.Radius, this.Radius), GreebleUtility.ProceduralValue(-this.Radius, this.Radius)); }while (zero.magnitude > this.Radius); switch (this.Direction) { case GreebleRayDirection.Floor: vector += new Vector3(zero.x, 0f, zero.y); vector2 = Vector3.down; break; case GreebleRayDirection.Ceiling: vector += new Vector3(zero.x, 0f, zero.y); vector2 = Vector3.up; break; case GreebleRayDirection.Walls: vector2 = GreebleUtility.ProceduralDirectionFast(); vector2.y = 0f; vector2.Normalize(); vector += zero - Vector3.Project(zero, vector2); break; case GreebleRayDirection.AllDirections: vector2 = GreebleUtility.ProceduralDirection(); break; } } Quaternion rotation = Quaternion.identity; if (greebleDefinition.RandomizeRotation) { rotation = Quaternion.Euler((!greebleDefinition.AllowRotationX) ? 0f : GreebleUtility.ProceduralAngle(), (!greebleDefinition.AllowRotationY) ? 0f : GreebleUtility.ProceduralAngle(), (!greebleDefinition.AllowRotationZ) ? 0f : GreebleUtility.ProceduralAngle()); } this.instances[index] = GreebleUtility.Spawn(greebleDefinition, new Ray(base.transform.TransformPoint(vector), base.transform.TransformDirection(vector2)), distance, rotation, 0.5f); if (this.Data != null && this.instances[index] != null && Application.isPlaying) { try { if (greebleDefinition.HasCustomActiveValue) { CustomActiveValueGreeble component = this.instances[index].GetComponent <CustomActiveValueGreeble>(); component.Data = this.Data; component.Index = index; if (this.Data._instancesState[index] > 252) { this.Data._instancesState[index] = 252; } } else { this.Data._instancesState[index] = 253; } } catch (Exception message) { Debug.Log(message); } } if (this.instances[index]) { if (this.MpSync && BoltNetwork.isServer) { BoltNetwork.Attach(this.instances[index]); } this.InstanceData[index].Spawned = true; if (this.OnSpawned != null) { this.OnSpawned(index, this.instances[index]); } } UnityEngine.Random.seed = this.GetRandomSeed(); }