public static void Postfix(CyclopsExternalDamageManager __instance, bool __state) { if (__state) { NitroxServiceLocator.LocateService <Cyclops>().OnCreateDamagePoint(__instance.subRoot); } }
public static bool Prefix(CyclopsExternalDamageManager __instance, out bool __state) { // Block from creating points if they aren't the owner of the sub __state = NitroxServiceLocator.LocateService <SimulationOwnership>().HasAnyLockType(NitroxEntity.GetId(__instance.subRoot.gameObject)); return(__state); }
private void DrawCyclopsDebugMenu() { if (GUILayout.Button("Destroy Cyclops static mesh")) { Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray4, out RaycastHit raycastHit4)) { if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops")) { Transform transform = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic"); Log.Print("Size 1: " + transform.GetComponentInChildren <MeshFilter>().mesh.triangles.Length); Log.Print("Size 2: " + transform.GetComponentInChildren <MeshFilter>().mesh.vertices.Length); Destroy(transform.gameObject); } } } if (GUILayout.Button("Cyclops Engine RPM SFX Manager")) { Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray4, out RaycastHit raycastHit4)) { if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops")) { EngineRpmSFXManager engine = raycastHit4.rigidbody.GetComponentInChildren <EngineRpmSFXManager>(); if (engine == null) { Utilities.Log.Print("EngineRpmSFXManager not found"); return; } Log.Print("engineRpmSFX: " + engine.engineRpmSFX?.asset?.path); Log.Print("stopSoundInterval: " + engine.engineRpmSFX?.stopSoundInterval); Log.Print("engineRevUp: " + engine.engineRevUp?.asset?.path); Log.Print("rampUpSpeed: " + engine.rampUpSpeed); Log.Print("rampDownSpeed: " + engine.rampDownSpeed); } } } if (GUILayout.Button("Cyclops render materials")) { Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray4, out RaycastHit raycastHit4)) { if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops")) { //Transform gggg1 = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic").transform.Find("undamaged").Find("cyclops_LOD0").Find("cyclops_submarine_exterior"); Transform gggg1 = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic").transform.Find("undamaged").Find("cyclops_LOD0").Find("Cyclops_submarine_exterior_glass"); //Transform gggg1 = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic").transform.Find("undamaged").Find("cyclops_LOD0").Find("cyclops_submarine_exterior_decals"); //Transform gggg1 = raycastHit4.rigidbody.gameObject.transform.Find("CyclopsMeshStatic").transform.Find("undamaged").Find("cyclops_LOD0"); /*foreach (MeshRenderer mr in gggg1.gameObject.GetComponentsInChildren<MeshRenderer>()) * { * Utilities.Log.Print("Gameobject: " + mr.gameObject.name); * foreach (Material mat2 in mr.materials) * { * Utilities.Log.Print("Material: " + mat2.name); * Utilities.Log.Print("keywords: " + mat2.shaderKeywords.Length); * foreach(var s in mat2.shaderKeywords) * { * Utilities.Log.Print("Keyword: " + s); * } * Utilities.Log.Print("-"); * } * Utilities.Log.Print("--"); * }*/ Log.Print("Materials count: " + gggg1.GetComponent <MeshRenderer>().materials.Length); Material mat = gggg1.GetComponent <MeshRenderer>().material; mat.PrintAllMarmosetUBERShaderProperties(); } } } if (GUILayout.Button("Cyclops Oxygen Manager")) { Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray4, out RaycastHit raycastHit4)) { if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops")) { OxygenManager[] oxygenManager = raycastHit4.rigidbody.GetComponentsInChildren <OxygenManager>(); Log.Print("Oxygen Manager Found Count " + oxygenManager.Length); } } } if (GUILayout.Button("Cyclops Depth Cleaer")) { Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray4, out RaycastHit raycastHit4)) { if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops")) { SubRoot subRoot = raycastHit4.rigidbody.GetComponent <SubRoot>(); MeshRenderer mr = subRoot.depthClearer as MeshRenderer; Log.Print("DepthClearer type: " + subRoot.depthClearer.GetType()); Log.Print("DepthClearer name: " + subRoot.depthClearer.name); Log.Print("DepthClearer material: " + subRoot.depthClearer.material); Log.Print("DepthClearer mesh: " + subRoot.depthClearer.GetComponent <MeshFilter>().mesh); Log.Print("DepthClearer mesh name: " + subRoot.depthClearer.GetComponent <MeshFilter>().mesh.name); Log.Print("DepthClearer Children count: " + subRoot.depthClearer.transform.childCount); Log.Print("DepthClearer transform pos: " + subRoot.depthClearer.transform.localPosition); Log.Print("DepthClearer transform size: " + subRoot.depthClearer.transform.localScale); Log.Print("DepthClearer transform Parent: " + subRoot.depthClearer.transform.parent?.name); subRoot.depthClearer.material.color = new Color(1f, 0f, 0f, 1f); Log.Print("DepthClearer mat color: " + subRoot.depthClearer.material.color); Log.Print("DepthClearer enabled?: " + subRoot.depthClearer.enabled); Log.Print("DepthClearer Component cound: " + subRoot.depthClearer.GetComponents(typeof(Component)).Length); foreach (Component c in subRoot.depthClearer.GetComponents(typeof(Component))) { Utilities.Log.Print("Component: " + c); } } } } if (GUILayout.Button("Cyclops Ladder")) { Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray4, out RaycastHit raycastHit4)) { if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops")) { Utilities.Log.Print(raycastHit4.rigidbody.gameObject.name); foreach (SkinnedMeshRenderer smr in raycastHit4.rigidbody.gameObject.GetComponentsInChildren <SkinnedMeshRenderer>()) { if (smr.gameObject.name.ToLower().Equals("submarine_ladder_04") || smr.gameObject.name.ToLower().Equals("cyclops_ladder_long") || smr.gameObject.name.ToLower().Equals("cyclops_ladder_short_right") || smr.gameObject.name.ToLower().Equals("cyclops_ladder_short_left") || smr.gameObject.name.ToLower().Equals("submarine_ladder_02")) { Utilities.Log.Print("Mesh: " + smr.gameObject.GetComponent <SkinnedMeshRenderer>()?.sharedMesh?.name); Utilities.Log.Print("Bones Length: " + smr.gameObject.GetComponent <SkinnedMeshRenderer>()?.bones?.Length); smr.gameObject.GetComponent <SkinnedMeshRenderer>()?.material?.PrintAllMarmosetUBERShaderProperties(); } } } } } if (GUILayout.Button("Cyclops Force Damage Point")) { Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray4, out RaycastHit raycastHit4)) { if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops")) { CyclopsExternalDamageManager damage = raycastHit4.rigidbody.GetComponentInChildren <CyclopsExternalDamageManager>(); if (damage == null) { Log.Print("CyclopsExternalDamageManager not found"); return; } MethodInfo mi = SMLHelper.V2.Utility.ReflectionHelper.GetInstanceMethod(damage, "CreatePoint"); if (mi == null) { Log.Print("CreatePoint method not found"); return; } mi.FastInvoke(damage); } } } if (GUILayout.Button("Cyclops Print Damage Info")) { Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray4, out RaycastHit raycastHit4)) { if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops")) { CyclopsExternalDamageManager damage = raycastHit4.rigidbody.GetComponentInChildren <CyclopsExternalDamageManager>(); if (damage == null) { Log.Print("CyclopsExternalDamageManager not found"); return; } CyclopsDamagePoint[] damagePoints = raycastHit4.rigidbody.gameObject.GetComponentsInChildren <CyclopsDamagePoint>(); foreach (var dp in damagePoints) { dp.gameObject.GetComponentInChildren <LiveMixin>().PrintAllLiveMixinDetails(); Log.Print(" "); } } } } if (GUILayout.Button("CyclopsDestructionevent information.")) { Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray4, out RaycastHit raycastHit4)) { if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops")) { CyclopsDestructionEvent dm = raycastHit4.rigidbody.GetComponentInChildren <CyclopsDestructionEvent>(); if (dm == null) { Log.Print("Cyclop's CyclopsDestructionEvent not found."); return; } Utilities.Log.Print("explodeSFX: " + dm.fxControl); } } } if (GUILayout.Button("Cyclops PingInstance information.")) { Ray ray4 = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray4, out RaycastHit raycastHit4)) { if (raycastHit4.rigidbody.gameObject.name.ToLower().Contains("cyclops")) { PingInstance pi = raycastHit4.rigidbody.GetComponentInChildren <PingInstance>(); if (pi == null) { Log.Print("Cyclop's PingInstance not found."); return; } Log.Print("colorIndex: " + pi.colorIndex); Log.Print("currentVersion: " + pi.currentVersion); Log.Print("displayPingInManager: " + pi.displayPingInManager); Log.Print("maxDist: " + pi.maxDist); Log.Print("minDist: " + pi.minDist); Log.Print("origin: " + pi.origin); Log.Print("pingType: " + pi.pingType); Log.Print("visible: " + pi.visible); } } } }
/// <summary> /// Add/remove <see cref="CyclopsDamagePoint"/>s until it matches the <paramref name="damagePointIndexes"/> array passed. Can trigger <see cref="CyclopsDamagePointRepaired"/> packets /// </summary> private void SetActiveDamagePoints(SubRoot cyclops, int[] damagePointIndexes) { CyclopsExternalDamageManager damageManager = cyclops.gameObject.RequireComponentInChildren <CyclopsExternalDamageManager>(); List <CyclopsDamagePoint> unusedDamagePoints = (List <CyclopsDamagePoint>)damageManager.ReflectionGet("unusedDamagePoints"); // CyclopsExternalDamageManager.damagePoints is an unchanged list. It will never have items added/removed from it. Since packet.DamagePointIndexes is also an array // generated in an ordered manner, we can match them without worrying about unordered items. if (damagePointIndexes != null && damagePointIndexes.Length > 0) { int packetDamagePointsIndex = 0; for (int damagePointsIndex = 0; damagePointsIndex < damageManager.damagePoints.Length; damagePointsIndex++) { // Loop over all of the packet.DamagePointIndexes as long as there's more to match if (packetDamagePointsIndex < damagePointIndexes.Length && damagePointIndexes[packetDamagePointsIndex] == damagePointsIndex) { if (!damageManager.damagePoints[damagePointsIndex].gameObject.activeSelf) { // Copied from CyclopsExternalDamageManager.CreatePoint(), except without the random index pick. damageManager.damagePoints[damagePointsIndex].gameObject.SetActive(true); damageManager.damagePoints[damagePointsIndex].RestoreHealth(); GameObject prefabGo = damageManager.fxPrefabs[UnityEngine.Random.Range(0, damageManager.fxPrefabs.Length - 1)]; damageManager.damagePoints[damagePointsIndex].SpawnFx(prefabGo); unusedDamagePoints.Remove(damageManager.damagePoints[damagePointsIndex]); } packetDamagePointsIndex++; } else { // If it's active, but not in the list, it must have been repaired. if (damageManager.damagePoints[damagePointsIndex].gameObject.activeSelf) { RepairDamagePoint(cyclops, damagePointsIndex, 999); } } } // Looks like the list came in unordered. I've uttered "That shouldn't happen" enough to do sanity checks for what should be impossible. if (packetDamagePointsIndex < damagePointIndexes.Length) { Log.Error("[CyclopsDamageProcessor packet.DamagePointGuids did not fully iterate! Guid: " + damagePointIndexes[packetDamagePointsIndex].ToString() + " had no matching Guid in damageManager.damagePoints, or the order is incorrect!]"); } } else { // None should be active. for (int i = 0; i < damageManager.damagePoints.Length; i++) { if (damageManager.damagePoints[i].gameObject.activeSelf) { RepairDamagePoint(cyclops, i, 999); } } } // unusedDamagePoints is checked against damagePoints to determine if there's enough damage points. Failing to set the new list // of unusedDamagePoints will cause random DamagePoints to appear. damageManager.ReflectionSet("unusedDamagePoints", unusedDamagePoints); // Visual update only to show the water leaking through the window and various hull points based on missing health. damageManager.ReflectionCall("ToggleLeakPointsBasedOnDamage", false, false, null); }