-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(server): OnWeaponDamageEvent and WeaponDamageResponse (#40)
* refactor(server): OnWeaponDamageEvent and WeaponDamageResponse * refactor(server): OnWeaponDamageEvent and WeaponDamageResponse * refactor(server): OnWeaponDamageEvent and WeaponDamageResponse
- Loading branch information
Showing
2 changed files
with
77 additions
and
28 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
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,6 +1,21 @@ | ||
namespace AltV.Net.Data; | ||
|
||
public record WeaponDamageResponse(bool notCancel, uint? Damage) { | ||
public static implicit operator WeaponDamageResponse(bool val) => new WeaponDamageResponse(val, null); | ||
public static implicit operator WeaponDamageResponse(uint val) => new WeaponDamageResponse(true, val); | ||
}; | ||
/// <summary> | ||
/// Represents the response to a weapon damage event, indicating whether the damage is processed and the amount of damage. | ||
/// </summary> | ||
public record WeaponDamageResponse(bool Cancel, uint? Damage) | ||
{ | ||
/// <summary> | ||
/// Implicit conversion from a boolean value to <see cref="WeaponDamageResponse"/>. | ||
/// Sets <see cref="Cancel"/> to the specified value and <see cref="Damage"/> to null. | ||
/// </summary> | ||
/// <param name="cancel">Indicates whether the damage is processed.</param> | ||
public static implicit operator WeaponDamageResponse(bool cancel) => new(cancel, null); | ||
|
||
/// <summary> | ||
/// Implicit conversion from an uint value to <see cref="WeaponDamageResponse"/>. | ||
/// Sets <see cref="Cancel"/> to true and <see cref="Damage"/> to the specified value. | ||
/// </summary> | ||
/// <param name="damage">The amount of damage.</param> | ||
public static implicit operator WeaponDamageResponse(uint damage) => new(false, damage); | ||
} |