Skip to content

Commit

Permalink
Fixed Intercom
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal78900 committed Apr 22, 2021
1 parent 142bdcd commit 2f0d103
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Remade version of this plugin: https://github.com/TruthfullyHonest/WaitAndChill
- Choice of randomly setting a room for users to be spawnned in

## Note
- %player will return one of two options for messages ((0 or x players have connected) or (1 player has connected))
- %seconds will return one of four options for messages (The server is paused, The round has started, 1 second remains, x seconds remain)
- **{player}** will return one of two options for messages ((0 or x players have connected) or (1 player has connected))
- **{seconds}** will return one of four options for messages (The server is paused, The round has started, 1 second remains, x seconds remain)

# Config
```yml
Expand Down Expand Up @@ -55,7 +55,7 @@ wait_and_chill_reborn:
# Determines the position of the Hint on the users screen (32 = Top, 0 = Middle, -15 = Below)
hint_vert_pos: 25
```
#Translations
# Translations
```yml
translations:
top_message: <size=40><color=yellow><b>The game will be starting soon, {seconds}</b></color></size>
Expand Down
5 changes: 1 addition & 4 deletions WaitAndChillReborn/Handler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ internal void OnTeleporting(TeleportingEventArgs ev)

internal void OnSendingRemoteAdminCommand(SendingRemoteAdminCommandEventArgs ev)
{
if (IsLobby && ev.Name == "destroy" && ev.Arguments[0] == "**")
if (spawnedDoors.Count > 0 && ev.Name == "destroy" && ev.Arguments[0] == "**")
{
ev.IsAllowed = false;
ev.Success = false;
Expand All @@ -162,9 +162,6 @@ internal void OnSendingRemoteAdminCommand(SendingRemoteAdminCommandEventArgs ev)

internal void OnRoundStarted()
{
Intercom.host.CustomContent = string.Empty;
Intercom.host.Network_state = Intercom.State.Ready;

SubClassHandler(true);

Timing.CallDelayed(0.25f, () =>
Expand Down
32 changes: 31 additions & 1 deletion WaitAndChillReborn/Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ internal void Scp079sDoors(bool state)
}

byte doorType = 0;
internal void SpawnDoor(Vector3 position, Vector3 rotation)
internal void SpawnDoor(Vector3 position, Vector3 rotation, bool big = false)
{
// Original code by 初音早猫(sanyae2439)#0001

Expand All @@ -217,6 +217,9 @@ internal void SpawnDoor(Vector3 position, Vector3 rotation)

var door = Object.Instantiate(prefab.TargetPrefab, position, Quaternion.Euler(rotation));

if (big)
door.transform.localScale = new Vector3(4f, 4f, 2.5f);

spawnedDoors.Add(door.gameObject);
NetworkServer.Spawn(door.gameObject);
}
Expand Down Expand Up @@ -281,6 +284,7 @@ internal void SpawnParkour()

SpawnDoor(new Vector3(231f, 1029f, -20f), new Vector3(90f, 0f, 0f));

//Tower floor
for (int x = 0; x < 6; x++)
{
for (int z = 0; z < 4; z++)
Expand All @@ -290,6 +294,32 @@ internal void SpawnParkour()
}
}

// Tower wall
for (int z = 0; z < 7; z++)
{
doorType = 2;
SpawnDoor(new Vector3(217f, 1029f, -24 + z * 2f), new Vector3(0f, 90f, 0f));
}

// Tower wall
for (int x = 0; x < 6; x++)
{
doorType = 2;
SpawnDoor(new Vector3(228f - x * 2f, 1029f, -25f), new Vector3(0f, 0f, 0f));
}

// Tower wall
for (int x = 0; x < 6; x++)
{
doorType = 2;
SpawnDoor(new Vector3(228f - x * 2f, 1029f, -12f), new Vector3(0f, 0f, 0f));
}

doorType = 1;
SpawnDoor(new Vector3(233f, 1020f, -12f), new Vector3(0f, 0f, 0f), true);
doorType = 1;
SpawnDoor(new Vector3(233f, 1020f, -25f), new Vector3(0f, 0f, 0f), true);

byte[,] slArray = {
{ 0,0,0,0,0,0,0,0,0,0,0,0,0 },
{ 0, 0,1,1,1, 0,0, 1,0,0,0, 0,0 },
Expand Down
22 changes: 19 additions & 3 deletions WaitAndChillReborn/Patches/IntercomPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
{
using Exiled.API.Features;
using HarmonyLib;
using MEC;
using System.Linq;

[HarmonyPatch(typeof(Intercom), nameof(Intercom.Start))]
public static class IntercomStartPatch
{
private static void Postfix(Intercom __instance)
internal static bool first = true;

public static void Postfix(Intercom __instance)
{
if (!string.IsNullOrEmpty(WaitAndChillReborn.Singleton.Config.Translations.Intercom))
{
first = true;
__instance.Network_state = Intercom.State.Custom;
}
}
Expand All @@ -19,21 +23,33 @@ private static void Postfix(Intercom __instance)
[HarmonyPatch(typeof(Intercom), nameof(Intercom.Update))]
public static class IntercomUpdatePatch
{
private static bool Prefix(Intercom __instance)
public static bool Prefix(Intercom __instance)
{
if (Handler.IsLobby && !string.IsNullOrEmpty(WaitAndChillReborn.Singleton.Config.Translations.Intercom))
{
string intercomText = WaitAndChillReborn.Singleton.Config.Translations.Intercom;
intercomText = intercomText.Replace("{servername}", Server.Name).Replace("{playercount}", Player.List.Count().ToString()).Replace("{maxplayers}", CustomNetworkManager.slots.ToString());

__instance.CustomContent = intercomText;
__instance.Network_intercomText = __instance.Network_intercomText;
__instance.UpdateText();

return false;
}
else
{
if (IntercomStartPatch.first)
{
Timing.CallDelayed(1f, () =>
{
__instance.CustomContent = string.Empty;
__instance.Network_intercomText = string.Empty;
__instance.UpdateText();
IntercomStartPatch.first = false;
});
}
return true;
}
}
}
}

0 comments on commit 2f0d103

Please sign in to comment.