public static void Add(TreeWindSfx tree) { if (!TreeWindSfxManager.sTrees.Contains(tree)) { TreeWindSfxManager.sTrees.Add(tree); TreeWindSfxManager.sTreeInfoList.Add(TreeWindSfxManager.GetTreeInfo(tree)); } }
private static void CreateDebugTextures() { TreeWindSfxManager.activeTexture = new Texture2D(10, 10, TextureFormat.ARGB32, false); TreeWindSfxManager.Fill(TreeWindSfxManager.activeTexture, new Color(0f, 0f, 0f, 0f)); TreeWindSfxManager.DrawDiamond(TreeWindSfxManager.activeTexture, new Color(0f, 1f, 0f, 0.5f)); TreeWindSfxManager.activeTexture.Apply(); TreeWindSfxManager.inactiveTexture = new Texture2D(10, 10, TextureFormat.ARGB32, false); TreeWindSfxManager.Fill(TreeWindSfxManager.inactiveTexture, new Color(0f, 0f, 0f, 0f)); TreeWindSfxManager.DrawDiamond(TreeWindSfxManager.inactiveTexture, new Color(1f, 1f, 1f, 0.5f)); TreeWindSfxManager.inactiveTexture.Apply(); TreeWindSfxManager.playerTexture = new Texture2D(10, 10, TextureFormat.ARGB32, false); TreeWindSfxManager.Fill(TreeWindSfxManager.playerTexture, new Color(0f, 0f, 0f, 0f)); TreeWindSfxManager.DrawDiamond(TreeWindSfxManager.playerTexture, new Color(1f, 1f, 1f, 1f)); TreeWindSfxManager.playerTexture.Apply(); }
private void UpdateVirtualisation() { if (TreeWindSfxManager.sTrees.Count <= this.TargetActiveCount) { foreach (TreeWindSfx treeWindSfx in TreeWindSfxManager.sTrees) { treeWindSfx.Activate(); } } else { List <TreeWindSfxManager.TreeInfo> list = TreeWindSfxManager.sTreeInfoList; if (LocalPlayer.Transform != null) { Vector3 position = LocalPlayer.Transform.position; for (int i = 0; i < list.Count; i++) { TreeWindSfxManager.TreeInfo treeInfo = list[i]; Vector3 vector = treeInfo.position - position; treeInfo.sqrDistance = vector.sqrMagnitude; treeInfo.direction = Mathf.Atan2(vector.z, vector.x); } } for (int j = 0; j < this.TargetActiveCount; j++) { int num = j; for (int k = j + 1; k < list.Count; k++) { if (list[k].sqrDistance < list[num].sqrDistance) { num = k; } } TreeWindSfxManager.Swap(list, j, num); list[j].tree.Activate(); TreeWindSfxManager.OccludeTrees(list[j], this.TreeOcclusionWidth, list, j + 1); } for (int l = this.TargetActiveCount; l < list.Count; l++) { list[l].tree.Deactivate(this.TreePersistTime); } } }
private void OnEnable() { TreeWindSfxManager.Add(this); EventDescription eventDescription = FMOD_StudioSystem.instance.GetEventDescription(this.EventPath); if (eventDescription != null) { if (this.WindParameterIndex == -1) { this.WindParameterIndex = FMODCommon.FindParameterIndex(eventDescription, "wind"); } if (this.SizeParameterIndex == -1) { this.SizeParameterIndex = FMODCommon.FindParameterIndex(eventDescription, "size"); } if (this.TimeParameterIndex == -1) { this.TimeParameterIndex = FMODCommon.FindParameterIndex(eventDescription, "time"); } } }
private static void DrawDebug() { if (TreeWindSfxManager.activeTexture == null) { TreeWindSfxManager.CreateDebugTextures(); } List <TreeWindSfxManager.TreeInfo> list = TreeWindSfxManager.sTreeInfoList; float num = 0f; int num2 = 0; for (int i = 0; i < list.Count; i++) { TreeWindSfxManager.TreeInfo treeInfo = list[i]; TreeWindSfx tree = treeInfo.tree; Vector3 vector = LocalPlayer.Transform.InverseTransformPoint(tree.transform.position); num = Math.Max(num, vector.sqrMagnitude); if (tree.IsActive) { num2++; } treeInfo.sqrDistance = vector.sqrMagnitude; treeInfo.direction = Mathf.Atan2(vector.z, vector.x); } num = Mathf.Sqrt(num); Vector2 vector2 = new Vector2(110f, (float)(Camera.main.pixelHeight - 110)); GUI.Box(new Rect(vector2.x - 105f, vector2.y - 105f - 35f, 210f, 245f), string.Format("Active trees: {0} Total trees: {1}", num2, list.Count)); foreach (TreeWindSfxManager.TreeInfo treeInfo2 in list) { float num3 = Mathf.Sqrt(treeInfo2.sqrDistance) / num * 100f; float num4 = vector2.x + num3 * Mathf.Cos(treeInfo2.direction); float num5 = vector2.y - num3 * Mathf.Sin(treeInfo2.direction); Texture2D image = (!treeInfo2.tree.IsActive) ? TreeWindSfxManager.inactiveTexture : TreeWindSfxManager.activeTexture; GUI.DrawTexture(new Rect(num4 - 5f, num5 - 5f, 10f, 10f), image); } GUI.DrawTexture(new Rect(vector2.x - 5f, vector2.y - 5f, 10f, 10f), TreeWindSfxManager.playerTexture); }
private void OnDisable() { TreeWindSfx.StopEvent(this.WindEvent); TreeWindSfxManager.Remove(this); }