mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
cache suffix in ND
This commit is contained in:
1 parent
60c3b8c76c
commit
b4fe41e4d7
3 files changed
+35
-16
No files matched your search
@@ -139,6 +139,8 @@ public static class NaturalDisasters
|
||||
|
||||
const float extend = 5f;
|
||||
MapBounds = ((x.Min() - extend, x.Max() + extend), (y.Min() - extend, y.Max() + extend));
|
||||
|
||||
RebuildSuffixText();
|
||||
}
|
||||
|
||||
public static void ApplyGameOptions(IGameOptions opt, byte id)
|
||||
@@ -146,19 +148,30 @@ public static class NaturalDisasters
|
||||
ActiveDisasters.ForEach(x => x.ApplyOwnGameOptions(opt, id));
|
||||
}
|
||||
|
||||
public static string SuffixText()
|
||||
public static string SuffixText;
|
||||
|
||||
public static void RebuildSuffixText()
|
||||
{
|
||||
var allRooms = ShipStatus.Instance.AllRooms;
|
||||
var collapsedRooms = BuildingCollapse.CollapsedRooms;
|
||||
string cb = allRooms.Count / 2 <= collapsedRooms.Count
|
||||
? (string.Format(Translator.GetString("AvailableBuildings"), allRooms.Count != collapsedRooms.Count
|
||||
? allRooms.Select(x => x.RoomId).Where(x => x is not (SystemTypes.Hallway or SystemTypes.Outside) && !x.ToString().Contains("Decontamination")).Except(collapsedRooms.ConvertAll(x => x.RoomId)).Select(x => Translator.GetString($"{x}")).Distinct().Join()
|
||||
: $"<#ff0000>{Translator.GetString("None")}</color>"))
|
||||
: (string.Format(Translator.GetString("CollapsedBuildings"), collapsedRooms.Count > 0
|
||||
string cb;
|
||||
|
||||
if (allRooms.Count / 2 <= collapsedRooms.Count)
|
||||
{
|
||||
SystemTypes[] remainingRooms = allRooms.Select(x => x.RoomId).Where(x => x is not (SystemTypes.Hallway or SystemTypes.Outside) && !x.ToString().Contains("Decontamination")).Except(collapsedRooms.ConvertAll(x => x.RoomId)).ToArray();
|
||||
cb = string.Format(Translator.GetString("AvailableBuildings"), remainingRooms.Length > 0
|
||||
? remainingRooms.Select(x => Translator.GetString($"{x}")).Distinct().Join()
|
||||
: $"<#ff0000>{Translator.GetString("None")}</color>");
|
||||
}
|
||||
else
|
||||
{
|
||||
cb = string.Format(Translator.GetString("CollapsedBuildings"), collapsedRooms.Count > 0
|
||||
? collapsedRooms.Select(x => Translator.GetString($"{x.RoomId}")).Distinct().Join()
|
||||
: Translator.GetString("None")));
|
||||
: Translator.GetString("None"));
|
||||
}
|
||||
|
||||
string ts = ActiveDisasters.Exists(x => x is Thunderstorm) ? $"\n{Translator.GetString("OngoingThunderstorm")}" : string.Empty;
|
||||
return $"<size=70%>{cb}{ts}</size>";
|
||||
SuffixText = $"<size=70%>{cb}{ts}</size>";
|
||||
}
|
||||
|
||||
public static int SurvivalTime(byte id)
|
||||
@@ -267,7 +280,6 @@ public static class NaturalDisasters
|
||||
|
||||
Disaster remove = PreferRemovingThunderstorm.GetBool() ? ActiveDisasters.Find(x => x is Thunderstorm) : ActiveDisasters.RandomElement();
|
||||
if (remove != null) remove.Duration = 0;
|
||||
|
||||
remove?.RemoveIfExpired();
|
||||
break;
|
||||
}
|
||||
@@ -331,6 +343,7 @@ public static class NaturalDisasters
|
||||
{
|
||||
BuildingCollapse.CollapsedRooms.Clear();
|
||||
Sinkhole.RemoveRandomSinkhole();
|
||||
RebuildSuffixText();
|
||||
Utils.NotifyRoles();
|
||||
}
|
||||
|
||||
@@ -703,7 +716,11 @@ public static class NaturalDisasters
|
||||
|
||||
naturalDisaster.Despawn();
|
||||
|
||||
LateTask.New(() => Utils.NotifyRoles(), 0.2f, "Thunderstorm Notify");
|
||||
LateTask.New(() =>
|
||||
{
|
||||
RebuildSuffixText();
|
||||
Utils.NotifyRoles();
|
||||
}, 0.2f, "Thunderstorm Notify");
|
||||
}
|
||||
|
||||
public override int Duration { get; set; } = DurationOpt.GetInt();
|
||||
@@ -756,6 +773,7 @@ public static class NaturalDisasters
|
||||
if (Duration == 0 || Utils.TimeStamp - StartTimeStamp >= Duration)
|
||||
{
|
||||
ActiveDisasters.Remove(this);
|
||||
RebuildSuffixText();
|
||||
Utils.NotifyRoles();
|
||||
return true;
|
||||
}
|
||||
@@ -994,9 +1012,9 @@ public static class NaturalDisasters
|
||||
{
|
||||
NetObject = naturalDisaster;
|
||||
Update();
|
||||
|
||||
PlainShipRoom room = ShipStatus.Instance.AllRooms.FirstOrDefault(x => x.RoomId == naturalDisaster.Room);
|
||||
if (!room) return;
|
||||
|
||||
if (!naturalDisaster.Room.HasValue) return;
|
||||
PlainShipRoom room = naturalDisaster.Room.Value.GetRoomClass();
|
||||
|
||||
foreach (PlayerControl pc in Main.EnumerateAlivePlayerControls())
|
||||
{
|
||||
@@ -1005,6 +1023,7 @@ public static class NaturalDisasters
|
||||
}
|
||||
|
||||
CollapsedRooms.Add(room);
|
||||
RebuildSuffixText();
|
||||
Utils.NotifyRoles();
|
||||
}
|
||||
|
||||
@@ -1034,7 +1053,7 @@ public static class NaturalDisasters
|
||||
}
|
||||
else pc.DieToDisaster(PlayerState.DeathReason.Collapsed);
|
||||
}
|
||||
else LastPosition[pc.PlayerId] = pc.Pos();
|
||||
else LastPosition[pc.PlayerId] = pc.transform.position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2847,7 +2847,7 @@ public static class Utils
|
||||
additionalSuffixes.Add(CaptureTheFlag.GetSuffixText(seer, seer));
|
||||
break;
|
||||
case CustomGameMode.NaturalDisasters:
|
||||
additionalSuffixes.Add(NaturalDisasters.SuffixText());
|
||||
additionalSuffixes.Add(NaturalDisasters.SuffixText);
|
||||
break;
|
||||
case CustomGameMode.RoomRush:
|
||||
additionalSuffixes.Add(RoomRush.GetSuffix(seer));
|
||||
|
||||
+1
-1
@@ -274,7 +274,7 @@ internal static class HudManagerPatch
|
||||
CustomGameMode.StopAndGo => StopAndGo.GetHudText(),
|
||||
CustomGameMode.HotPotato => HotPotato.GetSuffixText(player.PlayerId, true),
|
||||
CustomGameMode.HideAndSeek => CustomHnS.GetSuffixText(player, player, true),
|
||||
CustomGameMode.NaturalDisasters when AmongUsClient.Instance.AmHost => NaturalDisasters.SuffixText(),
|
||||
CustomGameMode.NaturalDisasters when AmongUsClient.Instance.AmHost => NaturalDisasters.SuffixText,
|
||||
CustomGameMode.Deathrace => Deathrace.GetSuffix(player, player, true),
|
||||
CustomGameMode.Snowdown => Snowdown.GetHudText(),
|
||||
CustomGameMode.Standard => state.Role.GetSuffix(player, player, true, GameStates.IsMeeting) + GetAddonSuffixes(),
|
||||
|
||||
Reference in new issue
Block a user