Skip to content
Merged

1.1.0 #198

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
33 changes: 32 additions & 1 deletion LabApi/Events/Arguments/PlayerEvents/PlayerDeathEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using LabApi.Events.Arguments.Interfaces;
using LabApi.Features.Wrappers;
using PlayerRoles;
using PlayerStatsSystem;
using System;
using UnityEngine;

namespace LabApi.Events.Arguments.PlayerEvents;

Expand All @@ -16,11 +18,20 @@ public class PlayerDeathEventArgs : EventArgs, IPlayerEvent
/// <param name="player">The player who died.</param>
/// <param name="attacker">The player who caused the death.</param>
/// <param name="damageHandler">The damage that caused the death.</param>
public PlayerDeathEventArgs(ReferenceHub player, ReferenceHub? attacker, DamageHandlerBase damageHandler)
/// <param name="oldRole">The previous role of the player before death.</param>
/// <param name="oldPosition">The previous world position of the player before death.</param>
/// <param name="oldVelocity">The previous velocity of the player before death.</param>
/// <param name="oldCameraRotation">The previous world rotation of the players camera before death.</param>
public PlayerDeathEventArgs(ReferenceHub player, ReferenceHub? attacker, DamageHandlerBase damageHandler,
RoleTypeId oldRole, Vector3 oldPosition, Vector3 oldVelocity, Quaternion oldCameraRotation)
{
Player = Player.Get(player);
Attacker = Player.Get(attacker);
DamageHandler = damageHandler;
OldRole = oldRole;
OldPosition = oldPosition;
OldVelocity = oldVelocity;
OldCameraRotation = oldCameraRotation;
}

/// <summary>
Expand All @@ -37,4 +48,24 @@ public PlayerDeathEventArgs(ReferenceHub player, ReferenceHub? attacker, DamageH
/// Gets the damage that caused the death.
/// </summary>
public DamageHandlerBase DamageHandler { get; }

/// <summary>
/// Gets the role of the <see cref="Player"/> before they had died.
/// </summary>
public RoleTypeId OldRole { get; }

/// <summary>
/// Gets the player's position before they died.
/// </summary>
public Vector3 OldPosition { get; }

/// <summary>
/// Gets the player's velocity before they died.
/// </summary>
public Vector3 OldVelocity { get; }

/// <summary>
/// Gets the player's camera rotation before they died.
/// </summary>
public Quaternion OldCameraRotation { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ public class PlayerDroppedItemEventArgs : EventArgs, IPlayerEvent, IPickupEvent
/// </summary>
/// <param name="player">The player who dropped the item.</param>
/// <param name="pickup">The item pickup.</param>
public PlayerDroppedItemEventArgs(ReferenceHub player, ItemPickupBase pickup)
/// <param name="isThrowing">Whether the item will be thrown.</param>
public PlayerDroppedItemEventArgs(ReferenceHub player, ItemPickupBase pickup, bool isThrowing)
{
Player = Player.Get(player);
Pickup = Pickup.Get(pickup);
Throw = isThrowing;
}

/// <summary>
Expand All @@ -30,4 +32,9 @@ public PlayerDroppedItemEventArgs(ReferenceHub player, ItemPickupBase pickup)
/// Gets the item pickup.
/// </summary>
public Pickup Pickup { get; }

/// <summary>
/// Gets or sets whether the <see cref="Pickup"/> will be thrown by the <see cref="Player"/>.
/// </summary>
public bool Throw { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ public class PlayerDroppingItemEventArgs : EventArgs, ICancellableEvent, IItemEv
/// </summary>
/// <param name="player">The player who is dropping the item.</param>
/// <param name="item">The item being dropped.</param>
public PlayerDroppingItemEventArgs(ReferenceHub player, ItemBase item)
/// <param name="isThrowing">Whether the item will be thrown.</param>
public PlayerDroppingItemEventArgs(ReferenceHub player, ItemBase item, bool isThrowing)
{
IsAllowed = true;
Player = Player.Get(player);
Item = Item.Get(item);
Throw = isThrowing;
}

/// <summary>
Expand All @@ -32,6 +34,11 @@ public PlayerDroppingItemEventArgs(ReferenceHub player, ItemBase item)
/// </summary>
public Item Item { get; }

/// <summary>
/// Gets or sets whether the <see cref="Pickup"/> will be thrown by the <see cref="Player"/>.
/// </summary>
public bool Throw { get; set; }

/// <inheritdoc />
public bool IsAllowed { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ public class PlayerPlacedBloodEventArgs : EventArgs, IPlayerEvent
/// Initializes a new instance of the <see cref="PlayerPlacedBloodEventArgs"/> class.
/// </summary>
/// <param name="player">The player whose blood it is.</param>
/// <param name="attacker">The player that attacked.</param>
/// <param name="hitPosition">Position at which blood has been spawned.</param>
/// <param name="startRaycast">Position where the blood decal raycast will start for it to be properly attached to surface.</param>
public PlayerPlacedBloodEventArgs(ReferenceHub player, Vector3 hitPosition, Vector3 startRaycast)
public PlayerPlacedBloodEventArgs(ReferenceHub player, ReferenceHub attacker, Vector3 hitPosition, Vector3 startRaycast)
{
Player = Player.Get(player);
Attacker = Player.Get(attacker);
HitPosition = hitPosition;
RaycastStart = startRaycast;
}
Expand All @@ -28,6 +30,11 @@ public PlayerPlacedBloodEventArgs(ReferenceHub player, Vector3 hitPosition, Vect
/// </summary>
public Player Player { get; }

/// <summary>
/// Gets the player that attacked the <see cref="Player"/>.
/// </summary>
public Player Attacker { get; }

/// <summary>
/// Gets the position at which blood has been spawned.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ public class PlayerPlacingBloodEventArgs : EventArgs, IPlayerEvent, ICancellable
/// Initializes a new instance of the <see cref="PlayerPlacingBloodEventArgs"/> class.
/// </summary>
/// <param name="player">The player whose blood it is.</param>
/// <param name="attacker">The player that attacked.</param>
/// <param name="hitPosition">Position at which is blood being placed.</param>
/// <param name="startRaycast">Position where the blood decal raycast will start for it to be properly attached to surface.</param>
public PlayerPlacingBloodEventArgs(ReferenceHub player, Vector3 hitPosition, Vector3 startRaycast)
public PlayerPlacingBloodEventArgs(ReferenceHub player, ReferenceHub attacker, Vector3 hitPosition, Vector3 startRaycast)
{
IsAllowed = true;
Player = Player.Get(player);
Attacker = Player.Get(attacker);
HitPosition = hitPosition;
RaycastStart = startRaycast;
}
Expand All @@ -29,6 +31,11 @@ public PlayerPlacingBloodEventArgs(ReferenceHub player, Vector3 hitPosition, Vec
/// </summary>
public Player Player { get; }

/// <summary>
/// Gets the player that attacked the <see cref="Player"/>.
/// </summary>
public Player Attacker { get; }

/// <summary>
/// Gets the position at which is blood being placed.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ public class PlayerUnlockingGeneratorEventArgs : EventArgs, IPlayerEvent, IGener
/// </summary>
/// <param name="player">The player who is unlocking the generator.</param>
/// <param name="generator">The generator that the player is unlocking.</param>
public PlayerUnlockingGeneratorEventArgs(ReferenceHub player, Scp079Generator generator)
/// <param name="canOpen">Whether the generator can be opened.</param>
public PlayerUnlockingGeneratorEventArgs(ReferenceHub player, Scp079Generator generator, bool canOpen)
{
Player = Player.Get(player);
Generator = Generator.Get(generator);
IsAllowed = true;
CanOpen = canOpen;
}

/// <summary>
Expand All @@ -30,7 +32,14 @@ public PlayerUnlockingGeneratorEventArgs(ReferenceHub player, Scp079Generator ge
/// <inheritdoc />
public Generator Generator { get; }

/// <inheritdoc/>
/// <summary>
/// Gets whether the player can open the generator.
/// </summary>
public bool CanOpen { get; set; }

/// <summary>
/// Gets whether this event is allowed. Not allowing this event will not unlock the generator and no denied animation is played.
/// </summary>
public bool IsAllowed { get; set; }
}

48 changes: 48 additions & 0 deletions LabApi/Events/Arguments/Scp079Events/Scp079PingedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using LabApi.Events.Arguments.Interfaces;
using LabApi.Features.Enums;
using LabApi.Features.Wrappers;
using System;
using UnityEngine;

namespace LabApi.Events.Arguments.Scp079Events;

/// <summary>
/// Represents the arguments for the <see cref="Handlers.Scp079Events.Pinged"/> event.
/// </summary>
public class Scp079PingedEventArgs : EventArgs, IPlayerEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="Scp079PingedEventArgs"/> class.
/// </summary>
/// <param name="player">The SCP-079 player instance.</param>
/// <param name="position">The world position of the ping.</param>
/// <param name="normal">Normal vector for the ping.</param>
/// <param name="index">The index of the ping type.</param>
public Scp079PingedEventArgs(ReferenceHub player, Vector3 position, Vector3 normal, byte index)
{
Player = Player.Get(player);
Position = position;
Normal = normal;
PingType = (Scp079PingType)index;
}

/// <summary>
/// Gets the SCP-079 player instance.
/// </summary>
public Player Player { get; }

/// <summary>
/// Gets the world ping position.
/// </summary>
public Vector3 Position { get; }

/// <summary>
/// Gets the ping normal vector.
/// </summary>
public Vector3 Normal { get; }

/// <summary>
/// Gets the type of the ping used the icon.
/// </summary>
public Scp079PingType PingType { get; }
}
52 changes: 52 additions & 0 deletions LabApi/Events/Arguments/Scp079Events/Scp079PingingEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using LabApi.Events.Arguments.Interfaces;
using LabApi.Features.Enums;
using LabApi.Features.Wrappers;
using System;
using UnityEngine;

namespace LabApi.Events.Arguments.Scp079Events;

/// <summary>
/// Represents the arguments for the <see cref="Handlers.Scp079Events.Pinging"/> event.
/// </summary>
public class Scp079PingingEventArgs : EventArgs, IPlayerEvent, ICancellableEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="Scp079PingingEventArgs"/> class.
/// </summary>
/// <param name="player">The SCP-079 player instance.</param>
/// <param name="position">The world position of the ping.</param>
/// <param name="normal">Normal vector for the ping.</param>
/// <param name="index">The index of the ping type.</param>
public Scp079PingingEventArgs(ReferenceHub player, Vector3 position, Vector3 normal, byte index)
{
Player = Player.Get(player);
Position = position;
Normal = normal;
PingType = (Scp079PingType)index;
IsAllowed = true;
}

/// <summary>
/// Gets the SCP-079 player instance.
/// </summary>
public Player Player { get; }

/// <summary>
/// Gets or sets the world ping position.
/// </summary>
public Vector3 Position { get; set; }

/// <summary>
/// Gets or sets the ping normal vector.
/// </summary>
public Vector3 Normal { get; set; }

/// <summary>
/// Gets or sets the type of the ping used the icon.
/// </summary>
public Scp079PingType PingType { get; set; }

/// <inheritdoc/>
public bool IsAllowed { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;

namespace LabApi.Events.Arguments.ServerEvents;

/// <summary>
/// Contains the arguments for the <see cref="Handlers.ServerEvents.RoundEnding"/> event.
/// </summary>
public class RoundEndingConditionsCheckEventArgs : EventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="RoundEndingConditionsCheckEventArgs"/> class.
/// </summary>
/// <param name="canEnd">Whether the round end conditions are met</param>
public RoundEndingConditionsCheckEventArgs(bool canEnd)
{
CanEnd = canEnd;
}

/// <summary>
/// Gets or sets whether the round end conditions are met.
/// </summary>
public bool CanEnd { get; set; }
}
10 changes: 10 additions & 0 deletions LabApi/Events/Handlers/Scp079Events.EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,14 @@ public static partial class Scp079Events
/// Gets called when SCP-079 has used a tesla.
/// </summary>
public static event LabEventHandler<Scp079UsedTeslaEventArgs>? UsedTesla;

/// <summary>
/// Gets called when SCP-079 is using ping ability.
/// </summary>
public static event LabEventHandler<Scp079PingingEventArgs>? Pinging;

/// <summary>
/// Gets called when SCP-079 used ping ability.
/// </summary>
public static event LabEventHandler<Scp079PingedEventArgs>? Pinged;
}
5 changes: 5 additions & 0 deletions LabApi/Events/Handlers/ServerEvents.EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public static partial class ServerEvents
/// </summary>
public static event LabEventHandler? RoundRestarted;

/// <summary>
/// Gets called when round end conditions are checked.
/// </summary>
public static event LabEventHandler<RoundEndingConditionsCheckEventArgs>? RoundEndingConditionsCheck;

/// <summary>
/// Gets called when the round is ending.
/// </summary>
Expand Down
44 changes: 44 additions & 0 deletions LabApi/Features/Enums/Scp079PingType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using LabApi.Features.Wrappers;

namespace LabApi.Features.Enums;

/// <summary>
/// Enum used for type of the ping.
/// </summary>
public enum Scp079PingType : byte
{
/// <summary>
/// <see cref="Wrappers.Generator"/> ping.
/// </summary>
Generator = 0,

/// <summary>
/// <see cref="ExplosiveGrenadeProjectile"/> and <see cref="FlashbangProjectile"/> pings.
/// </summary>
Projectile = 1,

/// <summary>
/// Micro-HID ping.
/// </summary>
MicroHid = 2,

/// <summary>
/// <see cref="Player"/> human role ping.
/// </summary>
Human = 3,

/// <summary>
/// <see cref="Wrappers.Elevator"/> ping.
/// </summary>
Elevator = 4,

/// <summary>
/// <see cref="Wrappers.Door"/> ping.
/// </summary>
Door = 5,

/// <summary>
/// Default "i" icon ping.
/// </summary>
Default = 6,
}
Loading