Skip to content

Commit

Permalink
Merge pull request #11 from pdcook/PlayerFaceOnline
Browse files Browse the repository at this point in the history
Fix for Player Face Online Bug
  • Loading branch information
olavim authored Oct 23, 2021
2 parents da7e86d + 402b133 commit e2ccd84
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion RoundsWithFriends/RoundsWithFriends.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static DebugOptions Deserialize(byte[] data)
public class RWFMod : BaseUnityPlugin
{
private const string ModId = "io.olavim.rounds.rwf";
public const string Version = "1.3.8";
public const string Version = "1.3.9";

#if DEBUG
public static readonly bool DEBUG = true;
Expand All @@ -64,6 +64,8 @@ public class RWFMod : BaseUnityPlugin

public static RWFMod instance;

private static bool facesSet = false;

public static string GetCustomPropertyKey(string prop)
{
return $"{ModId}/{prop}";
Expand Down Expand Up @@ -180,6 +182,8 @@ public void Start()
GameModeManager.AddHook(GameModeHooks.HookPointStart, gm => this.ToggleCeaseFire(true));
GameModeManager.AddHook(GameModeHooks.HookBattleStart, gm => this.ToggleCeaseFire(false));
GameModeManager.AddHook(GameModeHooks.HookInitEnd, this.OnGameModeInitialized);
GameModeManager.AddHook(GameModeHooks.HookGameStart, this.UnsetFaces);
GameModeManager.AddHook(GameModeHooks.HookPickStart, this.SetPlayerFaces);

this.gameObject.AddComponent<RoundEndHandler>();

Expand Down Expand Up @@ -220,6 +224,39 @@ public static void SetDebugOptions(DebugOptions opts)
GameModeManager.CurrentHandler?.ChangeSetting("pointsToWinRound", opts.points);
}

private IEnumerator UnsetFaces(IGameModeHandler gm)
{
RWFMod.facesSet = false;
yield break;
}
private IEnumerator SetPlayerFaces(IGameModeHandler gm)
{
if (RWFMod.facesSet)
{
yield break;
}
foreach (Player player in PlayerManager.instance.players)
{
if (player.data.view.IsMine)
{
PlayerFace playerFace = CharacterCreatorHandler.instance.selectedPlayerFaces[0];
player.data.view.RPC("RPCA_SetFace", RpcTarget.All, new object[]
{
playerFace.eyeID,
playerFace.eyeOffset,
playerFace.mouthID,
playerFace.mouthOffset,
playerFace.detailID,
playerFace.detailOffset,
playerFace.detail2ID,
playerFace.detail2Offset
});
}
}
RWFMod.facesSet = true;
yield break;
}

private IEnumerator OnGameModeInitialized(IGameModeHandler gm)
{
if (!this.gmInitialized.ContainsKey(gm.Name))
Expand Down

0 comments on commit e2ccd84

Please sign in to comment.