Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework #1

Merged
merged 23 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 4 additions & 2 deletions Common Utilities/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public class Config : IConfig
[Description("The multiplier applied to radio battery usage. Set to 0 to disable radio battery drain.")]
public float RadioBatteryDrainMultiplier { get; set; } = 1f;

[Description("The color to use for lights while the warhead is active. In the RGBA format using values between 0 and 1.")]
[Description("Whether to change the color of lights while warhead is active.")]
public bool ChangeWarheadColor { get; set; } = true;
Mikihero marked this conversation as resolved.
Show resolved Hide resolved

[Description("The color to use for lights while the warhead is active. In the RGBA format using values between 0 and 1. Ignored if ChangeWarheadColor is set to false.")]
public Color WarheadColor { get; set; } = new(1f, 0.2f, 0.2f, 1);

[Description("The maximum time, in seconds, that a player can be AFK before being kicked. Set to -1 to disable AFK system.")]
Expand All @@ -88,7 +91,6 @@ public class Config : IConfig
[Description("Whether or not probabilities should be additive (50 + 50 = 100) or not (50 + 50 = 2 seperate 50% chances)")]
public bool AdditiveProbabilities { get; set; } = false;

// TODO: check out starting inventory logic
[Description(
"The list of starting items for roles. ItemName is the item to give them, and Chance is the percent chance of them spawning with it, and Group allows you to restrict the item to only players with certain RA groups (Leave this as 'none' to allow all players to get the item). You can specify the same item multiple times.")]
public Dictionary<RoleTypeId, RoleInventory> StartingInventories { get; set; } = new()
Expand Down
4 changes: 1 addition & 3 deletions Common Utilities/EventHandlers/MapHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ namespace Common_Utilities.EventHandlers;

public class MapHandlers
{
private readonly Config config;

public MapHandlers(Plugin plugin) => config = plugin.Config;
private Config config => Plugin.Instance.Config;

public void OnUpgradingPickup(UpgradingPickupEventArgs ev)
{
Expand Down
6 changes: 2 additions & 4 deletions Common Utilities/EventHandlers/PlayerHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ namespace Common_Utilities.EventHandlers;

public class PlayerHandlers
{
private readonly Config config;

public PlayerHandlers(Plugin plugin) => config = plugin.Config;

private Config config => Plugin.Instance.Config;

public void OnPlayerVerified(VerifiedEventArgs ev)
{
string message = FormatJoinMessage(ev.Player);
Expand Down
8 changes: 5 additions & 3 deletions Common Utilities/EventHandlers/ServerHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ namespace Common_Utilities.EventHandlers

public class ServerHandlers
{
private readonly Config config;
private Config config => Plugin.Instance.Config;

private bool friendlyFireDisable;

public ServerHandlers(Plugin plugin) => config = plugin.Config;

public void OnRoundStarted()
{
if (config.AutonukeTime > -1)
Expand Down Expand Up @@ -77,6 +76,9 @@ public void OnRestartingRound()

public void OnWarheadStarting(StartingEventArgs _)
{
if (!config.ChangeWarheadColor)
return;

Mikihero marked this conversation as resolved.
Show resolved Hide resolved
foreach (Room room in Room.List)
room.Color = config.WarheadColor;
}
Expand Down
14 changes: 8 additions & 6 deletions Common Utilities/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class Plugin : Plugin<Config>

public override string Name { get; } = "Common Utilities";

public override string Author { get; } = "ExMod-Team, overhaul by Mikihero";
public override string Author { get; } = "ExMod-Team";

public override Version Version { get; } = new(7, 1, 1);

Expand All @@ -58,13 +58,13 @@ public override void OnEnabled()

Random = new Random();

Log.Info($"Instantiating Events..");
Log.Debug("Instantiating Events..");

playerHandlers = new PlayerHandlers(this);
serverHandlers = new ServerHandlers(this);
mapHandlers = new MapHandlers(this);
playerHandlers = new PlayerHandlers();
serverHandlers = new ServerHandlers();
mapHandlers = new MapHandlers();

Log.Info($"Registering EventHandlers..");
Log.Debug("Registering EventHandlers..");

player.Hurting += playerHandlers.OnPlayerHurting;
player.Verified += playerHandlers.OnPlayerVerified;
Expand Down Expand Up @@ -107,6 +107,8 @@ public override void OnEnabled()

warhead.Starting += serverHandlers.OnWarheadStarting;
warhead.Stopping += serverHandlers.OnWarheadStopping;

Log.Debug("Registered EventHandlers");

base.OnEnabled();
}
Expand Down