Shorten Method

This commit is contained in:
Gurge44 committed 2023-12-02 13:57:04 +01:00
1 parent f0feccb0c6
commit bfa7d2f760
26 files changed
+48 -53

No files matched your search

+2 -2
View File
@@ -389,8 +389,8 @@ internal static class FFAManager
pc.RPCPlayCustomSound("Teleport");
var originPs = target.GetTruePosition();
target.TP(pc.GetTruePosition());
var originPs = target.Pos();
target.TP(pc.Pos());
pc.TP(originPs);
target.Notify(Utils.ColorString(new Color32(0, 255, 165, byte.MaxValue), string.Format(GetString("FFA-Event-RandomTP"), pc.GetRealName())));
+2 -2
View File
@@ -344,7 +344,7 @@ internal static class SoloKombatManager
{
if (pc.inVent && KB_BootVentWhenDead.GetBool()) pc.MyPhysics.RpcExitVent(2);
var pos = Pelican.GetBlackRoomPS();
var dis = Vector2.Distance(pos, pc.GetTruePosition());
var dis = Vector2.Distance(pos, pc.Pos());
if (dis > 1f) pc.TP(pos);
}
@@ -371,7 +371,7 @@ internal static class SoloKombatManager
if (pc.SoloAlive() && !pc.inVent)
{
var pos = Pelican.GetBlackRoomPS();
var dis = Vector2.Distance(pos, pc.GetTruePosition());
var dis = Vector2.Distance(pos, pc.Pos());
if (dis < 1.1f) PlayerRandomSpwan(pc);
}
// 复活倒计时
+1 -1
View File
@@ -54,7 +54,7 @@ class DisableDevice
if (pc.IsModClient()) continue;
bool doComms = false;
Vector2 PlayerPos = pc.GetTruePosition();
Vector2 PlayerPos = pc.Pos();
bool ignore = (Options.DisableDevicesIgnoreImpostors.GetBool() && pc.Is(CustomRoleTypes.Impostor)) ||
(Options.DisableDevicesIgnoreNeutrals.GetBool() && pc.Is(CustomRoleTypes.Neutral)) ||
(Options.DisableDevicesIgnoreCrewmates.GetBool() && pc.Is(CustomRoleTypes.Crewmate)) ||
+2
View File
@@ -596,6 +596,7 @@ static class ExtendedPlayerControl
CustomRoles.Consort => pc.IsAlive(),
CustomRoles.Duellist => pc.IsAlive(),
CustomRoles.YinYanger => pc.IsAlive(),
CustomRoles.Librarian => pc.IsAlive() && Librarian.CanUseKillButton(pc),
CustomRoles.Cantankerous => pc.IsAlive() && Cantankerous.CanUseKillButton(pc.PlayerId),
CustomRoles.Inhibitor => !Utils.IsActive(SystemTypes.Electrical) && !Utils.IsActive(SystemTypes.Laboratory) && !Utils.IsActive(SystemTypes.Comms) && !Utils.IsActive(SystemTypes.LifeSupp) && !Utils.IsActive(SystemTypes.Reactor),
CustomRoles.Saboteur => Utils.IsActive(SystemTypes.Electrical) || Utils.IsActive(SystemTypes.Laboratory) || Utils.IsActive(SystemTypes.Comms) || Utils.IsActive(SystemTypes.LifeSupp) || Utils.IsActive(SystemTypes.Reactor),
@@ -844,6 +845,7 @@ static class ExtendedPlayerControl
_ => pc.Is(CustomRoleTypes.Impostor),
};
}
public static Vector2 Pos(this PlayerControl pc) => pc.Pos();
public static bool IsDousedPlayer(this PlayerControl arsonist, PlayerControl target)
{
if (arsonist == null || target == null || Main.isDoused == null) return false;
+3 -3
View File
@@ -365,8 +365,8 @@ public class TaskState
var tar1 = AllAlivePlayer[rd.Next(0, AllAlivePlayer.Count)];
AllAlivePlayer.Remove(tar1);
var tar2 = AllAlivePlayer[rd.Next(0, AllAlivePlayer.Count)];
var pos = tar1.GetTruePosition();
tar1.TP(tar2.GetTruePosition());
var pos = tar1.Pos();
tar1.TP(tar2.Pos());
tar2.TP(pos);
tar1.RPCPlayCustomSound("Teleport");
tar2.RPCPlayCustomSound("Teleport");
@@ -590,7 +590,7 @@ public class TaskState
}
else
{
list = [.. list.OrderBy(x => Vector2.Distance(player.GetTruePosition(), x.GetTruePosition()))];
list = [.. list.OrderBy(x => Vector2.Distance(player.Pos(), x.Pos()))];
var target = list[0];
if (!target.Is(CustomRoles.Pestilence))
{
+1 -1
View File
@@ -257,7 +257,7 @@ internal class ControllerManagerUpdatePatch
//获取现在的坐标
if (Input.GetKeyDown(KeyCode.I))
Logger.Info(PlayerControl.LocalPlayer.GetTruePosition().ToString(), "GetLocalPlayerPos");
Logger.Info(PlayerControl.LocalPlayer.Pos().ToString(), "GetLocalPlayerPos");
//マスゲーム用コード
if (Input.GetKeyDown(KeyCode.C))
+2 -2
View File
@@ -268,7 +268,7 @@ class ExternalRpcPetPatch
}
else
{
Main.TimeMasterBackTrack.Add(player.PlayerId, player.GetTruePosition());
Main.TimeMasterBackTrack.Add(player.PlayerId, player.Pos());
}
}
}
@@ -370,7 +370,7 @@ class ExternalRpcPetPatch
}
else
{
Main.EscapeeLocation.Add(pc.PlayerId, pc.GetTruePosition());
Main.EscapeeLocation.Add(pc.PlayerId, pc.Pos());
}
Main.EscapeeCD.TryAdd(pc.PlayerId, Utils.GetTimeStamp());
break;
+7 -7
View File
@@ -695,7 +695,7 @@ class CheckMurderPatch
_ = new LateTask(() =>
{
if (!Main.OverDeadPlayerList.Contains(target.PlayerId)) Main.OverDeadPlayerList.Add(target.PlayerId);
var ops = target.GetTruePosition();
var ops = target.Pos();
var rd = IRandom.Instance;
for (int i = 0; i < 20; i++)
{
@@ -954,7 +954,7 @@ class CheckMurderPatch
if (Main.AllAlivePlayerControls.Any(x =>
x.PlayerId != killer.PlayerId &&
x.PlayerId != target.PlayerId &&
Vector2.Distance(x.GetTruePosition(), target.GetTruePosition()) < 2f)) return false;
Vector2.Distance(x.Pos(), target.Pos()) < 2f)) return false;
break;
case CustomRoles.Gamer:
if (!Gamer.CheckMurder(killer, target))
@@ -1407,7 +1407,7 @@ class ShapeshiftPatch
}
else
{
Main.EscapeeLocation.Add(shapeshifter.PlayerId, shapeshifter.GetTruePosition());
Main.EscapeeLocation.Add(shapeshifter.PlayerId, shapeshifter.Pos());
}
}
isSSneeded = false;
@@ -1517,8 +1517,8 @@ class ShapeshiftPatch
{
if (!(!GameStates.IsInTask || !shapeshifter.IsAlive() || !target.IsAlive() || shapeshifter.inVent || target.inVent))
{
var originPs = target.GetTruePosition();
TP(target.NetTransform, shapeshifter.GetTruePosition());
var originPs = target.Pos();
TP(target.NetTransform, shapeshifter.Pos());
TP(shapeshifter.NetTransform, originPs);
}
}, 1.5f, "ImperiusCurse TP");
@@ -3133,7 +3133,7 @@ class EnterVentPatch
Main.LastEnteredVent.Remove(pc.PlayerId);
Main.LastEnteredVent.Add(pc.PlayerId, __instance);
Main.LastEnteredVentLocation.Remove(pc.PlayerId);
Main.LastEnteredVentLocation.Add(pc.PlayerId, pc.GetTruePosition());
Main.LastEnteredVentLocation.Add(pc.PlayerId, pc.Pos());
if (pc.Is(CustomRoles.Unlucky))
{
@@ -3324,7 +3324,7 @@ class EnterVentPatch
}
else
{
Main.TimeMasterBackTrack.Add(player.PlayerId, player.GetTruePosition());
Main.TimeMasterBackTrack.Add(player.PlayerId, player.Pos());
}
}
}
+1 -1
View File
@@ -73,7 +73,7 @@ class CanUseVentPatch
}
if (canUse)
{
Vector2 truePosition = pc.Object.GetTruePosition();
Vector2 truePosition = pc.Object.Pos();
Vector3 position = __instance.transform.position;
num = Vector2.Distance(truePosition, position);
canUse &= num <= usableDistance && !PhysicsHelpers.AnythingBetween(truePosition, position, Constants.ShipOnlyMask, false);
+1 -1
View File
@@ -161,7 +161,7 @@ namespace TOHE.Roles.Crewmate
var tar1 = AllAlivePlayer[player.PlayerId];
AllAlivePlayer.Remove(tar1);
var tar2 = AllAlivePlayer[rd.Next(0, AllAlivePlayer.Count)];
tar1.TP(tar2.GetTruePosition());
tar1.TP(tar2.Pos());
tar1.RPCPlayCustomSound("Teleport");
}, !isPet ? 2f : 0.1f);
break;
+1 -1
View File
@@ -163,7 +163,7 @@ namespace TOHE.Roles.Crewmate
PlayerControl target = GetPlayerById(CurrentTarget.ID);
if (target == null) return;
if (UnityEngine.Vector2.Distance(target.GetTruePosition(), pc.GetTruePosition()) < 2f)
if (UnityEngine.Vector2.Distance(target.Pos(), pc.Pos()) < 2f)
{
CurrentTarget.ID = byte.MaxValue;
NotifyRoles(SpecifySeer: pc, SpecifyTarget: target);
+1 -1
View File
@@ -6,6 +6,6 @@ namespace TOHE.Roles.Crewmate
{
public static void SetupCustomOption() => Options.SetupRoleOptions(642620, TabGroup.CrewmateRoles, CustomRoles.Autocrat);
public static void OnTaskComplete(PlayerControl pc) => Main.AllAlivePlayerControls.OrderBy(x => UnityEngine.Vector2.Distance(x.GetTruePosition(), pc.GetTruePosition())).FirstOrDefault(x => x.PlayerId != pc.PlayerId).TP(pc.GetTruePosition());
public static void OnTaskComplete(PlayerControl pc) => Main.AllAlivePlayerControls.OrderBy(x => UnityEngine.Vector2.Distance(x.Pos(), pc.Pos())).FirstOrDefault(x => x.PlayerId != pc.PlayerId).TP(pc.Pos());
}
}
+2 -2
View File
@@ -212,7 +212,7 @@ namespace TOHE.Roles.Crewmate
{
foreach (var trigger in triggers.Value.ToArray()) // Check for all traps of the current Druid - Most likely 0-2 loops
{
if (Vector2.Distance(trigger.Key, pc.GetTruePosition()) <= 2f)
if (Vector2.Distance(trigger.Key, pc.Pos()) <= 2f)
{
GetPlayerById(triggers.Key).Notify(string.Format(GetString("DruidTriggerTriggered"), GetFormattedRoomName(trigger.Value), GetFormattedVectorText(trigger.Key)));
Triggers[triggers.Key].Remove(trigger.Key);
@@ -228,7 +228,7 @@ namespace TOHE.Roles.Crewmate
{
PlainShipRoom room = pc.GetPlainShipRoom();
string roomName = room == null ? "Outside" : room.name;
Vector2 pos = pc.GetTruePosition();
Vector2 pos = pc.Pos();
return (pos, roomName);
}
+1 -1
View File
@@ -53,7 +53,7 @@ internal class Monitor
if (Pelican.IsEaten(pc.PlayerId) || pc.inVent) continue;
try
{
Vector2 PlayerPos = pc.GetTruePosition();
Vector2 PlayerPos = pc.Pos();
switch (Main.NormalOptions.MapId)
{
+2 -2
View File
@@ -56,13 +56,13 @@ public static class Mortician
}
public static void OnPlayerDead(PlayerControl target)
{
var pos = target.GetTruePosition();
var pos = target.Pos();
float minDis = float.MaxValue;
string minName = string.Empty;
foreach (PlayerControl pc in Main.AllAlivePlayerControls)
{
if (pc.PlayerId == target.PlayerId) continue;
var dis = Vector2.Distance(pc.GetTruePosition(), pos);
var dis = Vector2.Distance(pc.Pos(), pos);
if (dis < minDis && dis < 1.5f)
{
minDis = dis;
+1 -1
View File
@@ -82,7 +82,7 @@ namespace TOHE.Roles.Crewmate
{
if (GameStates.IsInTask)
{
TP(pc.NetTransform, GetPlayerById(Target).GetTruePosition());
TP(pc.NetTransform, GetPlayerById(Target).Pos());
}
}, isPet ? 0.1f : 2f, "Tether TP");
}
+2 -2
View File
@@ -79,13 +79,13 @@ public static class Tracefinder
public static void OnPlayerDead(PlayerControl target)
{
var pos = target.GetTruePosition();
var pos = target.Pos();
float minDis = float.MaxValue;
string minName = string.Empty;
foreach (PlayerControl pc in Main.AllAlivePlayerControls)
{
if (pc.PlayerId == target.PlayerId) continue;
var dis = Vector2.Distance(pc.GetTruePosition(), pos);
var dis = Vector2.Distance(pc.Pos(), pos);
if (dis < minDis && dis < 1.5f)
{
minDis = dis;
+1 -1
View File
@@ -6,6 +6,6 @@ namespace TOHE.Roles.Crewmate
{
public static void SetupCustomOption() => Options.SetupRoleOptions(642610, TabGroup.CrewmateRoles, CustomRoles.Transmitter);
public static void OnTaskComplete(PlayerControl pc) => pc.TP(Main.AllAlivePlayerControls.OrderBy(x => UnityEngine.Vector2.Distance(x.GetTruePosition(), pc.GetTruePosition())).FirstOrDefault(x => x.PlayerId != pc.PlayerId).GetTruePosition());
public static void OnTaskComplete(PlayerControl pc) => pc.TP(Main.AllAlivePlayerControls.OrderBy(x => UnityEngine.Vector2.Distance(x.Pos(), pc.Pos())).FirstOrDefault(x => x.PlayerId != pc.PlayerId).Pos());
}
}
+1 -1
View File
@@ -51,7 +51,7 @@ internal class AntiAdminer
if (Pelican.IsEaten(pc.PlayerId) || pc.inVent || pc.GetCustomRole().IsImpostor()) continue;
try
{
Vector2 PlayerPos = pc.GetTruePosition();
Vector2 PlayerPos = pc.Pos();
switch (Main.NormalOptions.MapId)
{
+1 -1
View File
@@ -103,7 +103,7 @@ internal static class Assassin
{
if (!(target == null || !target.IsAlive() || Pelican.IsEaten(target.PlayerId) || target.inVent || !GameStates.IsInTask))
{
pc.TP(target.GetTruePosition());
pc.TP(target.Pos());
pc.ResetKillCooldown();
pc.SyncSettings();
pc.SetKillCooldown(DefaultKillCooldown);
+1 -1
View File
@@ -130,7 +130,7 @@ namespace TOHE.Roles.Impostor
if (GameStates.IsInTask && killer.IsAlive())
{
var list = Main.AllAlivePlayerControls.Where(a => !Pelican.IsEaten(a.PlayerId) && !a.inVent && a.PlayerId != killer.PlayerId).ToArray();
TP(killer.NetTransform, list[rd.Next(0, list.Length)].GetTruePosition());
TP(killer.NetTransform, list[rd.Next(0, list.Length)].Pos());
}
}, TPDelay.GetInt(), "Gambler Swap");
break;
+5 -12
View File
@@ -1,14 +1,9 @@
using System;
using Hazel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static TOHE.Options;
using static TOHE.Utils;
using static TOHE.Translator;
using Hazel;
using TOHE.Roles.Crewmate;
using Il2CppMono.Security.Authenticode;
using static TOHE.Utils;
namespace TOHE.Roles.Impostor
{
@@ -62,7 +57,7 @@ namespace TOHE.Roles.Impostor
public static bool IsEnable => playerIdList.Count > 0;
public static bool CanUseKillButton(PlayerControl pc) => !pc.shapeshifting || CanKillWhileShifted.GetBool();
public static bool CanUseKillButton(PlayerControl pc) => !pc.shapeshifting || CanKillWhileShifted.GetBool();
public static void ApplyGameOptions()
{
@@ -119,7 +114,6 @@ namespace TOHE.Roles.Impostor
if (!IsEnable) return true;
if (reporter == null) return true;
bool isSilence = false;
PlayerControl librarian = null;
float silenceRadius = Radius.GetFloat();
@@ -127,14 +121,13 @@ namespace TOHE.Roles.Impostor
{
if (!isInSilencingMode.TryGetValue(id, out var x) || !x.SILENCING) continue;
var pc = GetPlayerById(id);
if (UnityEngine.Vector2.Distance(pc.GetTruePosition(), reporter.GetTruePosition()) <= silenceRadius)
if (UnityEngine.Vector2.Distance(pc.Pos(), reporter.Pos()) <= silenceRadius)
{
isSilence = true;
librarian = pc;
}
}
if (!isSilence || librarian == null) return true;
if (librarian == null) return true;
if (librarian.RpcCheckAndMurder(reporter))
{
+2 -2
View File
@@ -74,8 +74,8 @@ namespace TOHE.Roles.Impostor
pc.RPCPlayCustomSound("Teleport");
var originPs = target.GetTruePosition();
TP(target.NetTransform, pc.GetTruePosition());
var originPs = target.Pos();
TP(target.NetTransform, pc.Pos());
TP(pc.NetTransform, originPs);
target.Notify(ColorString(GetRoleColor(CustomRoles.Twister), string.Format(GetString("TeleportedByTwister"), pc.GetRealName())));
+1 -1
View File
@@ -116,7 +116,7 @@ namespace TOHE.Roles.Impostor
if (!pc1.IsAlive() || !pc2.IsAlive() || !yy.IsAlive()) return;
if (Vector2.Distance(pc1.GetTruePosition(), pc2.GetTruePosition()) <= 2f)
if (Vector2.Distance(pc1.Pos(), pc2.Pos()) <= 2f)
{
if (!yy.RpcCheckAndMurder(pc1, true)
|| !yy.RpcCheckAndMurder(pc2, true)) return;
+2 -2
View File
@@ -160,7 +160,7 @@ public static class Pelican
var player = Utils.GetPlayerById(pc);
if (player == null || target == null)
continue;
target.TP(player.GetTruePosition());
target.TP(player.Pos());
Main.AllPlayerSpeed[tar] = Main.AllPlayerSpeed[tar] - 0.5f + originalSpeed[tar];
ReportDeadBodyPatch.CanReport[tar] = true;
target.MarkDirtySettings();
@@ -195,7 +195,7 @@ public static class Pelican
if (target == null)
continue;
var pos = GetBlackRoomPS();
var dis = Vector2.Distance(pos, target.GetTruePosition());
var dis = Vector2.Distance(pos, target.Pos());
if (dis < 1f)
continue;
target.TP(pos);
+2 -2
View File
@@ -124,12 +124,12 @@ public static class Vulture
{
if (!ArrowsPointingToDeadBody.GetBool()) return;
var pos = target.GetTruePosition();
var pos = target.Pos();
float minDis = float.MaxValue;
foreach (PlayerControl pc in Main.AllAlivePlayerControls)
{
if (pc.PlayerId == target.PlayerId) continue;
var dis = Vector2.Distance(pc.GetTruePosition(), pos);
var dis = Vector2.Distance(pc.Pos(), pos);
if (dis < minDis && dis < 1.5f)
{
minDis = dis;