From e79a828095b4c651b1f9376cdd4fba5c424800e2 Mon Sep 17 00:00:00 2001 From: brayden-dowson <88667957+brayden-dowson@users.noreply.github.com> Date: Tue, 20 May 2025 04:08:55 +0930 Subject: [PATCH 1/5] Adds throw propertly to Item EventsArgs (#246) --- .../Arguments/PlayerEvents/PlayerDroppedItemEventArgs.cs | 9 ++++++++- .../PlayerEvents/PlayerDroppingItemEventArgs.cs | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerDroppedItemEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerDroppedItemEventArgs.cs index b6f17fd0..9dd3ff9e 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerDroppedItemEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerDroppedItemEventArgs.cs @@ -15,10 +15,12 @@ public class PlayerDroppedItemEventArgs : EventArgs, IPlayerEvent, IPickupEvent /// /// The player who dropped the item. /// The item pickup. - public PlayerDroppedItemEventArgs(ReferenceHub player, ItemPickupBase pickup) + /// Whether the item will be thrown. + public PlayerDroppedItemEventArgs(ReferenceHub player, ItemPickupBase pickup, bool isThrowing) { Player = Player.Get(player); Pickup = Pickup.Get(pickup); + Throw = isThrowing; } /// @@ -30,4 +32,9 @@ public PlayerDroppedItemEventArgs(ReferenceHub player, ItemPickupBase pickup) /// Gets the item pickup. /// public Pickup Pickup { get; } + + /// + /// Gets or sets whether the will be thrown by the . + /// + public bool Throw { get; set; } } \ No newline at end of file diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerDroppingItemEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerDroppingItemEventArgs.cs index 3ae57892..dc5f3e4d 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerDroppingItemEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerDroppingItemEventArgs.cs @@ -15,11 +15,13 @@ public class PlayerDroppingItemEventArgs : EventArgs, ICancellableEvent, IItemEv /// /// The player who is dropping the item. /// The item being dropped. - public PlayerDroppingItemEventArgs(ReferenceHub player, ItemBase item) + /// Whether the item will be thrown. + public PlayerDroppingItemEventArgs(ReferenceHub player, ItemBase item, bool isThrowing) { IsAllowed = true; Player = Player.Get(player); Item = Item.Get(item); + Throw = isThrowing; } /// @@ -32,6 +34,11 @@ public PlayerDroppingItemEventArgs(ReferenceHub player, ItemBase item) /// public Item Item { get; } + /// + /// Gets or sets whether the will be thrown by the . + /// + public bool Throw { get; set; } + /// public bool IsAllowed { get; set; } } \ No newline at end of file From 0bbdeee431b8d09db6b1e24434d399daec148e48 Mon Sep 17 00:00:00 2001 From: brayden-dowson <88667957+brayden-dowson@users.noreply.github.com> Date: Tue, 20 May 2025 07:48:56 +0930 Subject: [PATCH 2/5] Added more properties to PlayerDeath event arg (#241) * Added OldRole to PlayerDeath event arg * docs * more properties * Apply suggestions from code review --------- Co-authored-by: Beryl <10091181+SebasCapo@users.noreply.github.com> --- .../PlayerEvents/PlayerDeathEventArgs.cs | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerDeathEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerDeathEventArgs.cs index b32a0366..d58359eb 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerDeathEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerDeathEventArgs.cs @@ -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; @@ -16,11 +18,20 @@ public class PlayerDeathEventArgs : EventArgs, IPlayerEvent /// The player who died. /// The player who caused the death. /// The damage that caused the death. - public PlayerDeathEventArgs(ReferenceHub player, ReferenceHub? attacker, DamageHandlerBase damageHandler) + /// The previous role of the player before death. + /// The previous world position of the player before death. + /// The previous velocity of the player before death. + /// The previous world rotation of the players camera before death. + 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; } /// @@ -37,4 +48,24 @@ public PlayerDeathEventArgs(ReferenceHub player, ReferenceHub? attacker, DamageH /// Gets the damage that caused the death. /// public DamageHandlerBase DamageHandler { get; } + + /// + /// Gets the role of the before they had died. + /// + public RoleTypeId OldRole { get; } + + /// + /// Gets the player's position before they died. + /// + public Vector3 OldPosition { get; } + + /// + /// Gets the player's velocity before they died. + /// + public Vector3 OldVelocity { get; } + + /// + /// Gets the player's camera rotation before they died. + /// + public Quaternion OldCameraRotation { get; } } \ No newline at end of file From c554b39bf0ea11165782d9d3db9f2f3cbe7f1774 Mon Sep 17 00:00:00 2001 From: brayden-dowson <88667957+brayden-dowson@users.noreply.github.com> Date: Tue, 20 May 2025 07:52:14 +0930 Subject: [PATCH 3/5] Adds attacker player to placed blood event (#239) --- .../Arguments/PlayerEvents/PlayerPlacedBloodEventArgs.cs | 9 ++++++++- .../PlayerEvents/PlayerPlacingBloodEventArgs.cs | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerPlacedBloodEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerPlacedBloodEventArgs.cs index 344c74a2..e4385b58 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerPlacedBloodEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerPlacedBloodEventArgs.cs @@ -14,11 +14,13 @@ public class PlayerPlacedBloodEventArgs : EventArgs, IPlayerEvent /// Initializes a new instance of the class. /// /// The player whose blood it is. + /// The player that attacked. /// Position at which blood has been spawned. /// Position where the blood decal raycast will start for it to be properly attached to surface. - 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; } @@ -28,6 +30,11 @@ public PlayerPlacedBloodEventArgs(ReferenceHub player, Vector3 hitPosition, Vect /// public Player Player { get; } + /// + /// Gets the player that attacked the . + /// + public Player Attacker { get; } + /// /// Gets the position at which blood has been spawned. /// diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerPlacingBloodEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerPlacingBloodEventArgs.cs index 26bcf50d..cf28fff4 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerPlacingBloodEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerPlacingBloodEventArgs.cs @@ -14,12 +14,14 @@ public class PlayerPlacingBloodEventArgs : EventArgs, IPlayerEvent, ICancellable /// Initializes a new instance of the class. /// /// The player whose blood it is. + /// The player that attacked. /// Position at which is blood being placed. /// Position where the blood decal raycast will start for it to be properly attached to surface. - 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; } @@ -29,6 +31,11 @@ public PlayerPlacingBloodEventArgs(ReferenceHub player, Vector3 hitPosition, Vec /// public Player Player { get; } + /// + /// Gets the player that attacked the . + /// + public Player Attacker { get; } + /// /// Gets the position at which is blood being placed. /// From 35b8b80936aa2c9013247a59a765745559643816 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 6 Jun 2025 01:31:08 +0200 Subject: [PATCH 4/5] Playerscale + events (#244) * Scale * Added chaos and surface pass keycard to the keycard item register * Added CanOpen to UnlockingGenerator event Added Scp079Pinging/ed event Added RoundEndingConditionsCheck event Added permisisosn to the keycard wrapper * PingType to enum namespace * Ping to enum, comments --- .../PlayerUnlockingGeneratorEventArgs.cs | 13 ++++- .../Scp079Events/Scp079PingedEventArgs.cs | 48 +++++++++++++++++ .../Scp079Events/Scp079PingingEventArgs.cs | 52 +++++++++++++++++++ .../RoundEndingConditionsCheckEventArgs.cs | 23 ++++++++ .../Handlers/Scp079Events.EventHandlers.cs | 10 ++++ .../Handlers/ServerEvents.EventHandlers.cs | 5 ++ LabApi/Features/Enums/Scp079PingType.cs | 44 ++++++++++++++++ .../Features/Wrappers/Facility/Doors/Door.cs | 3 +- LabApi/Features/Wrappers/Items/Item.cs | 2 + LabApi/Features/Wrappers/Items/KeycardItem.cs | 14 ++++- LabApi/Features/Wrappers/Players/Player.cs | 22 ++++++++ 11 files changed, 230 insertions(+), 6 deletions(-) create mode 100644 LabApi/Events/Arguments/Scp079Events/Scp079PingedEventArgs.cs create mode 100644 LabApi/Events/Arguments/Scp079Events/Scp079PingingEventArgs.cs create mode 100644 LabApi/Events/Arguments/ServerEvents/RoundEndingConditionsCheckEventArgs.cs create mode 100644 LabApi/Features/Enums/Scp079PingType.cs diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerUnlockingGeneratorEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerUnlockingGeneratorEventArgs.cs index 57794b3f..9cb18a10 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerUnlockingGeneratorEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerUnlockingGeneratorEventArgs.cs @@ -15,11 +15,13 @@ public class PlayerUnlockingGeneratorEventArgs : EventArgs, IPlayerEvent, IGener /// /// The player who is unlocking the generator. /// The generator that the player is unlocking. - public PlayerUnlockingGeneratorEventArgs(ReferenceHub player, Scp079Generator generator) + /// Whether the generator can be opened. + public PlayerUnlockingGeneratorEventArgs(ReferenceHub player, Scp079Generator generator, bool canOpen) { Player = Player.Get(player); Generator = Generator.Get(generator); IsAllowed = true; + CanOpen = canOpen; } /// @@ -30,7 +32,14 @@ public PlayerUnlockingGeneratorEventArgs(ReferenceHub player, Scp079Generator ge /// public Generator Generator { get; } - /// + /// + /// Gets whether the player can open the generator. + /// + public bool CanOpen { get; set; } + + /// + /// Gets whether this event is allowed. Not allowing this event will not unlock the generator and no denied animation is played. + /// public bool IsAllowed { get; set; } } diff --git a/LabApi/Events/Arguments/Scp079Events/Scp079PingedEventArgs.cs b/LabApi/Events/Arguments/Scp079Events/Scp079PingedEventArgs.cs new file mode 100644 index 00000000..19b49334 --- /dev/null +++ b/LabApi/Events/Arguments/Scp079Events/Scp079PingedEventArgs.cs @@ -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; + +/// +/// Represents the arguments for the event. +/// +public class Scp079PingedEventArgs : EventArgs, IPlayerEvent +{ + /// + /// Initializes a new instance of the class. + /// + /// The SCP-079 player instance. + /// The world position of the ping. + /// Normal vector for the ping. + /// The index of the ping type. + public Scp079PingedEventArgs(ReferenceHub player, Vector3 position, Vector3 normal, byte index) + { + Player = Player.Get(player); + Position = position; + Normal = normal; + PingType = (Scp079PingType)index; + } + + /// + /// Gets the SCP-079 player instance. + /// + public Player Player { get; } + + /// + /// Gets the world ping position. + /// + public Vector3 Position { get; } + + /// + /// Gets the ping normal vector. + /// + public Vector3 Normal { get; } + + /// + /// Gets the type of the ping used the icon. + /// + public Scp079PingType PingType { get; } +} diff --git a/LabApi/Events/Arguments/Scp079Events/Scp079PingingEventArgs.cs b/LabApi/Events/Arguments/Scp079Events/Scp079PingingEventArgs.cs new file mode 100644 index 00000000..f27502db --- /dev/null +++ b/LabApi/Events/Arguments/Scp079Events/Scp079PingingEventArgs.cs @@ -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; + +/// +/// Represents the arguments for the event. +/// +public class Scp079PingingEventArgs : EventArgs, IPlayerEvent, ICancellableEvent +{ + /// + /// Initializes a new instance of the class. + /// + /// The SCP-079 player instance. + /// The world position of the ping. + /// Normal vector for the ping. + /// The index of the ping type. + public Scp079PingingEventArgs(ReferenceHub player, Vector3 position, Vector3 normal, byte index) + { + Player = Player.Get(player); + Position = position; + Normal = normal; + PingType = (Scp079PingType)index; + IsAllowed = true; + } + + /// + /// Gets the SCP-079 player instance. + /// + public Player Player { get; } + + /// + /// Gets or sets the world ping position. + /// + public Vector3 Position { get; set; } + + /// + /// Gets or sets the ping normal vector. + /// + public Vector3 Normal { get; set; } + + /// + /// Gets or sets the type of the ping used the icon. + /// + public Scp079PingType PingType { get; set; } + + /// + public bool IsAllowed { get; set; } +} diff --git a/LabApi/Events/Arguments/ServerEvents/RoundEndingConditionsCheckEventArgs.cs b/LabApi/Events/Arguments/ServerEvents/RoundEndingConditionsCheckEventArgs.cs new file mode 100644 index 00000000..4ddd004b --- /dev/null +++ b/LabApi/Events/Arguments/ServerEvents/RoundEndingConditionsCheckEventArgs.cs @@ -0,0 +1,23 @@ +using System; + +namespace LabApi.Events.Arguments.ServerEvents; + +/// +/// Contains the arguments for the event. +/// +public class RoundEndingConditionsCheckEventArgs : EventArgs +{ + /// + /// Initializes a new instance of the class. + /// + /// Whether the round end conditions are met + public RoundEndingConditionsCheckEventArgs(bool canEnd) + { + CanEnd = canEnd; + } + + /// + /// Gets or sets whether the round end conditions are met. + /// + public bool CanEnd { get; set; } +} diff --git a/LabApi/Events/Handlers/Scp079Events.EventHandlers.cs b/LabApi/Events/Handlers/Scp079Events.EventHandlers.cs index d3820f8e..43b2097e 100644 --- a/LabApi/Events/Handlers/Scp079Events.EventHandlers.cs +++ b/LabApi/Events/Handlers/Scp079Events.EventHandlers.cs @@ -116,4 +116,14 @@ public static partial class Scp079Events /// Gets called when SCP-079 has used a tesla. /// public static event LabEventHandler? UsedTesla; + + /// + /// Gets called when SCP-079 is using ping ability. + /// + public static event LabEventHandler? Pinging; + + /// + /// Gets called when SCP-079 used ping ability. + /// + public static event LabEventHandler? Pinged; } \ No newline at end of file diff --git a/LabApi/Events/Handlers/ServerEvents.EventHandlers.cs b/LabApi/Events/Handlers/ServerEvents.EventHandlers.cs index ef5066ec..7c8ea582 100644 --- a/LabApi/Events/Handlers/ServerEvents.EventHandlers.cs +++ b/LabApi/Events/Handlers/ServerEvents.EventHandlers.cs @@ -17,6 +17,11 @@ public static partial class ServerEvents /// public static event LabEventHandler? RoundRestarted; + /// + /// Gets called when round end conditions are checked. + /// + public static event LabEventHandler? RoundEndingConditionsCheck; + /// /// Gets called when the round is ending. /// diff --git a/LabApi/Features/Enums/Scp079PingType.cs b/LabApi/Features/Enums/Scp079PingType.cs new file mode 100644 index 00000000..9060ef6d --- /dev/null +++ b/LabApi/Features/Enums/Scp079PingType.cs @@ -0,0 +1,44 @@ +using LabApi.Features.Wrappers; + +namespace LabApi.Features.Enums; + +/// +/// Enum used for type of the ping. +/// +public enum Scp079PingType : byte +{ + /// + /// ping. + /// + Generator = 0, + + /// + /// and pings. + /// + Projectile = 1, + + /// + /// Micro-HID ping. + /// + MicroHid = 2, + + /// + /// human role ping. + /// + Human = 3, + + /// + /// ping. + /// + Elevator = 4, + + /// + /// ping. + /// + Door = 5, + + /// + /// Default "i" icon ping. + /// + Default = 6, +} diff --git a/LabApi/Features/Wrappers/Facility/Doors/Door.cs b/LabApi/Features/Wrappers/Facility/Doors/Door.cs index 14bddcb2..6e2c6ff5 100644 --- a/LabApi/Features/Wrappers/Facility/Doors/Door.cs +++ b/LabApi/Features/Wrappers/Facility/Doors/Door.cs @@ -1,5 +1,4 @@ using Generators; -using Hazards; using Interactables.Interobjects; using Interactables.Interobjects.DoorUtils; using LabApi.Features.Enums; @@ -143,7 +142,7 @@ internal virtual void OnRemove() /// /// Gets the rooms which have this door. /// - public RoomIdentifier[] Rooms => Base.Rooms; + public Room[] Rooms => Base.Rooms.Select(Room.Get).ToArray(); /// /// Gets the zone in which this door is. diff --git a/LabApi/Features/Wrappers/Items/Item.cs b/LabApi/Features/Wrappers/Items/Item.cs index c0c32280..6cb82c72 100644 --- a/LabApi/Features/Wrappers/Items/Item.cs +++ b/LabApi/Features/Wrappers/Items/Item.cs @@ -65,6 +65,8 @@ internal static void Initialize() Register(x => new BodyArmorItem(x)); Register(x => new ThrowableItem(x)); Register(x => new KeycardItem(x)); + Register(x => new KeycardItem(x)); + Register(x => new KeycardItem(x)); Register(x => new MicroHIDItem(x)); } diff --git a/LabApi/Features/Wrappers/Items/KeycardItem.cs b/LabApi/Features/Wrappers/Items/KeycardItem.cs index cd605b66..f6ba7f73 100644 --- a/LabApi/Features/Wrappers/Items/KeycardItem.cs +++ b/LabApi/Features/Wrappers/Items/KeycardItem.cs @@ -51,6 +51,16 @@ internal override void OnRemove() /// public new BaseKeycardItem Base { get; } + /// + /// Gets the of the keycard. + /// + public DoorPermissionFlags Permissions => Base.GetPermissions(null); + + /// + /// Gets the of the keycard which represent the tiers shown on the keycard. + /// + public KeycardLevels Levels => new KeycardLevels(Permissions); + #region Custom Keycards /// @@ -140,8 +150,8 @@ internal override void OnRemove() if (detailBase is not ICustomizableDetail customizableDetail) continue; - customizableDetail.SetArguments(new ArraySegment(args, index, customizableDetail.CustomizablePropertiesAmount)); - index += customizableDetail.CustomizablePropertiesAmount; + customizableDetail.SetArguments(new ArraySegment(args, index, customizableDetail.CustomizablePropertiesAmount)); + index += customizableDetail.CustomizablePropertiesAmount; } return (KeycardItem?)targetPlayer.AddItem(itemType); diff --git a/LabApi/Features/Wrappers/Players/Player.cs b/LabApi/Features/Wrappers/Players/Player.cs index d6bca3d0..b3592af2 100644 --- a/LabApi/Features/Wrappers/Players/Player.cs +++ b/LabApi/Features/Wrappers/Players/Player.cs @@ -754,6 +754,28 @@ public Vector2 LookRotation set => ReferenceHub.TryOverrideRotation(value); } + /// + /// Gets or sets player's scale. Player's role must be for it to take effect.
+ /// Vertical scale is not linear as the model's origin and scaling is done from player's feet. + ///
+ public Vector3 Scale + { + get + { + if (ReferenceHub.roleManager.CurrentRole is not IFpcRole fpcRole) + return Vector3.zero; + + return fpcRole.FpcModule.Motor.ScaleController.Scale; + } + set + { + if (ReferenceHub.roleManager.CurrentRole is not IFpcRole fpcRole) + return; + + fpcRole.FpcModule.Motor.ScaleController.Scale = value; + } + } + /// /// Gets or sets player's remaining stamina (min = 0, max = 1). /// From 3206e28df5cba879b6a294f1dbbf83692e238226 Mon Sep 17 00:00:00 2001 From: Beryl <10091181+SebasCapo@users.noreply.github.com> Date: Sun, 8 Jun 2025 21:33:12 -0300 Subject: [PATCH 5/5] 1.1.0 Version Bump --- LabApi/LabApi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LabApi/LabApi.csproj b/LabApi/LabApi.csproj index d5c4a3b7..0a4ab084 100644 --- a/LabApi/LabApi.csproj +++ b/LabApi/LabApi.csproj @@ -6,7 +6,7 @@ x64 12.0 - 1.0.2 + 1.1.0 LabApi Northwood.LabAPI