Skip to content

Commit 423477f

Browse files
MS-crewlouis1706
andauthored
refactor: consistent toys (#824)
* refactor edr * / * n * pitch refactor * idk why did this first time, i remember i was trying fix some bug but i dont remember wwhat bug soo * simple check * no magic number + array clear * Revert "Merge branch 'toys' of https://github.com/MS-crew/EXILEDPR into toys" This reverts commit 4104382, reversing changes made to 411f9cb. * Reapply "Merge branch 'toys' of https://github.com/MS-crew/EXILEDPR into toys" This reverts commit c5374ad. * delete rertunr * . * default prefab value * d * why you do that yamato * i yield... im losed everything * revert changes --------- Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com>
1 parent e3b0483 commit 423477f

9 files changed

Lines changed: 131 additions & 225 deletions

File tree

EXILED/Exiled.API/Features/Toys/AdminToy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public Vector3 Scale
161161
/// </summary>
162162
public byte MovementSmoothing
163163
{
164-
get => AdminToyBase.MovementSmoothing;
164+
get => AdminToyBase.NetworkMovementSmoothing;
165165
set => AdminToyBase.NetworkMovementSmoothing = value;
166166
}
167167

@@ -170,7 +170,7 @@ public byte MovementSmoothing
170170
/// </summary>
171171
public bool IsStatic
172172
{
173-
get => AdminToyBase.IsStatic;
173+
get => AdminToyBase.NetworkIsStatic;
174174
set => AdminToyBase.NetworkIsStatic = value;
175175
}
176176

EXILED/Exiled.API/Features/Toys/CameraToy.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,18 @@ public string Name
124124
/// Creates a new <see cref="CameraToy"/>.
125125
/// </summary>
126126
/// <param name="parent">The transform to create this <see cref="CameraToy"/> on.</param>
127-
/// <param name="type">The <see cref="CameraType"/> of the camera.</param>
128127
/// <param name="position">The local position of the camera.</param>
129128
/// <param name="rotation">The local rotation of the camera.</param>
130129
/// <param name="scale">The local scale of the camera.</param>
130+
/// <param name="type">The <see cref="CameraType"/> of the camera.</param>
131131
/// <param name="name">The name (label) of the camera.</param>
132132
/// <param name="room">The room associated with this camera.</param>
133133
/// <param name="verticalConstraint">The vertical limits. Leave null to use prefab default.</param>
134134
/// <param name="horizontalConstraint">The horizontal limits. Leave null to use prefab default.</param>
135135
/// <param name="zoomConstraint">The zoom limits. Leave null to use prefab default.</param>
136136
/// <param name="spawn">Whether the camera should be initially spawned.</param>
137137
/// <returns>The new <see cref="CameraToy"/>.</returns>
138-
public static CameraToy Create(Transform parent = null, CameraType type = CameraType.EzArmCameraToy, Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, string name = "New Camera", Room room = null, Vector2? verticalConstraint = null, Vector2? horizontalConstraint = null, Vector2? zoomConstraint = null, bool spawn = true)
138+
public static CameraToy Create(Transform parent = null, Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, CameraType type = CameraType.EzArmCameraToy, string name = "New Camera", Room room = null, Vector2? verticalConstraint = null, Vector2? horizontalConstraint = null, Vector2? zoomConstraint = null, bool spawn = true)
139139
{
140140
Scp079CameraToy prefab = type switch
141141
{
@@ -156,12 +156,11 @@ public static CameraToy Create(Transform parent = null, CameraType type = Camera
156156
CameraToy toy = new(Object.Instantiate(prefab, parent))
157157
{
158158
Name = name,
159+
LocalPosition = position ?? Vector3.zero,
160+
LocalRotation = rotation ?? Quaternion.identity,
161+
Scale = scale ?? Vector3.one,
159162
};
160163

161-
toy.Transform.localPosition = position ?? Vector3.zero;
162-
toy.Transform.localRotation = rotation ?? Quaternion.identity;
163-
toy.Transform.localScale = scale ?? Vector3.one;
164-
165164
if (verticalConstraint.HasValue)
166165
toy.VerticalConstraint = verticalConstraint.Value;
167166

EXILED/Exiled.API/Features/Toys/Capybara.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,11 @@ public static Capybara Create(Transform parent = null, Vector3? position = null,
8383
Capybara toy = new(Object.Instantiate(Prefab, parent))
8484
{
8585
Collidable = collidable,
86+
LocalPosition = position ?? Vector3.zero,
87+
LocalRotation = rotation ?? Quaternion.identity,
88+
Scale = scale ?? Vector3.one,
8689
};
8790

88-
toy.Transform.localPosition = position ?? Vector3.zero;
89-
toy.Transform.localRotation = rotation ?? Quaternion.identity;
90-
toy.Transform.localScale = scale ?? Vector3.one;
91-
9291
if (spawn)
9392
toy.Spawn();
9493

EXILED/Exiled.API/Features/Toys/InteractableToy.cs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,7 @@ public bool IsLocked
6666
}
6767

6868
/// <summary>
69-
/// Creates a new <see cref="InteractableToy"/> at the specified position.
70-
/// </summary>
71-
/// <param name="position">The local position of the <see cref="InteractableToy"/>.</param>
72-
/// <returns>The new <see cref="InteractableToy"/>.</returns>
73-
public static InteractableToy Create(Vector3 position) => Create(position: position, spawn: true);
74-
75-
/// <summary>
76-
/// Creates a new <see cref="InteractableToy"/> with a specific position and shape.
77-
/// </summary>
78-
/// <param name="position">The local position of the <see cref="InteractableToy"/>.</param>
79-
/// <param name="shape">The shape of the collider.</param>
80-
/// <returns>The new <see cref="InteractableToy"/>.</returns>
81-
public static InteractableToy Create(Vector3 position, ColliderShape shape) => Create(position: position, shape: shape, spawn: true);
82-
83-
/// <summary>
84-
/// Creates a new <see cref="InteractableToy"/> with a specific position, shape, and interaction duration.
69+
/// Creates a new <see cref="InteractableToy"/>.
8570
/// </summary>
8671
/// <param name="position">The local position of the <see cref="InteractableToy"/>.</param>
8772
/// <param name="shape">The shape of the collider.</param>
@@ -90,16 +75,16 @@ public bool IsLocked
9075
public static InteractableToy Create(Vector3 position, ColliderShape shape, float duration) => Create(position: position, shape: shape, interactionDuration: duration, spawn: true);
9176

9277
/// <summary>
93-
/// Creates a new <see cref="InteractableToy"/> from a Transform.
78+
/// Creates a new <see cref="InteractableToy"/>.
9479
/// </summary>
95-
/// <param name="transform">The transform to create this <see cref="InteractableToy"/> on.</param>
80+
/// <param name="position">The local position of the <see cref="InteractableToy"/>.</param>
9681
/// <param name="shape">The shape of the collider.</param>
9782
/// <param name="interactionDuration">How long the interaction takes.</param>
9883
/// <param name="isLocked">Whether the object is locked.</param>
9984
/// <param name="spawn">Whether the <see cref="InteractableToy"/> should be initially spawned.</param>
10085
/// <returns>The new <see cref="InteractableToy"/>.</returns>
101-
public static InteractableToy Create(Transform transform, ColliderShape shape = ColliderShape.Sphere, float interactionDuration = 1f, bool isLocked = false, bool spawn = true)
102-
=> Create(parent: transform, shape: shape, interactionDuration: interactionDuration, isLocked: isLocked, spawn: spawn);
86+
public static InteractableToy Create(Vector3 position, ColliderShape shape = ColliderShape.Sphere, float interactionDuration = 1f, bool isLocked = false, bool spawn = true)
87+
=> Create(position: position, shape: shape, interactionDuration: interactionDuration, isLocked: isLocked, spawn: spawn);
10388

10489
/// <summary>
10590
/// Creates a new <see cref="InteractableToy"/>.
@@ -120,12 +105,11 @@ public static InteractableToy Create(Transform parent = null, Vector3? position
120105
Shape = shape,
121106
IsLocked = isLocked,
122107
InteractionDuration = interactionDuration,
108+
LocalPosition = position ?? Vector3.zero,
109+
LocalRotation = rotation ?? Quaternion.identity,
110+
Scale = scale ?? Vector3.one,
123111
};
124112

125-
toy.Transform.localPosition = position ?? Vector3.zero;
126-
toy.Transform.localRotation = rotation ?? Quaternion.identity;
127-
toy.Transform.localScale = scale ?? Vector3.one;
128-
129113
if (spawn)
130114
toy.Spawn();
131115

EXILED/Exiled.API/Features/Toys/Light.cs

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ namespace Exiled.API.Features.Toys
1818

1919
using UnityEngine;
2020

21+
using Object = UnityEngine.Object;
22+
2123
/// <summary>
2224
/// A wrapper class for <see cref="LightSourceToy"/>.
2325
/// </summary>
@@ -129,36 +131,62 @@ public LightShadows ShadowType
129131
/// Creates a new <see cref="Light"/>.
130132
/// </summary>
131133
/// <param name="position">The position of the <see cref="Light"/>.</param>
132-
/// <param name="rotation">The rotation of the <see cref="Light"/>.</param>
133-
/// <param name="scale">The scale of the <see cref="Light"/>.</param>
134-
/// <param name="spawn">Whether the <see cref="Light"/> should be initially spawned.</param>
134+
/// <param name="color">The color of the <see cref="Light"/>.</param>
135135
/// <returns>The new <see cref="Light"/>.</returns>
136-
public static Light Create(Vector3? position = null, Vector3? rotation = null, Vector3? scale = null, bool spawn = true)
137-
=> Create(position, rotation, scale, spawn, null);
136+
public static Light Create(Vector3 position, Color color) => Create(position: position, color: color, spawn: true);
138137

139138
/// <summary>
140139
/// Creates a new <see cref="Light"/>.
141140
/// </summary>
142-
/// <param name="position">The position of the <see cref="Light"/>.</param>
143-
/// <param name="rotation">The rotation of the <see cref="Light"/>.</param>
141+
/// <param name="parent">The transform to create this <see cref="Light"/> on.</param>
142+
/// <param name="position">The local position of the <see cref="Light"/>.</param>
143+
/// <param name="rotation">The local rotation of the <see cref="Light"/>.</param>
144144
/// <param name="scale">The scale of the <see cref="Light"/>.</param>
145-
/// <param name="spawn">Whether the <see cref="Light"/> should be initially spawned.</param>
146145
/// <param name="color">The color of the <see cref="Light"/>.</param>
146+
/// <param name="intensity">The intensity of the light.</param>
147+
/// <param name="range">The range of the light.</param>
148+
/// <param name="spotAngle">The angle of the light.</param>
149+
/// <param name="innerSpotAngle">The inner angle of the light.</param>
150+
/// <param name="shadowStrength">The shadow strength of the light.</param>
151+
/// <param name="lightType">The type of light the Light emits.</param>
152+
/// <param name="shadowType">The type of shadows the light casts.</param>
153+
/// <param name="spawn">Whether the <see cref="Light"/> should be initially spawned.</param>
147154
/// <returns>The new <see cref="Light"/>.</returns>
148-
public static Light Create(Vector3? position /*= null*/, Vector3? rotation /*= null*/, Vector3? scale /*= null*/, bool spawn /*= true*/, Color? color /*= null*/)
155+
public static Light Create(Transform parent = null, Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, Color? color = null, float? intensity = null, float? range = null, float? spotAngle = null, float? innerSpotAngle = null, float? shadowStrength = null, LightType? lightType = null, LightShadows? shadowType = null, bool spawn = true)
149156
{
150-
Light light = new(UnityEngine.Object.Instantiate(Prefab))
157+
Light toy = new(Object.Instantiate(Prefab, parent))
151158
{
152-
Position = position ?? Vector3.zero,
153-
Rotation = Quaternion.Euler(rotation ?? Vector3.zero),
159+
LocalPosition = position ?? Vector3.zero,
160+
LocalRotation = rotation ?? Quaternion.identity,
154161
Scale = scale ?? Vector3.one,
155-
Color = color ?? Color.gray,
162+
Color = color ?? Color.white,
156163
};
157164

165+
if (intensity.HasValue)
166+
toy.Intensity = intensity.Value;
167+
168+
if (range.HasValue)
169+
toy.Range = range.Value;
170+
171+
if (spotAngle.HasValue)
172+
toy.SpotAngle = spotAngle.Value;
173+
174+
if (innerSpotAngle.HasValue)
175+
toy.InnerSpotAngle = innerSpotAngle.Value;
176+
177+
if (shadowStrength.HasValue)
178+
toy.ShadowStrength = shadowStrength.Value;
179+
180+
if (lightType.HasValue)
181+
toy.LightType = lightType.Value;
182+
183+
if (shadowType.HasValue)
184+
toy.ShadowType = shadowType.Value;
185+
158186
if (spawn)
159-
light.Spawn();
187+
toy.Spawn();
160188

161-
return light;
189+
return toy;
162190
}
163191

164192
/// <summary>

0 commit comments

Comments
 (0)