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
475 changes: 475 additions & 0 deletions COTLMP/Api/Configuration.cs

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions COTLMP/Data/ModDataGlobals.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: Globals data of the mod
* COPYRIGHT: Copyright 2025 GeoB99 <geobman1999@gmail.com>
*/

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

using COTLMP;

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

/*
* @brief
* Contains global mod data.
*
* @class ModDataGlobals
* Main class of which mod data is stored.
*/
namespace COTLMP.Data
{
internal class ModDataGlobals
{
/* Enable or Disable the execution of the mod */
public bool EnableMod;

/* The current executing game-play mode */
public string GameMode;

/* The name of the player in-game */
public string PlayerName;

/* The name of the server */
public string ServerName;

/* The maximum allowed number of players */
public int MaxNumPlayers;

/* Enable or Disable voice chat */
public bool EnableVoiceChat;

/******************************************************************************
* THE FOLLOWING FIELDS ARE RESERVED INTERNALLY *
* FOR THE MOD. CHANGE THESE VALUES WITH CAUTION!!! *
******************************************************************************/

/* Enable or disable verbose debug output in the console */
internal bool VerboseDebug = false;

/* The internal variable of maximum count of players per server. Used for validation purposes. */
internal const int MaxPlayersPerServerInternal = 8;

public ModDataGlobals(bool Enable,
string Mode,
string PlName,
string SvName,
int PlNum,
bool EnableVC)
{
EnableMod = Enable;
GameMode = Mode;
PlayerName = PlName;
ServerName = SvName;
MaxNumPlayers = PlNum;
EnableVoiceChat = EnableVC;
}
}
}

/* EOF */
8 changes: 0 additions & 8 deletions COTLMP/Data/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,6 @@ public static string MultiplayerSettings_VoiceChat
return LocalizationManager.GetTranslation("Multiplayer/UI/Settings/VoiceChat");
}
}

public static string MultiplayerSettings_SayChat
{
get
{
return LocalizationManager.GetTranslation("Multiplayer/UI/Settings/SayChat");
}
}
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion COTLMP/Debug/PrintLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public enum DebugComponent
INIT_COMPONENT = 0,
UI_COMPONENT,
NETWORK_STACK_COMPONENT,
LOCALIZATION_COMPONENT
LOCALIZATION_COMPONENT,
CONFIGURATION_COMPONENT
}

public class PrintLogger
Expand Down Expand Up @@ -128,6 +129,12 @@ private static string GetComponentName(DebugComponent Component)
break;
}

case DebugComponent.CONFIGURATION_COMPONENT:
{
Name = "CONFIGURATION_COMPONENT";
break;
}

default:
{
Name = null;
Expand Down
205 changes: 205 additions & 0 deletions COTLMP/Game/Callbacks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
/*
* PROJECT: Cult of the Lamb Multiplayer Mod
* LICENSE: MIT (https://spdx.org/licenses/MIT)
* PURPOSE: Setting callbacks methods
* COPYRIGHT: Copyright 2025 GeoB99 <geobman1999@gmail.com>
*/

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

using COTLMP;
using COTLMP.Debug;
using COTLMP.Api;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using System;
using UnityEngine;
using UnityEngine.Assertions;

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

/*
* @brief
* Contains the classes and code for the mod game related stuff.
*
* @class Callbacks
* The callbacks class which contains callback methods for the
* mod game settings.
*/
namespace COTLMP.Game
{
internal static class Callbacks
{
/*
* @brief
* A callback that gets called when the Toggle Mod
* setting's value has changed.
*
* @param[in] Value
* A boolean value representing the value of the setting
* that has changed.
*/
public static void ModToggleCallback(bool Value)
{
string Section;
ConfigDefinition Definition;
ConfigEntry<bool> SettingEntry;

/* Retrieve the section name for the setting */
Section = COTLMP.Api.Configuration.GetSectionName(CONFIGURATION_SECTION.ModSettings);

/* Get the Mod Toggle setting */
Definition = new ConfigDefinition(Section, "Toggle Mod");
SettingEntry = COTLMP.Api.Configuration.GetSettingEntry<bool>(Definition);
Assert.IsNotNull(SettingEntry);

/* Cache the new value to the globals store */
Plugin.Globals.EnableMod = Value;

/* FIXME: Enable/Disable mod execution here */

/* Overwrite the current value of the setting and flush it */
SettingEntry.BoxedValue = Value;
COTLMP.Api.Configuration.FlushSettings();
}

/*
* @brief
* A callback that gets called when the Game Mode
* setting's value has changed.
*
* @param[in] Value
* An integer value representing the value of the
* setting that has changed.
*/
public static void GameModeCallback(int Value)
{
string Section;
string GameMode;
ConfigDefinition Definition;
ConfigEntry<string> SettingEntry;

/* Retrieve the section name for the setting */
Section = COTLMP.Api.Configuration.GetSectionName(CONFIGURATION_SECTION.ServerSettings);

/* Get the Game Mode setting */
Definition = new ConfigDefinition(Section, "Game Mode");
SettingEntry = COTLMP.Api.Configuration.GetSettingEntry<string>(Definition);
Assert.IsNotNull(SettingEntry);

/* FIXME: This is a placeholder code, the game modes should be declared in a dedicated enum */
switch (Value)
{
case 0:
{
GameMode = "Standard";
break;
}

case 1:
{
GameMode = "Boss Fight";
break;
}

case 2:
{
GameMode = "Deathmatch";
break;
}

case 3:
{
GameMode = "Zombies!";
break;
}

/* Always default the game mode to Standard on bogus values */
default:
{
GameMode = "Standard";
break;
}
}

/* Cache the new value to the globals store */
Plugin.Globals.GameMode = GameMode;

/* Overwrite the current value of the setting and flush it */
SettingEntry.BoxedValue = GameMode;
COTLMP.Api.Configuration.FlushSettings();
}

/*
* @brief
* A callback that gets called when the Max Players
* Count setting's value has changed.
*
* @param[in] Value
* An integer value representing the value of the
* setting that has changed.
*/
public static void PlayerCountCallback(int Value)
{
string Section;
ConfigDefinition Definition;
ConfigEntry<int> SettingEntry;

/* Retrieve the section name for the setting */
Section = COTLMP.Api.Configuration.GetSectionName(CONFIGURATION_SECTION.ServerSettings);

/* Get the Max Players Count setting */
Definition = new ConfigDefinition(Section, "Max Players");
SettingEntry = COTLMP.Api.Configuration.GetSettingEntry<int>(Definition);
Assert.IsNotNull(SettingEntry);

/*
* Cache the new value to the globals store.
* The horizontal selector begins its first element at index of 0
* which is which why we increment the value by one to make up the
* real count of max number of players.
*/
Plugin.Globals.MaxNumPlayers = Value + 1;

/* Overwrite the current value of the setting and flush it */
SettingEntry.BoxedValue = Value + 1;
COTLMP.Api.Configuration.FlushSettings();
}

/*
* @brief
* A callback that gets called when the Toggle Voice
* Chat setting's value has changed.
*
* @param[in] Value
* A boolean value representing the value of the
* setting that has changed.
*/
public static void VoiceChatCallback(bool Value)
{
string Section;
ConfigDefinition Definition;
ConfigEntry<bool> SettingEntry;

/* Retrieve the section name for the setting */
Section = COTLMP.Api.Configuration.GetSectionName(CONFIGURATION_SECTION.ServerSettings);

/* Get the Voice Chat Toggle setting */
Definition = new ConfigDefinition(Section, "Toggle Voice Chat");
SettingEntry = COTLMP.Api.Configuration.GetSettingEntry<bool>(Definition);
Assert.IsNotNull(SettingEntry);

/* Cache the new value to the globals store */
Plugin.Globals.EnableVoiceChat = Value;

/* FIXME: Enable/Disable the voice chat subsystem here */

/* Overwrite the current value of the setting and flush it */
SettingEntry.BoxedValue = Value;
COTLMP.Api.Configuration.FlushSettings();
}
}
}

/* EOF */
1 change: 0 additions & 1 deletion COTLMP/Language/en-US.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class English
new("Multiplayer/UI/Settings/GameMode", "Game Mode", false),
new("Multiplayer/UI/Settings/PlayerCount", "Number of maximum players to join", false),
new("Multiplayer/UI/Settings/VoiceChat", "Enable Voice Chat", false),
new("Multiplayer/UI/Settings/SayChat", "Enable Say 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)
Expand Down
Loading