-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add hud string method and code docs for modifiers
- Loading branch information
Showing
6 changed files
with
128 additions
and
17 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 |
---|---|---|
|
@@ -45,4 +45,4 @@ protected override void OnClick() | |
PlayerControl.LocalPlayer.RpcRemoveModifier<CaptainModifier>(); | ||
} | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,14 +1,74 @@ | ||
namespace MiraAPI.Modifiers; | ||
|
||
/// <summary> | ||
/// Base class for all modifiers. | ||
/// </summary> | ||
public abstract class BaseModifier | ||
{ | ||
/// <summary> | ||
/// Gets the player that the modifier is attached to. | ||
/// </summary> | ||
public PlayerControl? Player { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the modifier id. | ||
/// </summary> | ||
public uint ModifierId { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the modifier name. | ||
/// </summary> | ||
public abstract string ModifierName { get; } | ||
|
||
/// <summary> | ||
/// Gets a value indicating whether the modifier is hidden on the UI. | ||
/// </summary> | ||
public virtual bool HideOnUi => false; | ||
public PlayerControl Player { get; internal set; } | ||
public uint ModifierId { get; internal set; } | ||
public virtual void OnActivate() { } | ||
public virtual void OnDeactivate() { } | ||
public virtual void Update() { } | ||
public virtual void FixedUpdate() { } | ||
public virtual void OnDeath() { } | ||
public virtual bool CanVent() => Player.Data.Role.CanVent; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the HUD information for this modifier. Defaults to the modifier name. Does nothing if <see cref="HideOnUi"/> is true. | ||
/// </summary> | ||
/// <returns>The information string for the HUD.</returns> | ||
public virtual string GetHudString() => ModifierName; | ||
|
||
/// <summary> | ||
/// Called when the modifier is activated. | ||
/// </summary> | ||
public virtual void OnActivate() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Called when the modifier is deactivated. | ||
/// </summary> | ||
public virtual void OnDeactivate() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Called when the modifier is updated. Attached to the ModifierComponent's Update method. | ||
/// </summary> | ||
public virtual void Update() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Called when the modifier is updated. Attached to the ModifierComponent's FixedUpdate method. | ||
/// </summary> | ||
public virtual void FixedUpdate() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Called when the player dies. | ||
/// </summary> | ||
public virtual void OnDeath() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether the player can vent. | ||
/// </summary> | ||
/// <returns>True if the player can vent, false otherwise.</returns> | ||
public virtual bool CanVent() => Player?.Data.Role.CanVent == true; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,26 @@ | ||
namespace MiraAPI.Modifiers.Types; | ||
|
||
/// <summary> | ||
/// The base class for a game modifier. Game modifiers are applied at the start of the game on top of the player's role. | ||
/// </summary> | ||
public abstract class GameModifier : BaseModifier | ||
{ | ||
/// <summary> | ||
/// Gets the chance of the modifier being assigned to a player. | ||
/// </summary> | ||
/// <returns>An int value between 0 and 100 representing percent.</returns> | ||
public abstract int GetAssignmentChance(); | ||
|
||
/// <summary> | ||
/// Gets the amount of players that can have this modifier in a game. | ||
/// </summary> | ||
/// <returns>An int value greater than or equal to zero.</returns> | ||
public abstract int GetAmountPerGame(); | ||
|
||
/// <summary> | ||
/// Determines whether the modifier is valid on a role. | ||
/// </summary> | ||
/// <param name="role">The role to be checked.</param> | ||
/// <returns>True if the modifier is valid on the role, otherwise false.</returns> | ||
public virtual bool IsModifierValidOn(RoleBehaviour role) => true; | ||
} | ||
} |
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