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

[Resonance] More Custom Modules Examples & Small Command Fixes #2783

Merged
merged 1 commit into from
Oct 7, 2024
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
2 changes: 1 addition & 1 deletion Exiled.CustomModules/API/Commands/CustomTeams/Spawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
return false;
}

if (!CustomTeam.TryGet(arguments.At(0), out CustomTeam team) && (!uint.TryParse(arguments.At(0), out uint id) || !CustomTeam.TryGet(id, out team)) && team is null)
if (!uint.TryParse(arguments.At(0), out uint id) || (!CustomTeam.TryGet(id, out CustomTeam team) && team is null))
{
response = $"Custom team {arguments.At(0)} not found!";
return false;
Expand Down
2 changes: 1 addition & 1 deletion Exiled.CustomModules/API/Commands/Gamemodes/Start.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
return false;
}

if (CustomGameMode.TryGet(arguments.At(0), out CustomGameMode gameMode) && (!uint.TryParse(arguments.At(0), out uint id) || !CustomGameMode.TryGet(id, out gameMode)) && gameMode is null)
if (!uint.TryParse(arguments.At(0), out uint id) || (!CustomGameMode.TryGet(id, out CustomGameMode gameMode) && gameMode is null))
{
response = $"Custom gamemode {arguments.At(0)} not found!";
return false;
Expand Down
22 changes: 22 additions & 0 deletions Exiled.Example/TestEscape/CustomEscapeScenarioType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// -----------------------------------------------------------------------
// <copyright file="CustomEscapeScenarioType.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Example.TestEscape
{
using Exiled.CustomModules.API.Enums;

/// <summary>
/// The custom escape scenario type.
/// </summary>
public class CustomEscapeScenarioType : UUEscapeScenarioType
{
/// <summary>
/// Initializes a new custom escape scenario id.
/// </summary>
public static readonly CustomEscapeScenarioType CustomScenario = new();
}
}
22 changes: 22 additions & 0 deletions Exiled.Example/TestEscape/CustomEscapeType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// -----------------------------------------------------------------------
// <copyright file="CustomEscapeType.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Example.TestEscape
{
using Exiled.CustomModules.API.Enums;

/// <summary>
/// The custom escape type.
/// </summary>
public class CustomEscapeType : UUCustomEscapeType
{
/// <summary>
/// Initializes a new custom escape id.
/// </summary>
public static readonly CustomEscapeType TestEscape = new();
}
}
42 changes: 42 additions & 0 deletions Exiled.Example/TestEscape/TestEscape.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// -----------------------------------------------------------------------
// <copyright file="TestEscape.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Example.TestEscape
{
using System.Collections.Generic;

using Exiled.API.Features;
using Exiled.CustomModules.API.Features.Attributes;
using Exiled.CustomModules.API.Features.CustomEscapes;
using PlayerRoles;

/// <inheritdoc />
[ModuleIdentifier]
public class TestEscape : CustomEscape<TestEscapeBehaviour>
{
/// <inheritdoc />
public override uint Id { get; set; } = CustomEscapeType.TestEscape;

/// <inheritdoc />
public override string Name { get; set; } = "Test Escape";

/// <inheritdoc />
public override bool IsEnabled { get; set; } = true;

/// <inheritdoc />
public override Dictionary<byte, Hint> Scenarios { get; set; } = new()
{
[1] = new Hint("Test Scenario"),
};

/// <inheritdoc />
public override List<EscapeSettings> Settings { get; set; } = new()
{
new EscapeSettings(true, RoleTypeId.FacilityGuard),
};
}
}
32 changes: 32 additions & 0 deletions Exiled.Example/TestEscape/TestEscapeBehaviour.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// -----------------------------------------------------------------------
// <copyright file="TestEscapeBehaviour.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Example.TestEscape
{
using Exiled.API.Features;
using Exiled.CustomModules.API.Enums;
using Exiled.CustomModules.API.Features.CustomEscapes;
using Exiled.CustomModules.Events.EventArgs.CustomEscapes;

/// <inheritdoc />
public class TestEscapeBehaviour : EscapeBehaviour
{
/// <inheritdoc />
protected override UUEscapeScenarioType CalculateEscapeScenario()
{
return CustomEscapeScenarioType.CustomScenario;
}

/// <inheritdoc />
protected override void OnEscaping(EscapingEventArgs ev)
{
base.OnEscaping(ev);

Log.ErrorWithContext($"Player {ev.Player.Nickname} is escaping");
}
}
}
26 changes: 26 additions & 0 deletions Exiled.Example/TestEscape/TestEscapeConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// -----------------------------------------------------------------------
// <copyright file="TestEscapeConfig.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Example.TestEscape
{
using Exiled.CustomModules.API.Features.Attributes;
using Exiled.CustomModules.API.Features.CustomEscapes;
using Exiled.CustomModules.API.Features.Generic;

/// <inheritdoc />
[ModuleIdentifier]
public class TestEscapeConfig : ModulePointer<CustomEscape>
{
/// <inheritdoc />
public override uint Id { get; set; } = CustomEscapeType.TestEscape;

/// <summary>
/// Gets or sets a integer value.
/// </summary>
public int Value { get; set; } = 10;
}
}
22 changes: 22 additions & 0 deletions Exiled.Example/TestGamemode/CustomGamemodeType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// -----------------------------------------------------------------------
// <copyright file="CustomGamemodeType.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Example.TestGamemode
{
using Exiled.CustomModules.API.Enums;

/// <summary>
/// The custom gamemode type.
/// </summary>
public class CustomGamemodeType : UUGameModeType
{
/// <summary>
/// Initializes a new custom gamemode id.
/// </summary>
public static readonly CustomGamemodeType TestGamemode = new();
}
}
48 changes: 48 additions & 0 deletions Exiled.Example/TestGamemode/TestGamemode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// -----------------------------------------------------------------------
// <copyright file="TestGamemode.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Example.TestGamemode
{
using System;

using Exiled.CustomModules.API.Features.Attributes;
using Exiled.CustomModules.API.Features.CustomGameModes;
using PlayerRoles;

/// <inheritdoc />
[ModuleIdentifier]
public class TestGamemode : CustomGameMode
{
/// <inheritdoc />
public override uint Id { get; set; } = CustomGamemodeType.TestGamemode;

/// <inheritdoc />
public override string Name { get; set; } = "Test Gamemode";

/// <inheritdoc />
public override bool IsEnabled { get; set; } = true;

/// <inheritdoc />
public override Type[] BehaviourComponents { get; } = { typeof(TestGamemodeGameState), typeof(TestGamemodePlayerState) };

/// <inheritdoc />
public override GameModeSettings Settings { get; set; } = new()
{
Automatic = false,
MinimumPlayers = 1,
MaximumPlayers = 5,
RejectExceedingPlayers = false,
IsRespawnEnabled = false,
IsTeamRespawnEnabled = false,
RestartRoundOnEnd = true,
IsDecontaminationEnabled = false,
IsWarheadEnabled = false,
IsWarheadInteractable = false,
SpawnableRoles = new[] { RoleTypeId.ClassD, RoleTypeId.Scientist },
};
}
}
26 changes: 26 additions & 0 deletions Exiled.Example/TestGamemode/TestGamemodeConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// -----------------------------------------------------------------------
// <copyright file="TestGamemodeConfig.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Example.TestGamemode
{
using Exiled.CustomModules.API.Features.Attributes;
using Exiled.CustomModules.API.Features.CustomGameModes;
using Exiled.CustomModules.API.Features.Generic;

/// <inheritdoc />
[ModuleIdentifier]
public class TestGamemodeConfig : ModulePointer<CustomGameMode>
{
/// <inheritdoc />
public override uint Id { get; set; } = CustomGamemodeType.TestGamemode;

/// <summary>
/// Gets or sets a integer value.
/// </summary>
public int Value { get; set; } = 10;
}
}
36 changes: 36 additions & 0 deletions Exiled.Example/TestGamemode/TestGamemodeGameState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// -----------------------------------------------------------------------
// <copyright file="TestGamemodeGameState.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Example.TestGamemode
{
using Exiled.API.Features;
using Exiled.CustomModules.API.Features.CustomGameModes;

/// <inheritdoc />
public class TestGamemodeGameState : GameState
{
/// <inheritdoc />
public override void Start(bool isForced = false)
{
Map.Broadcast(5, "Test Gamemode Started");
base.Start(isForced);
}

/// <inheritdoc />
public override void End(bool isForced = false)
{
Map.Broadcast(5, "Test Gamemode Ended");
base.End(isForced);
}

/// <inheritdoc />
protected override bool EvaluateEndingConditions()
{
return false;
}
}
}
16 changes: 16 additions & 0 deletions Exiled.Example/TestGamemode/TestGamemodePlayerState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// -----------------------------------------------------------------------
// <copyright file="TestGamemodePlayerState.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Example.TestGamemode
{
using Exiled.CustomModules.API.Features.CustomGameModes;

/// <inheritdoc />
public class TestGamemodePlayerState : PlayerState
{
}
}
5 changes: 5 additions & 0 deletions Exiled.Example/TestRole/CustomRoleType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@ public class CustomRoleType : UUCustomRoleType
/// Initializes a new custom role id.
/// </summary>
public static readonly CustomRoleType TestRole = new();

/// <summary>
/// Initializes a new custom role id.
/// </summary>
public static readonly CustomRoleType TestRole2 = new();
}
}
2 changes: 1 addition & 1 deletion Exiled.Example/TestRole/TestRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class TestRole : CustomRole<TestRoleBehaviour>
public override int MaxInstances { get; set; } = 1;

/// <inheritdoc />
public override Team[] TeamsOwnership { get; set; } = { Team.SCPs };
public override Team[] TeamsOwnership { get; set; } = { Team.ClassD };

/// <inheritdoc />
public override RoleTypeId AssignFromRole { get; set; } = RoleTypeId.ClassD;
Expand Down
Loading
Loading