Skip to content
Merged
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
68 changes: 68 additions & 0 deletions SecretAPI/Extensions/AdminToys/AdminToyExtensions.Camera.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
namespace SecretAPI.Extensions.AdminToys;

using LabApi.Features.Wrappers;
using UnityEngine;

/// <summary>
/// Extensions for camera toys.
/// </summary>
public static partial class AdminToyExtensions
{
extension(CameraToy toy)
{
/// <summary>
/// Modify the label of this <see cref="CameraToy"/>.
/// </summary>
/// <param name="label">The label.</param>
/// <returns>The modified <see cref="CameraToy"/>.</returns>
public CameraToy WithLabel(string label)
{
toy.Label = label;
return toy;
}

/// <summary>
/// Modify the room of this <see cref="CameraToy"/>.
/// </summary>
/// <param name="room">The room.</param>
/// <returns>The modified <see cref="CameraToy"/>.</returns>
public CameraToy WithRoom(Room room)
{
toy.Room = room;
return toy;
}

/// <summary>
/// Modify the vertical constrains of this <see cref="CameraToy"/>.
/// </summary>
/// <param name="constraint">The constraints.</param>
/// <returns>The modified <see cref="CameraToy"/>.</returns>
public CameraToy WithVerticalConstraints(Vector2 constraint)
{
toy.VerticalConstraints = constraint;
return toy;
}

/// <summary>
/// Modify the horizontal constrains of this <see cref="CameraToy"/>.
/// </summary>
/// <param name="constraint">The constraints.</param>
/// <returns>The modified <see cref="CameraToy"/>.</returns>
public CameraToy WithHorizontalConstraints(Vector2 constraint)
{
toy.HorizontalConstraint = constraint;
return toy;
}

/// <summary>
/// Modify the zoom constrains of this <see cref="CameraToy"/>.
/// </summary>
/// <param name="constraint">The constraints.</param>
/// <returns>The modified <see cref="CameraToy"/>.</returns>
public CameraToy WithZoomConstraints(Vector2 constraint)
{
toy.ZoomConstraints = constraint;
return toy;
}
}
}
91 changes: 91 additions & 0 deletions SecretAPI/Extensions/AdminToys/AdminToyExtensions.Interactable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
namespace SecretAPI.Extensions.AdminToys;

using System;
using global::AdminToys;
using LabApi.Features.Wrappers;

/// <summary>
/// Extensions for interactable toys.
/// </summary>
public static partial class AdminToyExtensions
{
extension(InteractableToy toy)
{
/// <summary>
/// Call an <see cref="Action"/> when this <see cref="InteractableToy"/> is interacted with.
/// </summary>
/// <param name="action">The <see cref="Action"/> to run.</param>
/// <returns>The modified <see cref="InteractableToy"/>.</returns>
public InteractableToy WhenInteracted(Action<Player> action)
{
toy.OnInteracted += action;
return toy;
}

/// <summary>
/// Call an <see cref="Action"/> when this <see cref="InteractableToy"/> is being searched.
/// </summary>
/// <param name="action">The <see cref="Action"/> to run.</param>
/// <returns>The modified <see cref="InteractableToy"/>.</returns>
public InteractableToy WhenSearching(Action<Player> action)
{
toy.OnSearching += action;
return toy;
}

/// <summary>
/// Call an <see cref="Action"/> when this <see cref="InteractableToy"/> has been searched.
/// </summary>
/// <param name="action">The <see cref="Action"/> to run.</param>
/// <returns>The modified <see cref="InteractableToy"/>.</returns>
public InteractableToy WhenSearched(Action<Player> action)
{
toy.OnSearched += action;
return toy;
}

/// <summary>
/// Call an <see cref="Action"/> when this <see cref="InteractableToy"/> has had an aborted search.
/// </summary>
/// <param name="action">The <see cref="Action"/> to run.</param>
/// <returns>The modified <see cref="InteractableToy"/>.</returns>
public InteractableToy WhenSearchAborted(Action<Player> action)
{
toy.OnSearchAborted += action;
return toy;
}

/// <summary>
/// Modify the shape of this <see cref="InteractableToy"/>.
/// </summary>
/// <param name="shape">The shape.</param>
/// <returns>The modified <see cref="InteractableToy"/>.</returns>
public InteractableToy WithShape(InvisibleInteractableToy.ColliderShape shape)
{
toy.Shape = shape;
return toy;
}

/// <summary>
/// Modify how long a user should interact with before triggering the <see cref="InteractableToy.OnSearched"/> event.
/// </summary>
/// <param name="duration">The duration.</param>
/// <returns>The modified <see cref="InteractableToy"/>.</returns>
public InteractableToy WithInteractionDuration(float duration)
{
toy.InteractionDuration = duration;
return toy;
}

/// <summary>
/// Modify whether this <see cref="InteractableToy"/> can be interacted with.
/// </summary>
/// <param name="locked">The lock state.</param>
/// <returns>The modified <see cref="InteractableToy"/>.</returns>
public InteractableToy IsLocked(bool locked)
{
toy.IsLocked = locked;
return toy;
}
}
}
114 changes: 114 additions & 0 deletions SecretAPI/Extensions/AdminToys/AdminToyExtensions.Light.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
namespace SecretAPI.Extensions.AdminToys;

using LabApi.Features.Wrappers;
using UnityEngine;

/// <summary>
/// Extensions for Light Source Toys.
/// </summary>
public static partial class AdminToyExtensions
{
extension(LightSourceToy toy)
{
/// <summary>
/// Modify the intensity of this <see cref="LightSourceToy"/>.
/// </summary>
/// <param name="intensity">The intensity.</param>
/// <returns>The modified <see cref="LightSourceToy"/>.</returns>
public LightSourceToy WithIntensity(float intensity)
{
toy.Intensity = intensity;
return toy;
}

/// <summary>
/// Modify the range of this <see cref="LightSourceToy"/>.
/// </summary>
/// <param name="range">The range.</param>
/// <returns>The modified <see cref="LightSourceToy"/>.</returns>
public LightSourceToy WithRange(float range)
{
toy.Range = range;
return toy;
}

/// <summary>
/// Modify the color of this <see cref="LightSourceToy"/>.
/// </summary>
/// <param name="color">The color.</param>
/// <returns>The modified <see cref="LightSourceToy"/>.</returns>
public LightSourceToy WithColor(Color color)
{
toy.Color = color;
return toy;
}

/// <summary>
/// Modify the shadow type of this <see cref="LightSourceToy"/>.
/// </summary>
/// <param name="type">The shadow type.</param>
/// <returns>The modified <see cref="LightSourceToy"/>.</returns>
public LightSourceToy WithShadowType(LightShadows type)
{
toy.ShadowType = type;
return toy;
}

/// <summary>
/// Modify the shadow strength of this <see cref="LightSourceToy"/>.
/// </summary>
/// <param name="strength">The strength.</param>
/// <returns>The modified <see cref="LightSourceToy"/>.</returns>
public LightSourceToy WithShadowStrength(float strength)
{
toy.ShadowStrength = strength;
return toy;
}

/// <summary>
/// Modify the type of this <see cref="LightSourceToy"/>.
/// </summary>
/// <param name="lightType">The type.</param>
/// <returns>The modified <see cref="LightSourceToy"/>.</returns>
public LightSourceToy WithType(LightType lightType)
{
toy.Type = lightType;
return toy;
}

/// <summary>
/// Modify the shape of this <see cref="LightSourceToy"/>.
/// </summary>
/// <param name="shape">The shape.</param>
/// <returns>The modified <see cref="LightSourceToy"/>.</returns>
#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;
}

/// <summary>
/// Modify the spot angle of this <see cref="LightSourceToy"/>.
/// </summary>
/// <param name="angle">The angle.</param>
/// <returns>The modified <see cref="LightSourceToy"/>.</returns>
public LightSourceToy WithSpotAngle(float angle)
{
toy.SpotAngle = angle;
return toy;
}

/// <summary>
/// Modify the inner spot angle of this <see cref="LightSourceToy"/>.
/// </summary>
/// <param name="angle">The angle.</param>
/// <returns>The modified <see cref="LightSourceToy"/>.</returns>
public LightSourceToy WithInnerSpotAngle(float angle)
{
toy.InnerSpotAngle = angle;
return toy;
}
}
}
87 changes: 87 additions & 0 deletions SecretAPI/Extensions/AdminToys/AdminToyExtensions.Primitive.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
namespace SecretAPI.Extensions.AdminToys;

using global::AdminToys;
using UnityEngine;
using PrimitiveObjectToy = LabApi.Features.Wrappers.PrimitiveObjectToy;

/// <summary>
/// Extensions for primitive object toys.
/// </summary>
public static partial class AdminToyExtensions
{
extension(PrimitiveObjectToy toy)
{
/// <summary>
/// Gets or sets a value indicating whether this <see cref="PrimitiveObjectToy"/> is collidable.
/// </summary>
public bool Collidable
{
get => (toy.Flags & PrimitiveFlags.Collidable) == PrimitiveFlags.Collidable;
set => toy.Flags = value ? toy.Flags | PrimitiveFlags.Collidable : toy.Flags & ~PrimitiveFlags.Collidable;
}

/// <summary>
/// Gets or sets a value indicating whether this <see cref="PrimitiveObjectToy"/> is visible.
/// </summary>
public bool Visible
{
get => (toy.Flags & PrimitiveFlags.Visible) == PrimitiveFlags.Visible;
set => toy.Flags = value ? toy.Flags | PrimitiveFlags.Visible : toy.Flags & ~PrimitiveFlags.Visible;
}

/// <summary>
/// Modify whether this <see cref="PrimitiveObjectToy"/> is collidable.
/// </summary>
/// <param name="collidable">The collidable state.</param>
/// <returns>The modified <see cref="PrimitiveObjectToy"/>.</returns>
public PrimitiveObjectToy WithCollidable(bool collidable)
{
toy.Collidable = collidable;
return toy;
}

/// <summary>
/// Modify whether this <see cref="PrimitiveObjectToy"/> is visible.
/// </summary>
/// <param name="visible">The visibility state.</param>
/// <returns>The modified <see cref="PrimitiveObjectToy"/>.</returns>
public PrimitiveObjectToy WithVisible(bool visible)
{
toy.Visible = visible;
return toy;
}

/// <summary>
/// Modify the type of this <see cref="PrimitiveObjectToy"/>.
/// </summary>
/// <param name="type">The type.</param>
/// <returns>The modified <see cref="PrimitiveObjectToy"/>.</returns>
public PrimitiveObjectToy WithType(PrimitiveType type)
{
toy.Type = type;
return toy;
}

/// <summary>
/// Modify the color of this <see cref="PrimitiveObjectToy"/>.
/// </summary>
/// <param name="color">The color.</param>
/// <returns>The modified <see cref="PrimitiveObjectToy"/>.</returns>
public PrimitiveObjectToy WithColor(Color color)
{
toy.Color = color;
return toy;
}

/// <summary>
/// Modify the flags of this <see cref="PrimitiveObjectToy"/>.
/// </summary>
/// <param name="flags">The flags.</param>
/// <returns>The modified <see cref="PrimitiveObjectToy"/>.</returns>
public PrimitiveObjectToy WithFlags(PrimitiveFlags flags)
{
toy.Flags = flags;
return toy;
}
}
}
Loading
Loading