public static IEnumerator CleanCoroutine(DeadBody body) { KillButtonTarget.SetTarget(DestroyableSingleton <HudManager> .Instance.KillButton, null); PerformKillButton.LastCleaned = DateTime.UtcNow; var renderer = body.GetComponent <SpriteRenderer>(); var backColour = renderer.material.GetColor(BackColor); var bodyColour = renderer.material.GetColor(BodyColor); var newColour = new Color(1f, 1f, 1f, 0f); for (var i = 0; i < 60; i++) { if (body == null) { yield break; } renderer.color = Color.Lerp(backColour, newColour, i / 60f); renderer.color = Color.Lerp(bodyColour, newColour, i / 60f); yield return(null); } UnityEngine.Object.Destroy(body.gameObject); }
public static void Postfix(PlayerControl __instance) { if (PlayerControl.AllPlayerControls.Count <= 1) { return; } if (PlayerControl.LocalPlayer == null) { return; } if (PlayerControl.LocalPlayer.Data == null) { return; } if (!__instance.AmOwner) { return; } if (!PlayerControl.LocalPlayer.isJanitor()) { return; } var data = __instance.Data; var isDead = data.IsDead; var truePosition = __instance.GetTruePosition(); var maxDistance = GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance]; var flag = (PlayerControl.GameOptions.GhostsDoTasks || !data.IsDead) && (!AmongUsClient.Instance || !AmongUsClient.Instance.IsGameOver) && __instance.CanMove; var allocs = Physics2D.OverlapCircleAll(truePosition, maxDistance, Constants.PlayersOnlyMask); var killButton = DestroyableSingleton <HudManager> .Instance.KillButton; closestBody = null; closestDistance = float.MaxValue; foreach (var collider2D in allocs) { if (!flag || isDead || collider2D.tag != "DeadBody") { continue; } var component = collider2D.GetComponent <DeadBody>(); if (!(Vector2.Distance(truePosition, component.TruePosition) <= maxDistance) || PhysicsHelpers.Method_2(truePosition, component.TruePosition, Constants.ShipAndObjectsMask, false)) { continue; } var distance = Vector2.Distance(truePosition, component.TruePosition); if (!(distance < closestDistance)) { continue; } closestBody = component; closestDistance = distance; } KillButtonTarget.SetTarget(killButton, closestBody); if (isDead) { killButton.gameObject.SetActive(false); killButton.isActive = false; } else { killButton.gameObject.SetActive(true); killButton.isActive = true; killButton.SetCoolDown(PerformKillButton.JanitorTimer(), CustomGameOptions.JanitorCleanCd); } }