mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
some fixes
This commit is contained in:
1 parent
0c68555256
commit
66ecb57d97
9 files changed
+94
-126
No files matched your search
+19
-56
@@ -11,7 +11,6 @@ public static class DoorsReset
|
||||
|
||||
private static bool IsEnabled;
|
||||
private static ResetMode Mode;
|
||||
private static DoorsSystemType DoorsSystem => ShipStatus.Instance.Systems.TryGetValue(SystemTypes.Doors, out ISystemType system) ? system.CastFast<DoorsSystemType>() : null;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
@@ -30,71 +29,35 @@ public static class DoorsReset
|
||||
/// <summary>Reset door status according to settings</summary>
|
||||
public static void ResetDoors()
|
||||
{
|
||||
if (!IsEnabled || DoorsSystem == null) return;
|
||||
if (!IsEnabled) return;
|
||||
|
||||
Logger.Info("Reset Completed", "DoorsReset");
|
||||
|
||||
switch (Mode)
|
||||
{
|
||||
case ResetMode.AllOpen:
|
||||
OpenAllDoors();
|
||||
break;
|
||||
case ResetMode.AllClosed:
|
||||
CloseAllDoors();
|
||||
break;
|
||||
case ResetMode.RandomByDoor:
|
||||
OpenOrCloseAllDoorsRandomly();
|
||||
break;
|
||||
default:
|
||||
Logger.Warn($"Invalid Reset Doors Mode: {Mode}", "DoorsReset");
|
||||
break;
|
||||
}
|
||||
SetDoors(Mode);
|
||||
}
|
||||
|
||||
/// <summary>Open all doors on the map</summary>
|
||||
public static void OpenAllDoors()
|
||||
public static void SetDoors(ResetMode resetMode)
|
||||
{
|
||||
if (!ShipStatus.Instance) return;
|
||||
if (!ShipStatus.Instance || !ShipStatus.Instance.Systems.TryGetValue(SystemTypes.Doors, out ISystemType system)) return;
|
||||
|
||||
foreach (OpenableDoor door in ShipStatus.Instance.AllDoors)
|
||||
bool autoOpenDoors = system.TryCast(out AutoDoorsSystemType autoDoorsSystemType);
|
||||
|
||||
for (var index = 0; index < ShipStatus.Instance.AllDoors.Count; index++)
|
||||
{
|
||||
if (door == null) continue;
|
||||
SetDoorOpenState(door, true);
|
||||
OpenableDoor door = ShipStatus.Instance.AllDoors[index];
|
||||
if (!door) continue;
|
||||
bool open = resetMode switch
|
||||
{
|
||||
ResetMode.AllOpen => true,
|
||||
ResetMode.AllClosed => false,
|
||||
_ => IRandom.Instance.Next(2) > 0
|
||||
};
|
||||
SetDoorOpenState(door, open);
|
||||
if (autoOpenDoors) autoDoorsSystemType.dirtyBits |= (uint)(1 << index);
|
||||
}
|
||||
|
||||
DoorsSystemType doorsSystem = DoorsSystem;
|
||||
doorsSystem?.IsDirty = true;
|
||||
}
|
||||
|
||||
/// <summary>Close all doors on the map</summary>
|
||||
public static void CloseAllDoors()
|
||||
{
|
||||
if (!ShipStatus.Instance) return;
|
||||
|
||||
foreach (OpenableDoor door in ShipStatus.Instance.AllDoors)
|
||||
{
|
||||
if (door == null) continue;
|
||||
|
||||
SetDoorOpenState(door, false);
|
||||
}
|
||||
|
||||
DoorsSystemType doorsSystem = DoorsSystem;
|
||||
doorsSystem?.IsDirty = true;
|
||||
}
|
||||
|
||||
/// <summary>Randomly opens and closes all doors on the map</summary>
|
||||
public static void OpenOrCloseAllDoorsRandomly()
|
||||
{
|
||||
if (!ShipStatus.Instance) return;
|
||||
|
||||
foreach (OpenableDoor door in ShipStatus.Instance.AllDoors)
|
||||
{
|
||||
bool isOpen = IRandom.Instance.Next(2) > 0;
|
||||
SetDoorOpenState(door, isOpen);
|
||||
}
|
||||
|
||||
DoorsSystemType doorsSystem = DoorsSystem;
|
||||
doorsSystem?.IsDirty = true;
|
||||
if (autoOpenDoors || !system.TryCast(out DoorsSystemType doorsSystemType)) return;
|
||||
doorsSystemType.IsDirty = true;
|
||||
}
|
||||
|
||||
/// <summary>Sets the open/close status of the door. Do nothing for doors that cannot be closed by sabotage</summary>
|
||||
|
||||
@@ -1468,5 +1468,7 @@ internal static class IntroCutsceneDestroyPatch
|
||||
}, 4f, "Airship Spawn FailSafe");
|
||||
|
||||
MatchInfoHudButton.defaultDistanceFromEdge = MatchInfoHudButton.adjustedDistanceFromEdge;
|
||||
|
||||
ExtendedPlayerControl.NameWithRoleCache.Clear();
|
||||
}
|
||||
}
|
||||
@@ -425,28 +425,61 @@ public static class SabotageSystemTypeUpdateSystemPatch
|
||||
newReader.Recycle();
|
||||
}
|
||||
|
||||
if (SubmergedCompatibility.IsSubmerged()) return CheckSabotage(__instance, player, systemTypes);
|
||||
|
||||
if (Options.EnableCustomSabotages.GetBool())
|
||||
if (!SubmergedCompatibility.IsSubmerged() && Options.EnableCustomSabotages.GetBool() && Options.EnableGrabOxygenMaskCustomSabotage.GetBool() && systemTypes == SystemTypes.Comms)
|
||||
{
|
||||
if (Options.EnableGrabOxygenMaskCustomSabotage.GetBool() && systemTypes == SystemTypes.Comms)
|
||||
if (!SabotageDoubleTrigger.WaitingForDoubleTrigger)
|
||||
{
|
||||
if (!SabotageDoubleTrigger.WaitingForDoubleTrigger)
|
||||
SabotageDoubleTrigger.SetUp(player, () =>
|
||||
{
|
||||
SabotageDoubleTrigger.SetUp(player, () =>
|
||||
{
|
||||
new GrabOxygenMaskSabotage().Deteriorate();
|
||||
__instance.Timer = IsCooldownModificationEnabled ? ModifiedCooldownSec : 30f;
|
||||
__instance.IsDirty = true;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
SabotageDoubleTrigger.Reset();
|
||||
new GrabOxygenMaskSabotage().Deteriorate();
|
||||
__instance.Timer = IsCooldownModificationEnabled ? ModifiedCooldownSec : 30f;
|
||||
__instance.IsDirty = true;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
SabotageDoubleTrigger.Reset();
|
||||
}
|
||||
|
||||
return CheckSabotage(__instance, player, systemTypes);
|
||||
bool allowed = CheckSabotage(__instance, player, systemTypes);
|
||||
|
||||
if (allowed)
|
||||
{
|
||||
var pcs = Main.CachedAlivePlayerControls();
|
||||
|
||||
for (var index = 0; index < pcs.Count; index++)
|
||||
{
|
||||
PlayerControl pc = pcs[index];
|
||||
|
||||
try
|
||||
{
|
||||
switch (pc.GetCustomRole())
|
||||
{
|
||||
case CustomRoles.Evader:
|
||||
pc.RpcMakeInvisible();
|
||||
break;
|
||||
case CustomRoles.Sensor when pc.GetAbilityUseLimit() >= 1f:
|
||||
pc.RpcRemoveAbilityUse();
|
||||
TargetArrow.Add(pc.PlayerId, player.PlayerId);
|
||||
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
|
||||
LateTask.New(() =>
|
||||
{
|
||||
TargetArrow.Remove(pc.PlayerId, player.PlayerId);
|
||||
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
|
||||
}, Sensor.ArrowDuration.GetInt(), "Sensor Arrow");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e) { Utils.ThrowException(e); }
|
||||
}
|
||||
|
||||
if (QuizMaster.On) QuizMaster.Data.NumSabotages++;
|
||||
|
||||
if (Main.CurrentMap == MapNames.Skeld)
|
||||
LateTask.New(() => DoorsReset.SetDoors(DoorsReset.ResetMode.AllOpen), 1f, "Opening All Doors On Sabotage (Skeld)");
|
||||
}
|
||||
|
||||
return allowed;
|
||||
}
|
||||
|
||||
public static bool CheckSabotage(SabotageSystemType __instance, PlayerControl player, SystemTypes systemTypes)
|
||||
@@ -503,29 +536,6 @@ public static class SabotageSystemTypeUpdateSystemPatch
|
||||
allow = false;
|
||||
}
|
||||
|
||||
if (allow)
|
||||
{
|
||||
if (QuizMaster.On) QuizMaster.Data.NumSabotages++;
|
||||
|
||||
if (Main.CurrentMap == MapNames.Skeld)
|
||||
LateTask.New(DoorsReset.OpenAllDoors, 1f, "Opening All Doors On Sabotage (Skeld)");
|
||||
|
||||
foreach (PlayerControl pc in Main.CachedAlivePlayerControls())
|
||||
{
|
||||
if (pc.Is(CustomRoles.Sensor) && pc.GetAbilityUseLimit() >= 1f)
|
||||
{
|
||||
pc.RpcRemoveAbilityUse();
|
||||
TargetArrow.Add(pc.PlayerId, player.PlayerId);
|
||||
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
|
||||
LateTask.New(() =>
|
||||
{
|
||||
TargetArrow.Remove(pc.PlayerId, player.PlayerId);
|
||||
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
|
||||
}, Sensor.ArrowDuration.GetInt(), "Sensor Arrow");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allow;
|
||||
}
|
||||
|
||||
|
||||
+16
-26
@@ -182,22 +182,8 @@ internal static class UpdateSystemPatch
|
||||
}
|
||||
case SystemTypes.Sabotage when AmongUsClient.Instance.NetworkMode != NetworkModes.FreePlay:
|
||||
{
|
||||
bool allowed = SabotageSystemTypeUpdateSystemPatch.CheckSabotage(__instance.Systems[SystemTypes.Sabotage].CastFast<SabotageSystemType>(), player, systemType);
|
||||
|
||||
if (allowed)
|
||||
{
|
||||
List<PlayerControl> pcs = Main.CachedAlivePlayerControls();
|
||||
|
||||
for (var index = 0; index < pcs.Count; index++)
|
||||
{
|
||||
PlayerControl pc = pcs[index];
|
||||
|
||||
if (pc.Is(CustomRoles.Evader))
|
||||
pc.RpcMakeInvisible();
|
||||
}
|
||||
}
|
||||
|
||||
return allowed;
|
||||
var sabotageSystemType = SabotageSystemTypeUpdateSystemPatch.Instance ?? __instance.Systems[SystemTypes.Sabotage].CastFast<SabotageSystemType>();
|
||||
return SabotageSystemTypeUpdateSystemPatch.CheckSabotage(sabotageSystemType, player, systemType);
|
||||
}
|
||||
case SystemTypes.Security when amount == 1:
|
||||
{
|
||||
@@ -255,20 +241,24 @@ internal static class UpdateSystemPatch
|
||||
{
|
||||
PlayerControl pc = pcs[index];
|
||||
|
||||
switch (pc.GetCustomRole())
|
||||
try
|
||||
{
|
||||
case CustomRoles.Wiper:
|
||||
switch (pc.GetCustomRole())
|
||||
{
|
||||
if (petcd) pc.AddAbilityCD();
|
||||
else pc.RpcResetAbilityCooldown();
|
||||
break;
|
||||
}
|
||||
case CustomRoles.Evader:
|
||||
{
|
||||
pc.RpcMakeVisible();
|
||||
break;
|
||||
case CustomRoles.Wiper:
|
||||
{
|
||||
if (petcd) pc.AddAbilityCD();
|
||||
else pc.RpcResetAbilityCooldown();
|
||||
break;
|
||||
}
|
||||
case CustomRoles.Evader:
|
||||
{
|
||||
pc.RpcMakeVisible();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) { Utils.ThrowException(e); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,17 +332,17 @@ internal static class EffectExtenstions
|
||||
|
||||
break;
|
||||
case Effect.AllDoorsOpen:
|
||||
try { DoorsReset.OpenAllDoors(); }
|
||||
try { DoorsReset.SetDoors(DoorsReset.ResetMode.AllOpen); }
|
||||
catch { }
|
||||
|
||||
break;
|
||||
case Effect.AllDoorsClose:
|
||||
try { DoorsReset.CloseAllDoors(); }
|
||||
try { DoorsReset.SetDoors(DoorsReset.ResetMode.AllClosed); }
|
||||
catch { }
|
||||
|
||||
break;
|
||||
case Effect.SetDoorsRandomly:
|
||||
try { DoorsReset.OpenOrCloseAllDoorsRandomly(); }
|
||||
try { DoorsReset.SetDoors(DoorsReset.ResetMode.RandomByDoor); }
|
||||
catch { }
|
||||
|
||||
break;
|
||||
|
||||
@@ -148,7 +148,7 @@ public class Telekinetic : RoleBase
|
||||
Timer += 30;
|
||||
break;
|
||||
case Mode.Doors:
|
||||
DoorsReset.OpenAllDoors();
|
||||
DoorsReset.SetDoors(DoorsReset.ResetMode.AllOpen);
|
||||
Timer += 35;
|
||||
Freeze();
|
||||
break;
|
||||
|
||||
@@ -75,6 +75,8 @@ public class Transposer : RoleBase
|
||||
|
||||
try
|
||||
{
|
||||
Main.CheckShapeshift[firstTargetId] = true;
|
||||
Main.CheckShapeshift[target.PlayerId] = true;
|
||||
firstTarget.Shapeshift(target, false);
|
||||
target.Shapeshift(firstTarget, false);
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ internal class AntiAdminer : RoleBase
|
||||
if (pc.GetAbilityUseLimit() >= 1)
|
||||
{
|
||||
pc.RpcRemoveAbilityUse();
|
||||
DoorsReset.OpenAllDoors();
|
||||
DoorsReset.SetDoors(DoorsReset.ResetMode.AllOpen);
|
||||
}
|
||||
else
|
||||
pc.Notify(Translator.GetString("OutOfAbilityUsesDoMoreTasks"));
|
||||
|
||||
@@ -276,6 +276,7 @@ internal class Bargainer : RoleBase
|
||||
|
||||
private void CycleItem(PlayerControl pc)
|
||||
{
|
||||
if (!InShop) return;
|
||||
List<Item> list = OrderedItems.ToList();
|
||||
SelectedItem = list[(list.IndexOf(SelectedItem) + 1) % list.Count];
|
||||
Utils.SendRPC(CustomRPC.SyncBargainer, pc.PlayerId, 2, (int)SelectedItem);
|
||||
|
||||
Reference in new issue
Block a user