diff --git a/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Camera.cs b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Camera.cs new file mode 100644 index 0000000..dbb5996 --- /dev/null +++ b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Camera.cs @@ -0,0 +1,68 @@ +namespace SecretAPI.Extensions.AdminToys; + +using LabApi.Features.Wrappers; +using UnityEngine; + +/// +/// Extensions for camera toys. +/// +public static partial class AdminToyExtensions +{ + extension(CameraToy toy) + { + /// + /// Modify the label of this . + /// + /// The label. + /// The modified . + public CameraToy WithLabel(string label) + { + toy.Label = label; + return toy; + } + + /// + /// Modify the room of this . + /// + /// The room. + /// The modified . + public CameraToy WithRoom(Room room) + { + toy.Room = room; + return toy; + } + + /// + /// Modify the vertical constrains of this . + /// + /// The constraints. + /// The modified . + public CameraToy WithVerticalConstraints(Vector2 constraint) + { + toy.VerticalConstraints = constraint; + return toy; + } + + /// + /// Modify the horizontal constrains of this . + /// + /// The constraints. + /// The modified . + public CameraToy WithHorizontalConstraints(Vector2 constraint) + { + toy.HorizontalConstraint = constraint; + return toy; + } + + /// + /// Modify the zoom constrains of this . + /// + /// The constraints. + /// The modified . + public CameraToy WithZoomConstraints(Vector2 constraint) + { + toy.ZoomConstraints = constraint; + return toy; + } + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Interactable.cs b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Interactable.cs new file mode 100644 index 0000000..e5394fe --- /dev/null +++ b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Interactable.cs @@ -0,0 +1,91 @@ +namespace SecretAPI.Extensions.AdminToys; + +using System; +using global::AdminToys; +using LabApi.Features.Wrappers; + +/// +/// Extensions for interactable toys. +/// +public static partial class AdminToyExtensions +{ + extension(InteractableToy toy) + { + /// + /// Call an when this is interacted with. + /// + /// The to run. + /// The modified . + public InteractableToy WhenInteracted(Action action) + { + toy.OnInteracted += action; + return toy; + } + + /// + /// Call an when this is being searched. + /// + /// The to run. + /// The modified . + public InteractableToy WhenSearching(Action action) + { + toy.OnSearching += action; + return toy; + } + + /// + /// Call an when this has been searched. + /// + /// The to run. + /// The modified . + public InteractableToy WhenSearched(Action action) + { + toy.OnSearched += action; + return toy; + } + + /// + /// Call an when this has had an aborted search. + /// + /// The to run. + /// The modified . + public InteractableToy WhenSearchAborted(Action action) + { + toy.OnSearchAborted += action; + return toy; + } + + /// + /// Modify the shape of this . + /// + /// The shape. + /// The modified . + public InteractableToy WithShape(InvisibleInteractableToy.ColliderShape shape) + { + toy.Shape = shape; + return toy; + } + + /// + /// Modify how long a user should interact with before triggering the event. + /// + /// The duration. + /// The modified . + public InteractableToy WithInteractionDuration(float duration) + { + toy.InteractionDuration = duration; + return toy; + } + + /// + /// Modify whether this can be interacted with. + /// + /// The lock state. + /// The modified . + public InteractableToy IsLocked(bool locked) + { + toy.IsLocked = locked; + return toy; + } + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Light.cs b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Light.cs new file mode 100644 index 0000000..fd4ff69 --- /dev/null +++ b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Light.cs @@ -0,0 +1,114 @@ +namespace SecretAPI.Extensions.AdminToys; + +using LabApi.Features.Wrappers; +using UnityEngine; + +/// +/// Extensions for Light Source Toys. +/// +public static partial class AdminToyExtensions +{ + extension(LightSourceToy toy) + { + /// + /// Modify the intensity of this . + /// + /// The intensity. + /// The modified . + public LightSourceToy WithIntensity(float intensity) + { + toy.Intensity = intensity; + return toy; + } + + /// + /// Modify the range of this . + /// + /// The range. + /// The modified . + public LightSourceToy WithRange(float range) + { + toy.Range = range; + return toy; + } + + /// + /// Modify the color of this . + /// + /// The color. + /// The modified . + public LightSourceToy WithColor(Color color) + { + toy.Color = color; + return toy; + } + + /// + /// Modify the shadow type of this . + /// + /// The shadow type. + /// The modified . + public LightSourceToy WithShadowType(LightShadows type) + { + toy.ShadowType = type; + return toy; + } + + /// + /// Modify the shadow strength of this . + /// + /// The strength. + /// The modified . + public LightSourceToy WithShadowStrength(float strength) + { + toy.ShadowStrength = strength; + return toy; + } + + /// + /// Modify the type of this . + /// + /// The type. + /// The modified . + public LightSourceToy WithType(LightType lightType) + { + toy.Type = lightType; + return toy; + } + + /// + /// Modify the shape of this . + /// + /// The shape. + /// The modified . +#pragma warning disable CS0618 // Type or member is obsolete + public LightSourceToy WithShape(LightShape shape) +#pragma warning restore CS0618 // Type or member is obsolete + { + toy.Shape = shape; + return toy; + } + + /// + /// Modify the spot angle of this . + /// + /// The angle. + /// The modified . + public LightSourceToy WithSpotAngle(float angle) + { + toy.SpotAngle = angle; + return toy; + } + + /// + /// Modify the inner spot angle of this . + /// + /// The angle. + /// The modified . + public LightSourceToy WithInnerSpotAngle(float angle) + { + toy.InnerSpotAngle = angle; + return toy; + } + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Primitive.cs b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Primitive.cs new file mode 100644 index 0000000..f7ff3c5 --- /dev/null +++ b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Primitive.cs @@ -0,0 +1,87 @@ +namespace SecretAPI.Extensions.AdminToys; + +using global::AdminToys; +using UnityEngine; +using PrimitiveObjectToy = LabApi.Features.Wrappers.PrimitiveObjectToy; + +/// +/// Extensions for primitive object toys. +/// +public static partial class AdminToyExtensions +{ + extension(PrimitiveObjectToy toy) + { + /// + /// Gets or sets a value indicating whether this is collidable. + /// + public bool Collidable + { + get => (toy.Flags & PrimitiveFlags.Collidable) == PrimitiveFlags.Collidable; + set => toy.Flags = value ? toy.Flags | PrimitiveFlags.Collidable : toy.Flags & ~PrimitiveFlags.Collidable; + } + + /// + /// Gets or sets a value indicating whether this is visible. + /// + public bool Visible + { + get => (toy.Flags & PrimitiveFlags.Visible) == PrimitiveFlags.Visible; + set => toy.Flags = value ? toy.Flags | PrimitiveFlags.Visible : toy.Flags & ~PrimitiveFlags.Visible; + } + + /// + /// Modify whether this is collidable. + /// + /// The collidable state. + /// The modified . + public PrimitiveObjectToy WithCollidable(bool collidable) + { + toy.Collidable = collidable; + return toy; + } + + /// + /// Modify whether this is visible. + /// + /// The visibility state. + /// The modified . + public PrimitiveObjectToy WithVisible(bool visible) + { + toy.Visible = visible; + return toy; + } + + /// + /// Modify the type of this . + /// + /// The type. + /// The modified . + public PrimitiveObjectToy WithType(PrimitiveType type) + { + toy.Type = type; + return toy; + } + + /// + /// Modify the color of this . + /// + /// The color. + /// The modified . + public PrimitiveObjectToy WithColor(Color color) + { + toy.Color = color; + return toy; + } + + /// + /// Modify the flags of this . + /// + /// The flags. + /// The modified . + public PrimitiveObjectToy WithFlags(PrimitiveFlags flags) + { + toy.Flags = flags; + return toy; + } + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Text.cs b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Text.cs new file mode 100644 index 0000000..0a3a743 --- /dev/null +++ b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Text.cs @@ -0,0 +1,35 @@ +namespace SecretAPI.Extensions.AdminToys; + +using LabApi.Features.Wrappers; +using UnityEngine; + +/// +/// Extension methods for text toys. +/// +public static partial class AdminToyExtensions +{ + extension(TextToy toy) + { + /// + /// Modify the text of this . + /// + /// The text. + /// The modified . + public TextToy WithText(string text) + { + toy.TextFormat = text; + return toy; + } + + /// + /// Modify the size of this . + /// + /// The size. + /// The modified . + public TextToy WithSize(Vector2 size) + { + toy.DisplaySize = size; + return toy; + } + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Waypoint.cs b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Waypoint.cs new file mode 100644 index 0000000..0e4e906 --- /dev/null +++ b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.Waypoint.cs @@ -0,0 +1,46 @@ +namespace SecretAPI.Extensions.AdminToys; + +using LabApi.Features.Wrappers; +using UnityEngine; + +/// +/// Extension methods for waypoint toys. +/// +public static partial class AdminToyExtensions +{ + extension(WaypointToy toy) + { + /// + /// Modify the bounds size of this . + /// + /// The size. + /// The modified . + public WaypointToy WithBoundsSize(Vector3 size) + { + toy.BoundsSize = size; + return toy; + } + + /// + /// Modify whether this has visible bounds. + /// + /// The visibility state. + /// The modified . + public WaypointToy WithVisualiseBounds(bool visible) + { + toy.VisualizeBounds = visible; + return toy; + } + + /// + /// Modify the priority bias of this . + /// + /// The bias. + /// The modified . + public WaypointToy WithPriorityBias(float bias) + { + toy.PriorityBias = bias; + return toy; + } + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/AdminToys/AdminToyExtensions.cs b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.cs new file mode 100644 index 0000000..68e3a73 --- /dev/null +++ b/SecretAPI/Extensions/AdminToys/AdminToyExtensions.cs @@ -0,0 +1,60 @@ +namespace SecretAPI.Extensions.AdminToys; + +using LabApi.Features.Wrappers; +using UnityEngine; +using CapybaraToy = LabApi.Features.Wrappers.CapybaraToy; + +/// +/// Extensions for admin toys. +/// +public static partial class AdminToyExtensions +{ + extension(T toy) + where T : AdminToy + { + /// + /// Modify the position of this . + /// + /// The position to change to. + /// The modified . + public T WithPosition(Vector3 pos) + { + toy.Position = pos; + return toy; + } + + /// + /// Modify the rotation of this . + /// + /// The rotation to change to. + /// The modified . + public T WithRotation(Quaternion rot) + { + toy.Rotation = rot; + return toy; + } + + /// + /// Modify the scale of this . + /// + /// The scale to change to. + /// The modified . + public T WithScale(Vector3 scale) + { + toy.Scale = scale; + return toy; + } + } + + /// + /// Updates whether the capybara has enabled colliders. + /// + /// The . + /// Whether the colliders are enabled. + /// The modified . + public static CapybaraToy WithCollidersEnabled(this CapybaraToy toy, bool enabled) + { + toy.CollidersEnabled = enabled; + return toy; + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/Items/ItemExtensions.Firearms.cs b/SecretAPI/Extensions/Items/ItemExtensions.Firearms.cs new file mode 100644 index 0000000..fbe50e6 --- /dev/null +++ b/SecretAPI/Extensions/Items/ItemExtensions.Firearms.cs @@ -0,0 +1,57 @@ +namespace SecretAPI.Extensions.Items; + +using LabApi.Features.Wrappers; + +/// +/// Extensions for firearms. +/// +public static partial class ItemExtensions +{ + extension(T item) + where T : FirearmItem + { + /// + /// Modifies the stored ammo in this . + /// + /// The ammo. + /// The modified . + public T WithStoredAmmo(int ammo) + { + item.StoredAmmo = ammo; + return item; + } + + /// + /// Modifies whether the magazine is inserted in this . + /// + /// Whether the magazine is inserted. + /// The modified . + public T WithMagazineInserted(bool magazineInserted) + { + item.MagazineInserted = magazineInserted; + return item; + } + + /// + /// Modifies whether the firearm is cocked in this . + /// + /// Whether the firearm is cocked. + /// The modified . + public T WithCocked(bool cocked) + { + item.Cocked = cocked; + return item; + } + + /// + /// Modifies the chambered ammo in this . + /// + /// The ammo. + /// The modified . + public T WithChamberedAmmo(int ammo) + { + item.ChamberedAmmo = ammo; + return item; + } + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/Items/ItemExtensions.MicroHID.cs b/SecretAPI/Extensions/Items/ItemExtensions.MicroHID.cs new file mode 100644 index 0000000..c2977a6 --- /dev/null +++ b/SecretAPI/Extensions/Items/ItemExtensions.MicroHID.cs @@ -0,0 +1,57 @@ +namespace SecretAPI.Extensions.Items; + +using InventorySystem.Items.MicroHID.Modules; +using LabApi.Features.Wrappers; + +/// +/// Extensions for Micro H.I.D. +/// +public static partial class ItemExtensions +{ + extension(MicroHIDItem item) + { + /// + /// Modify the energy of this . + /// + /// The energy. + /// The modified . + public MicroHIDItem WithEnergy(float energy) + { + item.Energy = energy; + return item; + } + + /// + /// Modify the broken state of this . + /// + /// Whether the item is broken or not. + /// The modified . + public MicroHIDItem WithBrokenState(bool brokenState) + { + item.IsBroken = brokenState; + return item; + } + + /// + /// Modify the phase of this . + /// + /// The phase. + /// The modified . + public MicroHIDItem WithPhase(MicroHidPhase phase) + { + item.Phase = phase; + return item; + } + + /// + /// Modify the firing mode of this . + /// + /// The firing mode. + /// The modified . + public MicroHIDItem WithFiringMode(MicroHidFiringMode mode) + { + item.FiringMode = mode; + return item; + } + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/Items/ItemExtensions.Scp127.cs b/SecretAPI/Extensions/Items/ItemExtensions.Scp127.cs new file mode 100644 index 0000000..1f1ba8c --- /dev/null +++ b/SecretAPI/Extensions/Items/ItemExtensions.Scp127.cs @@ -0,0 +1,35 @@ +namespace SecretAPI.Extensions.Items; + +using InventorySystem.Items.Firearms.Modules.Scp127; +using LabApi.Features.Wrappers; + +/// +/// Extensions for SCP-127. +/// +public static partial class ItemExtensions +{ + extension(Scp127Firearm item) + { + /// + /// Modifies the tier of this . + /// + /// The tier. + /// The modified . + public Scp127Firearm WithTier(Scp127Tier tier) + { + item.Tier = tier; + return item; + } + + /// + /// Modifies the experience of this . + /// + /// The experience. + /// The modified . + public Scp127Firearm WithExperience(float experience) + { + item.Experience = experience; + return item; + } + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/Items/ItemExtensions.Scp1509.cs b/SecretAPI/Extensions/Items/ItemExtensions.Scp1509.cs new file mode 100644 index 0000000..d78780a --- /dev/null +++ b/SecretAPI/Extensions/Items/ItemExtensions.Scp1509.cs @@ -0,0 +1,67 @@ +namespace SecretAPI.Extensions.Items; + +using LabApi.Features.Wrappers; + +/// +/// Extensions for SCP-1509. +/// +public static partial class ItemExtensions +{ + extension(Scp1509Item item) + { + /// + /// Modifies the shield regen rate of this . + /// + /// The rate. + /// The modified . + public Scp1509Item WithShieldRegenRate(float rate) + { + item.ShieldRegenRate = rate; + return item; + } + + /// + /// Modifies the shield decay rate of this . + /// + /// The rate. + /// The modified . + public Scp1509Item WithShieldDecayRate(float rate) + { + item.ShieldDecayRate = rate; + return item; + } + + /// + /// Modifies the unequip decay delay of this . + /// + /// The time to start decaying. + /// The modified . + public Scp1509Item WithUnequipDecayDelay(float time) + { + item.UnequipDecayDelay = time; + return item; + } + + /// + /// Modifies the revive cooldown of this . + /// + /// The cooldown. + /// The modified . + public Scp1509Item WithReviveCooldown(double cooldown) + { + item.ReviveCooldown = cooldown; + return item; + } + + /// + /// Modifies the equipped HS of this . + /// + /// The hume shield. + /// The modified . + public Scp1509Item WithEquippedHumeShield(float hs) + { + item.EquippedHS = hs; + return item; + } + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/Items/ItemExtensions.cs b/SecretAPI/Extensions/Items/ItemExtensions.cs new file mode 100644 index 0000000..ac671c9 --- /dev/null +++ b/SecretAPI/Extensions/Items/ItemExtensions.cs @@ -0,0 +1,21 @@ +namespace SecretAPI.Extensions.Items; + +using LabApi.Features.Wrappers; + +/// +/// Extensions for items. +/// +public static partial class ItemExtensions +{ + /// + /// Modifies the battery percentage of this . + /// + /// The . + /// The percentage. + /// The modified . + public static RadioItem WithBatteryPercent(this RadioItem item, byte battery) + { + item.BatteryPercent = battery; + return item; + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/Pickups/PickupExtensions.Grenades.cs b/SecretAPI/Extensions/Pickups/PickupExtensions.Grenades.cs new file mode 100644 index 0000000..152b6fa --- /dev/null +++ b/SecretAPI/Extensions/Pickups/PickupExtensions.Grenades.cs @@ -0,0 +1,86 @@ +namespace SecretAPI.Extensions.Pickups; + +using LabApi.Features.Wrappers; +using UnityEngine; + +/// +/// Extensions for grenade projectiles. +/// +public static partial class PickupExtensions +{ + extension(T pickup) + where T : TimedGrenadeProjectile + { + /// + /// Modifies the remaining time of this . + /// + /// The time. + /// The modified . + public T WithRemainingTime(double time) + { + pickup.RemainingTime = time; + return pickup; + } + } + + extension(ExplosiveGrenadeProjectile pickup) + { + /// + /// Modifies the max explosion radius of this . + /// + /// The radius. + /// The modified . + public ExplosiveGrenadeProjectile WithMaxRadius(float radius) + { + pickup.MaxRadius = radius; + return pickup; + } + + /// + /// Modifies the scp damage multiplier of this . + /// + /// The multiplier. + /// The modified . + public ExplosiveGrenadeProjectile WithScpDamageMultiplier(float multiplier) + { + pickup.ScpDamageMultiplier = multiplier; + return pickup; + } + } + + /// + /// Modifies the flash time of this . + /// + /// The flashbang. + /// The time. + /// The modified . + public static FlashbangProjectile WithBlindTime(this FlashbangProjectile pickup, float time) + { + pickup.BaseBlindTime = time; + return pickup; + } + + /// + /// Modifies the velocity of this . + /// + /// The SCP-018 instance. + /// The velocity. + /// The modified . + public static Scp018Projectile WithVelocity(this Scp018Projectile pickup, Vector3 velocity) + { + pickup.Velocity = velocity; + return pickup; + } + + /// + /// Modifies the lockdown duration of this . + /// + /// The SCP-2176 instance. + /// The duration. + /// The modified . + public static Scp2176Projectile WithLockdownDuration(this Scp2176Projectile pickup, float duration) + { + pickup.LockdownDuration = duration; + return pickup; + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/Pickups/PickupExtensions.Jailbird.cs b/SecretAPI/Extensions/Pickups/PickupExtensions.Jailbird.cs new file mode 100644 index 0000000..8f1aad2 --- /dev/null +++ b/SecretAPI/Extensions/Pickups/PickupExtensions.Jailbird.cs @@ -0,0 +1,46 @@ +namespace SecretAPI.Extensions.Pickups; + +using InventorySystem.Items.Jailbird; +using JailbirdPickup = LabApi.Features.Wrappers.JailbirdPickup; + +/// +/// Extensions for jailbirds. +/// +public static partial class PickupExtensions +{ + extension(JailbirdPickup pickup) + { + /// + /// Modifies the total damage dealt of this . + /// + /// The damage. + /// The modified . + public JailbirdPickup WithTotalDamageDealt(float damage) + { + pickup.TotalDamageDealt += damage; + return pickup; + } + + /// + /// Modifies the total charges performed of this . + /// + /// The charges. + /// The modified . + public JailbirdPickup WithTotalChargesPerformed(int charges) + { + pickup.TotalChargesPerformed += charges; + return pickup; + } + + /// + /// Modifies the wear state of this . + /// + /// The state. + /// The modified . + public JailbirdPickup WithWearState(JailbirdWearState state) + { + pickup.WearState = state; + return pickup; + } + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/Pickups/PickupExtensions.MicroHID.cs b/SecretAPI/Extensions/Pickups/PickupExtensions.MicroHID.cs new file mode 100644 index 0000000..c749688 --- /dev/null +++ b/SecretAPI/Extensions/Pickups/PickupExtensions.MicroHID.cs @@ -0,0 +1,46 @@ +namespace SecretAPI.Extensions.Pickups; + +using InventorySystem.Items.MicroHID.Modules; +using LabApi.Features.Wrappers; + +/// +/// Extensions for Micro H.I.D. +/// +public static partial class PickupExtensions +{ + extension(MicroHIDPickup pickup) + { + /// + /// Modify the energy of this . + /// + /// The energy. + /// The modified . + public MicroHIDPickup WithEnergy(float energy) + { + pickup.Energy = energy; + return pickup; + } + + /// + /// Modify the phase of this . + /// + /// The phase. + /// The modified . + public MicroHIDPickup WithPhase(MicroHidPhase phase) + { + pickup.Phase = phase; + return pickup; + } + + /// + /// Modify the firing mode of this . + /// + /// The firing mode. + /// The modified . + public MicroHIDPickup WithFiringMode(MicroHidFiringMode mode) + { + pickup.FiringMode = mode; + return pickup; + } + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/Pickups/PickupExtensions.Radio.cs b/SecretAPI/Extensions/Pickups/PickupExtensions.Radio.cs new file mode 100644 index 0000000..f45b142 --- /dev/null +++ b/SecretAPI/Extensions/Pickups/PickupExtensions.Radio.cs @@ -0,0 +1,46 @@ +namespace SecretAPI.Extensions.Pickups; + +using InventorySystem.Items.Radio; +using RadioPickup = LabApi.Features.Wrappers.RadioPickup; + +/// +/// Extensions for radios. +/// +public static partial class PickupExtensions +{ + extension(RadioPickup pickup) + { + /// + /// Modifies the enabled state of this . + /// + /// The enabled state. + /// The modified . + public RadioPickup WithEnabledState(bool enabled) + { + pickup.IsEnabled = enabled; + return pickup; + } + + /// + /// Modifies the range level of this . + /// + /// The range. + /// The modified . + public RadioPickup WithRangeLevel(RadioMessages.RadioRangeLevel range) + { + pickup.RangeLevel = range; + return pickup; + } + + /// + /// Modifies the battery of this . + /// + /// The battery. + /// The modified . + public RadioPickup WithBattery(float battery) + { + pickup.Battery = battery; + return pickup; + } + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/Pickups/PickupExtensions.cs b/SecretAPI/Extensions/Pickups/PickupExtensions.cs new file mode 100644 index 0000000..0d530b3 --- /dev/null +++ b/SecretAPI/Extensions/Pickups/PickupExtensions.cs @@ -0,0 +1,61 @@ +namespace SecretAPI.Extensions.Pickups; + +using InventorySystem.Items.Usables.Scp330; +using LabApi.Features.Wrappers; +using Scp330Pickup = LabApi.Features.Wrappers.Scp330Pickup; + +/// +/// Extensions for pickups. +/// +public static partial class PickupExtensions +{ + extension(T pickup) + where T : Pickup + { + /// + /// Modifies the weight of this . + /// + /// The weight. + /// The modified . + public T WithWeight(float weight) + { + pickup.Weight = weight; + return pickup; + } + + /// + /// Modifies the locked state of this . + /// + /// The lock state. + /// The modified . + public T WithLockedState(bool locked) + { + pickup.IsLocked = locked; + return pickup; + } + } + + /// + /// Modifies the ammo in this . + /// + /// The pickup. + /// The ammo. + /// The modified . + public static AmmoPickup WithAmmo(this AmmoPickup pickup, ushort ammo) + { + pickup.Ammo = ammo; + return pickup; + } + + /// + /// Modifies the exposed candy in this . + /// + /// The pickup. + /// The candy kind. + /// The modified . + public static Scp330Pickup WithExposedCandy(this Scp330Pickup pickup, CandyKindID kind) + { + pickup.ExposedCandy = kind; + return pickup; + } +} \ No newline at end of file diff --git a/SecretAPI/Extensions/ReflectionExtensions.cs b/SecretAPI/Extensions/ReflectionExtensions.cs index 32767cf..340cf68 100644 --- a/SecretAPI/Extensions/ReflectionExtensions.cs +++ b/SecretAPI/Extensions/ReflectionExtensions.cs @@ -11,6 +11,28 @@ /// public static class ReflectionExtensions { + /// + /// Casts an object into . + /// This will throw an exception if is not of type . + /// + /// The source object to cast from. + /// The new type to cast to. + /// The source after being cast to T. + public static T Cast(this object source) + where T : class => (T)source; + + /// + /// Casts an object of to . + /// This will require to be derived from . + /// + /// The source to cast from. + /// The original type. + /// The type to cast to. + /// The source after being cast to . + public static T2 CastTypeSafely(this T1 source) + where T1 : class + where T2 : T1 => (T2)source; + /// /// Gets the long name of a function. ///