Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions COTLMP/COTLMP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\COTLMPServer\COTLMPServer.csproj" />
</ItemGroup>
</Project>
40 changes: 40 additions & 0 deletions COTLMP/Data/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,46 @@ public static string Multiplayer_Text
}
}

public static string StartServer
{
get
{
return LocalizationManager.GetTranslation("Multiplayer/UI/StartServer");
}
}

public static string ServerStarted
{
get
{
return LocalizationManager.GetTranslation("Multiplayer/UI/ServerStarted");
}
}

public static string Disconnected
{
get
{
return LocalizationManager.GetTranslation("Multiplayer/UI/Disconnected");
}
}

public static string DisconnectedError
{
get
{
return LocalizationManager.GetTranslation("Multiplayer/UI/DisconnectedError");
}
}

public static string ServerStopConfirm
{
get
{
return LocalizationManager.GetTranslation("Multiplayer/UI/ServerConfirm");
}
}

public static class Settings
{
public static string MultiplayerSettings_Title
Expand Down
8 changes: 4 additions & 4 deletions COTLMP/Data/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
namespace COTLMP.Data
{
public class Version
{
public const string CotlMpGuid = "geob99.cotl.cotlmp";
public const string CotlMpName = "Cult of the Lamb Multiplayer Mod Plug-In";
public const string CotlMpVer = "0.0.0.1";
{
public const string CotlMpGuid = "geob99.cotl.cotlmp";
public const string CotlMpName = "Cult of the Lamb Multiplayer Mod Plug-In";
public const string CotlMpVer = "0.0.0.1";
}
}

Expand Down
7 changes: 6 additions & 1 deletion COTLMP/Language/en-US.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ public class English
new("Multiplayer/UI/Settings/VoiceChat", "Enable Voice Chat", false),
new("Multiplayer/Game/Join", "{0} has joined the server", false),
new("Multiplayer/Game/Left", "{0} has left the server", false),
new("Multiplayer/UI/WIP", "Multiplayer is currently not implemented yet", false)
new("Multiplayer/UI/WIP", "Multiplayer is currently not implemented yet", false),
new("Multiplayer/UI/StartServer", "Open to LAN", false),
new("Multiplayer/UI/ServerStarted", "Stop server and quit", false),
new("Multiplayer/UI/ServerConfirm", "Are you sure you want to stop the server? This action will return you to the main menu without saving progress.", false),
new("Multiplayer/UI/Disconnected", "Disconnected", false),
new("Multiplayer/UI/DisconnectedError", "An error has ocurred (check console)", false)
];
}
}
Expand Down
Empty file removed COTLMP/Network/.keep
Empty file.
71 changes: 71 additions & 0 deletions COTLMP/Network/Network.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* PROJECT: Cult of the Lamb Multiplayer Mod
* LICENSE: MIT (https://spdx.org/licenses/MIT)
* PURPOSE: Define the network class
* COPYRIGHT: Copyright 2025 Neco-Arc <neco-arc@inbox.ru>
*/

/* IMPORTS ********************************************************************/

using COTLMP.Ui;
using UnityEngine;
using UnityEngine.SceneManagement;

/* CLASSES & CODE *************************************************************/

/**
* @brief
* The namespace for all network-related classes, enums and structs
*/
namespace COTLMP.Network
{
/**
* @brief
* The main class for network features
*/
internal class Network
{
/**
* @brief
* If the scene loaded is main menu, stop the integrated server
*
* @param[in] scene
* The scene
*
* @param[in] _
* The scene load mode, unused
*/
private static void OnSceneLoaded(Scene scene, LoadSceneMode _)
{
if (scene.name.Equals("Main Menu"))
{
// set the quitting flag temporarily so it doesn't try to transition to the main menu on server stop
PauseMenuPatches.Quitting = true;
PauseMenuPatches.Server?.Dispose();
PauseMenuPatches.Quitting = false;
}
}

/**
* @brief
* On game quitting, stop the integrated server
*/
private static void OnQuitting()
{
PauseMenuPatches.Quitting = true;
PauseMenuPatches.Server?.Dispose();
}

/**
* @brief
* Initialize the network components
*/
public static void Initialize()
{
SceneManager.sceneLoaded += OnSceneLoaded;
Application.quitting += OnQuitting;
}
}
}

/* EOF */
5 changes: 4 additions & 1 deletion COTLMP/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
using COTLMP.Ui;
using HarmonyLib;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine.SceneManagement;

/* NAMESPACES *****************************************************************/

Expand Down Expand Up @@ -179,6 +179,9 @@ private void Awake()
/* Initialize the Settings UI */
COTLMP.Ui.Settings.InitializeUI();

// Initialize the network features
COTLMP.Network.Network.Initialize();

/* Log to the debugger that our mod is loaded */
Logger.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
}
Expand Down
15 changes: 15 additions & 0 deletions COTLMP/Ui/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ private static bool OnMultiplayerButtonClickedPatch(MainMenu __instance)
ConfirmDialog.Configure(MultiplayerModLocalization.UI.Multiplayer_Title, MultiplayerModLocalization.UI.Multiplayer_Text, true);
return false;
}

/**
* @brief
* Show a message when returning to main menu, when needed
*/
[HarmonyPatch(typeof(MainMenu), "Start")]
[HarmonyPostfix]
private static void Start(MainMenu __instance)
{
if(PauseMenuPatches.Message != null)
{
__instance.Push<UIMenuConfirmationWindow>(MonoSingleton<UIManager>.Instance.ConfirmationWindowTemplate).Configure(MultiplayerModLocalization.UI.Disconnected, PauseMenuPatches.Message, true);
PauseMenuPatches.Message = null;
}
}
}
}
}
Expand Down
Loading