Skip to content

Commit

Permalink
Refactoring for duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
trippyone committed Jun 17, 2024
1 parent bbd3a5f commit 5f46e2f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Fika.Core/Coop/Utils/NetManagerUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ public static class NetManagerUtils
private static ManualLogSource logger = BepInEx.Logging.Logger.CreateLogSource("NetManagerUtils");
public static GameObject FikaGameObject;

public static void CreateFikaGameObject()
{
FikaGameObject = new GameObject("FikaGameObject");
Object.DontDestroyOnLoad(FikaGameObject);
logger.LogInfo("FikaGameObject has been created!");
}

public static void CreateNetManager(bool isServer)
{
if (FikaGameObject == null)
{
FikaGameObject = new GameObject("FikaGameObject");
Object.DontDestroyOnLoad(FikaGameObject);
logger.LogInfo("FikaGameObject has been created!");
CreateFikaGameObject();
}

if (isServer)
Expand All @@ -40,9 +45,7 @@ public static void CreatePingingClient()
{
if (FikaGameObject == null)
{
FikaGameObject = new GameObject("FikaGameObject");
Object.DontDestroyOnLoad(FikaGameObject);
logger.LogInfo("FikaGameObject has been created!");
CreateFikaGameObject();
}

FikaPingingClient pingingClient = FikaGameObject.AddComponent<FikaPingingClient>();
Expand Down

0 comments on commit 5f46e2f

Please sign in to comment.