Skip to content
Open
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
11 changes: 10 additions & 1 deletion Commands/Modifying/Scale/SubCommands/Add.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,16 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s

if (arguments.Count >= 3 && TryGetVector(arguments.At(0), arguments.At(1), arguments.At(2), out Vector3 newScale))
{
mapEditorObject.Base.Scale += newScale;
if(mapEditorObject.GetComponentInParent<AdminToys.WaypointToy>() != null || mapEditorObject.GetComponentInChildren<AdminToys.WaypointToy>() != null)
{
AdminToys.WaypointToy waypointToy = mapEditorObject.GetComponent<AdminToys.WaypointToy>();
WaypointToy waypointToy1 = WaypointToy.Get(waypointToy);
waypointToy1.BoundsSize += newScale;
response = waypointToy1.BoundsSize.ToString("F3");
return true;
}

mapEditorObject.Base.Scale += newScale;
mapEditorObject.UpdateObjectAndCopies();

response = mapEditorObject.Base.Scale.ToString("F3");
Expand Down
13 changes: 11 additions & 2 deletions Commands/Modifying/Scale/SubCommands/Set.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,18 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
return false;
}

if (arguments.Count >= 3 && TryGetVector(arguments.At(0), arguments.At(1), arguments.At(2), out Vector3 newScale))
if (arguments.Count >= 3 && TryGetVector(arguments.At(0), arguments.At(1), arguments.At(2), out Vector3 newScale))
{
mapEditorObject.Base.Scale = newScale;
if (mapEditorObject.GetComponentInParent<AdminToys.WaypointToy>() != null || mapEditorObject.GetComponentInChildren<AdminToys.WaypointToy>() != null)
{
AdminToys.WaypointToy waypointToy = mapEditorObject.GetComponent<AdminToys.WaypointToy>();
WaypointToy waypointToy1 = WaypointToy.Get(waypointToy);
waypointToy1.BoundsSize = newScale;
response = waypointToy1.BoundsSize.ToString("F3");
return true;
}

mapEditorObject.Base.Scale = newScale;
mapEditorObject.UpdateObjectAndCopies();

response = mapEditorObject.Base.Scale.ToString("F3");
Expand Down
18 changes: 13 additions & 5 deletions Features/Serializable/Schematics/SchematicBlockData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ public GameObject Create(SchematicObject schematicObject, Transform parentTransf
transform.localScale = BlockType switch
{
BlockType.Empty when Scale == Vector3.zero => Vector3.one,
BlockType.Waypoint => Scale * SerializableWaypoint.ScaleMultiplier,
_ => Scale,
BlockType.Waypoint => ApplyWaypointBounds(Scale, transform),
_ => Scale,
};

if (gameObject.TryGetComponent(out AdminToyBase adminToyBase))
if (gameObject.TryGetComponent(out AdminToyBase adminToyBase) && gameObject.GetComponent<WaypointToy>() == null)
{
if (Properties != null && Properties.TryGetValue("Static", out object isStatic) && Convert.ToBoolean(isStatic))
{
Expand All @@ -75,8 +74,17 @@ public GameObject Create(SchematicObject schematicObject, Transform parentTransf

return gameObject;
}
private static Vector3 ApplyWaypointBounds(Vector3 scale, Transform t)
{
if (t.TryGetComponent<WaypointToy>(out var wp))
{
LabApi.Features.Wrappers.WaypointToy waypointToy = LabApi.Features.Wrappers.WaypointToy.Get(wp);
waypointToy.BoundsSize = scale;
}
return scale;
}

private GameObject CreateEmpty(bool fallback = false)
private GameObject CreateEmpty(bool fallback = false)
{
if (fallback)
Logger.Warn($"{BlockType} is not yet implemented. Object will be an empty GameObject instead.");
Expand Down
3 changes: 1 addition & 2 deletions Features/Serializable/SerializableWaypoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace ProjectMER.Features.Serializable;

public class SerializableWaypoint : SerializableObject, IIndicatorDefinition
{
public const float ScaleMultiplier = 1 / 256f;

public override GameObject? SpawnOrUpdateObject(Room? room = null, GameObject? instance = null)
{
Expand All @@ -21,7 +20,7 @@ public class SerializableWaypoint : SerializableObject, IIndicatorDefinition
_prevIndex = Index;

waypoint.transform.SetPositionAndRotation(position, rotation);
waypoint.transform.localScale = Scale * ScaleMultiplier;
waypoint.NetworkBoundsSize = Vector3.one;
waypoint.NetworkMovementSmoothing = 60;
waypoint.NetworkVisualizeBounds = true;

Expand Down
Loading