-
Notifications
You must be signed in to change notification settings - Fork 44
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
There are so many changes that I don't know what to put in the title. #217
base: 13.1
Are you sure you want to change the base?
Conversation
# Player - Added `IEnumerable<Player> GetPlayers(RoleTypeId roleType)`: Gets a filtered collection of players based on their role type. - Added `IEnumerable<Player> GetPlayers(Team team)`: Gets a filtered collection of players based on their team. - Added `Player Get(Collider collider)` and `TryGet(Collider collider, out Player player)`: Methods to get or try getting the player associated with a collider. - Added `Player Get(Footprint footprint)` and `TryGet(Footprint footprint, out Player player)`: Methods to get or try getting the player associated with a footprint. - Added `Footprint Footprint`: Property to get the player's footprint. - Modified `DropAmmo(ItemType item, ushort amount, bool checkMinimals = false)`: Un-commented the method to allow the player to drop ammo. - Modified `SetRole(RoleTypeId newRole, RoleChangeReason reason = RoleChangeReason.RemoteAdmin)`: Added an optional parameter to specify the role spawn flags for the role change. # Facility doors - Added a method to try getting a `FacilityDoor` from a `DoorVariant`. - `TryGet(DoorVariant baseDoor, out FacilityDoor facilityDoor)`: Tries to get the `FacilityDoor` associated with the provided `DoorVariant`. If found, the `facilityDoor` parameter will be set; otherwise, it will be `null`. # ItemExtensions - Created an `ItemExtensions` class with various extension methods for `ItemType` and `Firearm`. - Added methods to check if an `ItemType` is of a specific category: `IsAmmo`, `IsFirearm`, `IsMedical`, `IsUtility`, `IsArmor`, `IsKeycard`, `IsThrowable`. - Implemented a method to get a `Firearm`'s `ItemBase` using `InventoryItemLoader`. - Added a method to get a random attachments code for a given `ItemType`. - Introduced a method to apply attachments to a `Firearm`. - Provided a method to apply a set of random attachments directly to a `Firearm`. - Implemented a method to attempt applying a player's attachments preferences to a `Firearm`.
Github is not putting the commit I uploaded SrLicht@fe1ba46 |
* Visual studio doing things
there are still a bunch of indented preprocessor directives |
/// </summary> | ||
/// <param name="firearm">The <see cref="Firearm"/> to which the attachments will be applied.</param> | ||
/// <param name="attachmentCode">The attachments code representing the set of attachments to apply.</param> | ||
public static void ApllyAttachments(this Firearm firearm, uint attachmentCode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should say ApplyAttachments
/// </summary> | ||
/// <param name="firearm">The <see cref="Firearm"/> to which random attachments will be applied.</param> | ||
/// <exception cref="ArgumentNullException">Thrown if the <paramref name="firearm"/> is null.</exception> | ||
public static void ApllyRandomAttachments(this Firearm firearm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply, couldn't you also call ApplyAttachment using the value from the GetRandomAttachmentsCode instead of copy-pasting the function.
} | ||
|
||
/// <summary> | ||
/// Applies the preferences of a <see cref="Player"/>'s attachments to a given <see cref="Firearm"/>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could "Tries to apply the pref...." be better in this case?
/// <param name="player">The <see cref="Player"/> whose attachments preferences are to be applied.</param> | ||
/// <param name="reloadWeapon">If this value is true, the weapon will be fully reloaded with ammunition when the attachment is applied.</param> | ||
/// <returns>Returns true if the weapon was modified with the attachments; otherwise, false.</returns> | ||
public static bool TryApplyAttachmentsPreferences(this Firearm firearm, Player player, bool reloadWeapon = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps ApplyAttachment could be used here to prevent copy-pasting the same code.
firearmStatusFlags |= FirearmStatusFlags.FlashlightEnabled; | ||
} | ||
|
||
if(reloadWeapon) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldnt this either force ammo to 0, or to the max, and not retain current ammunition?
FirearmStatusFlags firearmStatusFlags = FirearmStatusFlags.MagazineInserted; | ||
if (firearm.HasAdvantageFlag(AttachmentDescriptiveAdvantages.Flashlight)) | ||
{ | ||
firearmStatusFlags |= FirearmStatusFlags.FlashlightEnabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially check what the old state of the flashlight is, as this will always enable it if there is a flashlight, or we could pass an argument that decides to enable it, disable it, or leave it as is when a flashlight is present.
Perhaps an enum flag could be introduced to decide these modifications, to avoid having a lot of method parameters, please let me know what you think of that idea.
public static bool TryApplyAttachmentsPreferences(this Firearm firearm, Player player, bool reloadWeapon = false) | ||
{ | ||
if(firearm == null) | ||
throw new ArgumentNullException(nameof(Firearm), "Firearm is null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps returning false here could be better, as it is a "Try" style method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense I will do it
Player
IEnumerable<Player> GetPlayers(RoleTypeId roleType)
: Gets a filtered collection of players based on their role type.IEnumerable<Player> GetPlayers(Team team)
: Gets a filtered collection of players based on their team.Player Get(Collider collider)
andTryGet(Collider collider, out Player player)
: Methods to get or try getting the player associated with a collider.Player Get(Footprint footprint)
andTryGet(Footprint footprint, out Player player)
: Methods to get or try getting the player associated with a footprint.Footprint Footprint
: Property to get the player's footprint.DropAmmo(ItemType item, ushort amount, bool checkMinimals = false)
: Un-commented the method to allow the player to drop ammo.SetRole(RoleTypeId newRole, RoleChangeReason reason = RoleChangeReason.RemoteAdmin)
: Added an optional parameter to specify the role spawn flags for the role change.Facility doors
FacilityDoor
from aDoorVariant
.TryGet(DoorVariant baseDoor, out FacilityDoor facilityDoor)
: Tries to get theFacilityDoor
associated with the providedDoorVariant
. If found, thefacilityDoor
parameter will be set; otherwise, it will benull
.ItemExtensions
ItemExtensions
class with various extension methods forItemType
andFirearm
.ItemType
is of a specific category:IsAmmo
,IsFirearm
,IsMedical
,IsUtility
,IsArmor
,IsKeycard
,IsThrowable
.Firearm
'sItemBase
usingInventoryItemLoader
.ItemType
.Firearm
.Firearm
.Firearm
.Note: This was originally just going to add the Footprint to Player but then I started doing the Get methods and by the time I realized I had already made 1 new extension class and modified 3 classes.