-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
485 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using DeathmatchAPI.Events; | ||
using DeathmatchAPI.Helpers; | ||
|
||
namespace DeathmatchAPI; | ||
|
||
public interface IDeathmatchAPI | ||
{ | ||
public void StartCustomMode(int modeId); | ||
public void ChangeNextMode(int modeId); | ||
public void AddCustomMode(int modeId, ModeData mode); | ||
public void ChangeCheckDistance(int distance); | ||
|
||
/* | ||
Team String - Available values: ct | t | ||
Spawns Dictionary - Vector & QAngle to string | ||
*/ | ||
public void SetupCustomSpawns(string team, Dictionary<string, string> spawns); | ||
public void SwapHudMessageVisibility(bool visible); | ||
public int GetActiveModeId(); | ||
public int GetActiveModeRemainingTime(); | ||
public Dictionary<string, ModeData> GetCustomModes(); | ||
public event EventHandler<IDeathmatchEventsAPI> DeathmatchEventHandlers; | ||
public void TriggerEvent(IDeathmatchEventsAPI @event); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace DeathmatchAPI.Events; | ||
public interface IDeathmatchEventsAPI | ||
{ | ||
public record OnCustomModeStarted(int modeId) : IDeathmatchEventsAPI; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace DeathmatchAPI.Helpers; | ||
|
||
public class ModeData | ||
{ | ||
public required string Name { get; set; } | ||
public required int Interval { get; set; } | ||
public required int Armor { get; set; } | ||
public required bool OnlyHS { get; set; } | ||
public required bool KnifeDamage { get; set; } | ||
public required bool RandomWeapons { get; set; } | ||
public required string CenterMessageText { get; set; } | ||
public List<string>? PrimaryWeapons { get; set; } | ||
public List<string>? SecondaryWeapons { get; set; } | ||
public List<string>? Utilities { get; set; } | ||
public List<string>? ExecuteCommands { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using DeathmatchAPI; | ||
using DeathmatchAPI.Events; | ||
using DeathmatchAPI.Helpers; | ||
|
||
namespace Deathmatch; | ||
|
||
public partial class Deathmatch : IDeathmatchAPI | ||
{ | ||
public event EventHandler<IDeathmatchEventsAPI>? DeathmatchEventHandlers; | ||
public void TriggerEvent(IDeathmatchEventsAPI @event) | ||
{ | ||
DeathmatchEventHandlers?.Invoke(this, @event); | ||
} | ||
|
||
public void StartCustomMode(int modeId) | ||
{ | ||
if (!CustomModes.ContainsKey(modeId.ToString())) | ||
throw new Exception($"A Custom mode with ID '{modeId}' cannot be started, because this mode does not exist!"); | ||
|
||
SetupCustomMode(modeId.ToString()); | ||
} | ||
|
||
public void ChangeNextMode(int modeId) | ||
{ | ||
if (!CustomModes.ContainsKey(modeId.ToString())) | ||
throw new Exception($"A Custom mode with ID '{modeId}' cannot be set as next mode, because this mode does not exist!"); | ||
|
||
NextMode = modeId; | ||
} | ||
|
||
public void AddCustomMode(int modeId, ModeData mode) | ||
{ | ||
if (CustomModes.ContainsKey(modeId.ToString())) | ||
throw new Exception($"A Custom mode with ID '{modeId}' cannot be added, because this mode already exists!"); | ||
|
||
CustomModes.Add(modeId.ToString(), mode); | ||
} | ||
|
||
public void ChangeCheckDistance(int distance) | ||
{ | ||
CheckedEnemiesDistance = distance; | ||
} | ||
|
||
public void SetupCustomSpawns(string team, Dictionary<string, string> spawns) | ||
{ | ||
if (team.Equals("ct")) | ||
{ | ||
spawnPositionsCT.Clear(); | ||
foreach (var spawn in spawns) | ||
{ | ||
spawnPositionsCT.Add(ParseVector(spawn.Key), ParseQAngle(spawn.Value)); | ||
} | ||
} | ||
else if (team.Equals("t")) | ||
{ | ||
spawnPositionsT.Clear(); | ||
foreach (var spawn in spawns) | ||
{ | ||
spawnPositionsT.Add(ParseVector(spawn.Key), ParseQAngle(spawn.Value)); | ||
} | ||
} | ||
else | ||
{ | ||
throw new Exception($"Invalid team name '{team}'! Allowed options: ct , t"); | ||
} | ||
} | ||
|
||
public void SwapHudMessageVisibility(bool visible) | ||
{ | ||
VisibleHud = visible; | ||
} | ||
|
||
public int GetActiveModeId() | ||
{ | ||
return ActiveCustomMode; | ||
} | ||
|
||
public int GetActiveModeRemainingTime() | ||
{ | ||
return RemainingTime; | ||
} | ||
|
||
public Dictionary<string, ModeData> GetCustomModes() | ||
{ | ||
return CustomModes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
12 changes: 10 additions & 2 deletions
12
source/Common/Globals.cs → source/Deathmatch/Common/Globals.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.