public static bool Prefix(MapCountOverlay __instance) { var localPlayer = PlayerControl.LocalPlayer; if (!localPlayer.Is(RoleEnum.Spy)) { return(true); } __instance.timer += Time.deltaTime; if (__instance.timer < 0.1f) { return(false); } __instance.timer = 0f; var sabotaged = PlayerTask.PlayerHasTaskOfType <IHudOverrideTask>(localPlayer); if (sabotaged != __instance.isSab) { SetSabotaged(__instance, sabotaged); } if (!sabotaged) { UpdateBlips(__instance); } return(false); }
public static bool Prefix(SurveillanceMinigame __instance) { // Update normal and securityGuard cameras timer += Time.deltaTime; int numberOfPages = Mathf.CeilToInt(ShipStatus.Instance.AllCameras.Length / 4f); bool update = false; if (timer > 3f || Input.GetKeyDown(KeyCode.RightArrow)) { update = true; timer = 0f; page = (page + 1) % numberOfPages; } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { page = (page + numberOfPages - 1) % numberOfPages; update = true; timer = 0f; } if ((__instance.isStatic || update) && !PlayerTask.PlayerHasTaskOfType <IHudOverrideTask>(PlayerControl.LocalPlayer)) { __instance.isStatic = false; for (int i = 0; i < __instance.ViewPorts.Length; i++) { __instance.ViewPorts[i].sharedMaterial = __instance.DefaultMaterial; __instance.SabText[i].gameObject.SetActive(false); if (page * 4 + i < __instance.textures.Length) { __instance.ViewPorts[i].material.SetTexture("_MainTex", __instance.textures[page * 4 + i]); } else { __instance.ViewPorts[i].sharedMaterial = __instance.StaticMaterial; } } } else if (!__instance.isStatic && PlayerTask.PlayerHasTaskOfType <HudOverrideTask>(PlayerControl.LocalPlayer)) { __instance.isStatic = true; for (int j = 0; j < __instance.ViewPorts.Length; j++) { __instance.ViewPorts[j].sharedMaterial = __instance.StaticMaterial; __instance.SabText[j].gameObject.SetActive(true); } } return(false); }
public static void Postfix(VitalsMinigame __instance) { if (PlayerTask.PlayerHasTaskOfType <HudOverrideTask>(PlayerControl.LocalPlayer)) { return; } //Allow to switch pages if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.mouseScrollDelta.y > 0f) { currentPage = Mathf.Clamp(currentPage - 1, 0, maxPages - 1); } else if (Input.GetKeyDown(KeyCode.RightArrow) || Input.mouseScrollDelta.y < 0f) { currentPage = Mathf.Clamp(currentPage + 1, 0, maxPages - 1); } //Place dead players at the beginning, disconnected at the end VitalsPanel[] vitalsPanels = __instance.vitals.OrderBy(x => (x.IsDead ? 0 : 1) + (x.IsDiscon ? 2 : 0)).ToArray();//VitalsPanel[] //Sorted by: Dead -> Alive -> dead&disc -> alive&disc int i = 0; //Show/hide/move each panel foreach (VitalsPanel panel in vitalsPanels) { if (i >= currentPage * maxPerPage && i < (currentPage + 1) * maxPerPage) { panel.gameObject.SetActive(true); int relativeIndex = i % maxPerPage; // /!\ -2.7f hardcoded, can we get it the same way as MeetingHud.VoteOrigin ? var transform = panel.transform; var localPosition = transform.localPosition; localPosition = new Vector3(-2.7f + 0.6f * relativeIndex, localPosition.y, localPosition.z); transform.localPosition = localPosition; } else { panel.gameObject.SetActive(false); } i++; } }
public static void Postfix(VitalsMinigame __instance) { if (PlayerTask.PlayerHasTaskOfType <HudOverrideTask>(PlayerControl.LocalPlayer)) { return; } //Allow to switch pages if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.mouseScrollDelta.y > 0f) { currentPage = Mathf.Clamp(currentPage - 1, 0, maxPages - 1); } else if (Input.GetKeyDown(KeyCode.RightArrow) || Input.mouseScrollDelta.y < 0f) { currentPage = Mathf.Clamp(currentPage + 1, 0, maxPages - 1); } var i = 0; //Show/hide/move each panel foreach (var panel in __instance.vitals) { if (i >= currentPage * maxPerPage && i < (currentPage + 1) * maxPerPage) { panel.gameObject.SetActive(true); var relativeIndex = i % maxPerPage; panel.transform.localPosition = new Vector3( __instance.XStart + __instance.XOffset * (relativeIndex % 3), __instance.YStart + __instance.YOffset * (relativeIndex / 3), -1f ); } else { panel.gameObject.SetActive(false); } i++; } }
public static bool Prefix(MapCountOverlay __instance) { if (!PlayerControl.LocalPlayer.Is(RoleEnum.Spy)) { return(true); } __instance.timer += Time.deltaTime; if (__instance.timer < 0.1f) { return(false); } __instance.timer = 0f; AllRooms = new Dictionary <SystemTypes, List <int> >(); var task = PlayerControl.LocalPlayer.myTasks.ToArray() .FirstOrDefault(x => x.TaskType == TaskTypes.FixComms); var flag = task != null; if (!__instance.isSab && flag) { __instance.isSab = true; __instance.BackgroundColor.SetColor(Palette.DisabledGrey); __instance.SabotageText.gameObject.SetActive(true); return(false); } if (__instance.isSab && !flag) { __instance.isSab = false; __instance.BackgroundColor.SetColor(Color.green); __instance.SabotageText.gameObject.SetActive(false); } for (int i = 0; i < __instance.CountAreas.Length; i++) { CounterArea counterArea = __instance.CountAreas[i]; var colourList = new List <int>(); AllRooms.Add(counterArea.RoomType, colourList); if (!PlayerTask.PlayerHasTaskOfType <HudOverrideTask>(PlayerControl.LocalPlayer)) { PlainShipRoom plainShipRoom; if (ShipStatus.Instance.FastRooms.ContainsKey(counterArea.RoomType)) { plainShipRoom = ShipStatus.Instance.FastRooms[counterArea.RoomType]; if (!plainShipRoom.roomArea) { continue; } int num = plainShipRoom.roomArea.OverlapCollider(__instance.filter, __instance.buffer); int num2 = num; for (int j = 0; j < num; j++) { Collider2D collider2D = __instance.buffer[j]; if (!(collider2D.tag == "DeadBody")) { PlayerControl component = collider2D.GetComponent <PlayerControl>(); if (!component || component.Data == null || component.Data.Disconnected || component.Data.IsDead) { num2--; } else { colourList.Add(component.Data.ColorId); } } } counterArea.UpdateCount(num2); } else { Debug.LogWarning("Couldn't find counter for:" + counterArea.RoomType); } } else { counterArea.UpdateCount(0); } } return(false); }
public static bool Prefix(SurveillanceMinigame __instance) { cameraTimer += Time.deltaTime; if (cameraTimer > 0.1f) { UseCameraTime(); } if (MapOptions.restrictDevices > 0 && MapOptions.restrictCameras) { if (TimeRemaining == null) { TimeRemaining = UnityEngine.Object.Instantiate(HudManager.Instance.TaskText, __instance.transform); TimeRemaining.alignment = TMPro.TextAlignmentOptions.Center; TimeRemaining.transform.position = Vector3.zero; TimeRemaining.transform.localPosition = new Vector3(0.0f, -1.7f); TimeRemaining.transform.localScale *= 1.8f; TimeRemaining.color = Palette.White; } if (MapOptions.restrictCamerasTime <= 0f) { __instance.Close(); return(false); } string timeString = TimeSpan.FromSeconds(MapOptions.restrictCamerasTime).ToString(@"mm\:ss\.ff"); TimeRemaining.text = String.Format(ModTranslation.getString("timeRemaining"), timeString); TimeRemaining.gameObject.SetActive(true); } // Update normal and securityGuard cameras timer += Time.deltaTime; int numberOfPages = Mathf.CeilToInt(ShipStatus.Instance.AllCameras.Length / 4f); bool update = false; if (timer > 3f || Input.GetKeyDown(KeyCode.RightArrow)) { update = true; timer = 0f; page = (page + 1) % numberOfPages; } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { page = (page + numberOfPages - 1) % numberOfPages; update = true; timer = 0f; } if ((__instance.isStatic || update) && !PlayerTask.PlayerHasTaskOfType <IHudOverrideTask>(PlayerControl.LocalPlayer)) { __instance.isStatic = false; for (int i = 0; i < __instance.ViewPorts.Length; i++) { __instance.ViewPorts[i].sharedMaterial = __instance.DefaultMaterial; __instance.SabText[i].gameObject.SetActive(false); if (page * 4 + i < __instance.textures.Length) { __instance.ViewPorts[i].material.SetTexture("_MainTex", __instance.textures[page * 4 + i]); } else { __instance.ViewPorts[i].sharedMaterial = __instance.StaticMaterial; } } } else if (!__instance.isStatic && PlayerTask.PlayerHasTaskOfType <HudOverrideTask>(PlayerControl.LocalPlayer)) { __instance.isStatic = true; for (int j = 0; j < __instance.ViewPorts.Length; j++) { __instance.ViewPorts[j].sharedMaterial = __instance.StaticMaterial; __instance.SabText[j].gameObject.SetActive(true); } } return(false); }