Skip to content
Open
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using JANOARG.Shared.Data.ChartInfo;
using JANOARG.Chartmaker.Utils;
using Unity.Collections;
using UnityEngine;
using UnityEngine.Serialization;

Expand All @@ -17,6 +18,9 @@

public Transform HitObjectPosition;

[SerializeField] [ReadOnly]
private ulong Uuid;

public void OnDestroy()
{
if (HoldTail)
Expand All @@ -27,6 +31,9 @@

public void UpdateObjects(HitObjectManager hit)
{
if (CurrentHit != null && Uuid != CurrentHit.Uuid)
Uuid = CurrentHit.Uuid;

CurrentHit = hit;
transform.localPosition = hit.Position;
transform.localRotation = hit.Rotation;
Expand Down Expand Up @@ -102,7 +109,7 @@
if (!FlickEmblem) {
FlickEmblem = Instantiate(PlayerView.main.HoldMeshSample, transform);
}

Check notice on line 112 in Assets/JANOARG.Chartmaker/Scripts/Behaviors/Chartmaker/ChartmakerHitPlayer.cs

View check run for this annotation

codefactor.io / CodeFactor

Assets/JANOARG.Chartmaker/Scripts/Behaviors/Chartmaker/ChartmakerHitPlayer.cs#L112

Code should not contain multiple blank lines in a row. (SA1507)

FlickEmblem.gameObject.SetActive(true);
FlickEmblem.sharedMaterial = mainMaterial;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using JANOARG.Shared.Data.ChartInfo;
using Unity.Collections;
using UnityEngine;

namespace JANOARG.Chartmaker.Behaviors.Chartmaker
Expand All @@ -7,8 +8,14 @@ public class ChartmakerLaneGroupPlayer : MonoBehaviour
{
public LaneGroupManager CurrentGroup;

[SerializeField] [ReadOnly]
private ulong Uuid;

public void UpdateObjects(LaneGroupManager group)
{
if (CurrentGroup != null && Uuid != CurrentGroup.Uuid)
Uuid = CurrentGroup.Uuid;

CurrentGroup = group;

// Apply only this group's own local transform — nesting is handled
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using System.Collections.Generic;
using JANOARG.Shared.Data.ChartInfo;
using JANOARG.Chartmaker.Utils;
using Unity.Collections;
using Unity.Profiling;
using UnityEngine;

namespace JANOARG.Chartmaker.Behaviors.Chartmaker
{
public class ChartmakerLanePlayer : MonoBehaviour

Check notice on line 10 in Assets/JANOARG.Chartmaker/Scripts/Behaviors/Chartmaker/ChartmakerLanePlayer.cs

View check run for this annotation

codefactor.io / CodeFactor

Assets/JANOARG.Chartmaker/Scripts/Behaviors/Chartmaker/ChartmakerLanePlayer.cs#L10

An opening brace should not be followed by a blank line. (SA1505)
{

public LaneManager CurrentLane;
public Transform Holder;
public MeshRenderer Renderer;
Expand All @@ -16,6 +18,9 @@
public MeshRenderer JudgeLine;
public MeshRenderer[] JudgeEnds;

[SerializeField][ReadOnly]
private ulong Uuid;

public List<ChartmakerHitPlayer> HitPlayers { get; private set; } = new();

// Last values written to a transform. A lane without a Position/Rotation storyboard
Expand All @@ -39,6 +44,9 @@
{
sr_LaneState.Begin();

if (CurrentLane != null && Uuid != CurrentLane.Uuid)
Uuid = CurrentLane.Uuid;

CurrentLane = lane;

// Use the lane's own Position/Rotation, not FinalPosition/FinalRotation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,23 +242,22 @@

GroupItems = newGroupItems;

// Resolve parent hierarchy using first-match by name, same as client.
// Resolve parent hierarchy using UUID, falling back to name.
for (int gi = 0; gi < chart.Groups.Count; gi++)
{
LaneGroup data = chart.Groups[gi];
if (!string.IsNullOrEmpty(data.Group))
int parentIdx = data.GroupUuid != 0
? chart.Groups.FindIndex(g => g.UUID == data.GroupUuid)
: (!string.IsNullOrEmpty(data.Group) ? chart.Groups.FindIndex(g => g.Name == data.Group) : -1);
if (parentIdx >= 0)
{
int parentIdx = chart.Groups.FindIndex(g => g.Name == data.Group);
if (parentIdx >= 0)
{
GroupItems[parentIdx].Children.Add(GroupItems[gi]);
continue;
}
GroupItems[parentIdx].Children.Add(GroupItems[gi]);
continue;
}
worldItem.Children.Add(GroupItems[gi]);
}

// Add lanes — first-match by group name, same as client.
// Add lanes — resolve by UUID, falling back to name.
foreach (Lane lane in chart.Lanes)
{
HierarchyItem item = new () {
Expand All @@ -268,7 +267,9 @@
Target = lane,
};

int groupIdx = string.IsNullOrEmpty(lane.Group) ? -1 : chart.Groups.FindIndex(g => g.Name == lane.Group);
int groupIdx = lane.GroupUuid != 0
? chart.Groups.FindIndex(g => g.UUID == lane.GroupUuid)
: (!string.IsNullOrEmpty(lane.Group) ? chart.Groups.FindIndex(g => g.Name == lane.Group) : -1);
if (groupIdx >= 0)
GroupItems[groupIdx].Children.Add(item);
else
Expand Down Expand Up @@ -604,17 +605,18 @@
{
new ContextMenuListAction("Lane", () =>
{
string group = InspectorPanel.main.CurrentObject switch
(string group, ulong groupUuid) = InspectorPanel.main.CurrentObject switch
{
Lane laneCurrentObject => laneCurrentObject.Group,
LaneGroup laneGroupCurrentObject => laneGroupCurrentObject.Name,
_ => ""
Lane laneCurrentObject => (laneCurrentObject.Group, laneCurrentObject.GroupUuid),
LaneGroup laneGroupCurrentObject => (laneGroupCurrentObject.Name, laneGroupCurrentObject.UUID),
_ => ("", 0UL)
};

Lane lane = new Lane
{
Position = new(0, -4, 0),
Group = group,
GroupUuid = groupUuid,
};

lane.LaneSteps.Add(new LaneStep
Expand All @@ -635,15 +637,16 @@
}),
new ContextMenuListAction("Lane Group", () =>
{
string parent = InspectorPanel.main.CurrentObject switch
(string parent, ulong parentUuid) = InspectorPanel.main.CurrentObject switch
{
Lane laneCurrentObject => laneCurrentObject.Group,
LaneGroup laneGroupCurrentObject => laneGroupCurrentObject.Name,
_ => ""
Lane laneCurrentObject => (laneCurrentObject.Group, laneCurrentObject.GroupUuid),
LaneGroup laneGroupCurrentObject => (laneGroupCurrentObject.Group, laneGroupCurrentObject.GroupUuid),
_ => ("", 0UL)
};

LaneGroup group = new LaneGroup {
Group = parent,
GroupUuid = parentUuid,
Name = InspectorPanel.main.GetNewGroupName("Group 1"),
};
Chartmaker.main.AddItem(group);
Expand All @@ -651,7 +654,7 @@
};

default:
return new ContextMenuListItem[] {};

Check notice on line 657 in Assets/JANOARG.Chartmaker/Scripts/Behaviors/Chartmaker/HierarchyPanel.cs

View check run for this annotation

codefactor.io / CodeFactor

Assets/JANOARG.Chartmaker/Scripts/Behaviors/Chartmaker/HierarchyPanel.cs#L657

Avoid unnecessary zero-length array allocations. Use Array.Empty<ContextMenuListItem>() instead. (CA1825)
}
}
}
Expand All @@ -672,7 +675,7 @@
item.Expanded = true;
foreach (HierarchyItem child in item.Children) if (child.Children.Count > 0) ExpandRecursively(child);
}

Check notice on line 678 in Assets/JANOARG.Chartmaker/Scripts/Behaviors/Chartmaker/HierarchyPanel.cs

View check run for this annotation

codefactor.io / CodeFactor

Assets/JANOARG.Chartmaker/Scripts/Behaviors/Chartmaker/HierarchyPanel.cs#L678

Code should not contain multiple blank lines in a row. (SA1507)

public void OnSearchFieldUpdate()
{
Expand Down Expand Up @@ -787,11 +790,20 @@
bool IsLaneGroupDraggingIntoSelf(LaneGroup dragging, string target)
{
if (dragging.Name == target) return true;
while (!String.IsNullOrEmpty(target))
ulong targetUuid = dragging.GroupUuid;
while (targetUuid != 0 || !string.IsNullOrEmpty(target))
{
LaneGroup group = PlayerView.main.Manager.Groups[target].CurrentGroup;
if (group.Group == dragging.Name) return true;
if (group.Group == dragging.Group) return false;
if (!PlayerView.main.Manager.Groups.TryGetValue(targetUuid, out var groupManager))
{
// Fallback: find by name
var found = PlayerView.main.Manager.Groups.Values.FirstOrDefault(g => g.CurrentGroup.Name == target);
if (found == null) break;
groupManager = found;
}
LaneGroup group = groupManager.CurrentGroup;
if (group.UUID == dragging.UUID) return true;
if (group.GroupUuid == dragging.GroupUuid) return false;
targetUuid = group.GroupUuid;
target = group.Group;
}
return false;
Expand All @@ -810,37 +822,45 @@
List<Lane> list = Chartmaker.main.CurrentChart.Lanes;
int index = list.IndexOf(lane);

ChartmakerArrangeLaneAction rearrangeLaneAction(Lane adjacent, string group) => new () {
ChartmakerArrangeLaneAction rearrangeLaneAction(Lane adjacent, string group, ulong groupUuid) => new () {
Target = lane,
BeforeAdjacent = index > 0 ? list[index - 1] : null,
BeforeAdjacentUuid = index > 0 ? list[index - 1].UUID : 0,
BeforeGroup = lane.Group,
BeforeGroupUuid = lane.GroupUuid,
AfterAdjacent = adjacent,
AfterGroup = group
AfterAdjacentUuid = adjacent?.UUID ?? 0,
AfterGroup = group,
AfterGroupUuid = groupUuid
};

if (item1.Target.Target is LaneGroup group1)
{
return rearrangeLaneAction(list[^1], group1.Name);
return rearrangeLaneAction(list[^1], group1.Name, group1.UUID);
}
}
else if (item.Target.Target is LaneGroup group)
{
List<LaneGroup> list = Chartmaker.main.CurrentChart.Groups;
int index = list.IndexOf(group);

ChartmakerArrangeLaneGroupAction rearrangeGroupAction(LaneGroup adjacent, string parent) => new () {
ChartmakerArrangeLaneGroupAction rearrangeGroupAction(LaneGroup adjacent, string parent, ulong parentUuid) => new () {
Target = group,
BeforeAdjacent = index > 0 ? list[index - 1] : null,
BeforeAdjacentUuid = index > 0 ? list[index - 1].UUID : 0,
BeforeGroup = group.Group,
BeforeGroupUuid = group.GroupUuid,
AfterAdjacent = adjacent,
AfterGroup = parent
AfterAdjacentUuid = adjacent?.UUID ?? 0,
AfterGroup = parent,
AfterGroupUuid = parentUuid
};

Check notice on line 858 in Assets/JANOARG.Chartmaker/Scripts/Behaviors/Chartmaker/HierarchyPanel.cs

View check run for this annotation

codefactor.io / CodeFactor

Assets/JANOARG.Chartmaker/Scripts/Behaviors/Chartmaker/HierarchyPanel.cs#L858

Code should not contain multiple blank lines in a row. (SA1507)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code should not contain multiple blank lines in a row.

Suggested change


if (item1.Target.Target is LaneGroup group1)
{
if (IsLaneGroupDraggingIntoSelf(group, group1.Group)) return null;
return rearrangeGroupAction(list[^1], group1.Name);
return rearrangeGroupAction(list[^1], group1.Name, group1.UUID);
}
}
}
Expand All @@ -853,55 +873,63 @@
List<Lane> list = Chartmaker.main.CurrentChart.Lanes;
int index = list.IndexOf(lane);

ChartmakerArrangeLaneAction rearrangeLaneAction(Lane adjacent, string group) => new () {
ChartmakerArrangeLaneAction rearrangeLaneAction(Lane adjacent, string group, ulong groupUuid) => new () {
Target = lane,
BeforeAdjacent = index > 0 ? list[index - 1] : null,
BeforeAdjacentUuid = index > 0 ? list[index - 1].UUID : 0,
BeforeGroup = lane.Group,
BeforeGroupUuid = lane.GroupUuid,
AfterAdjacent = adjacent,
AfterGroup = group
AfterAdjacentUuid = adjacent?.UUID ?? 0,
AfterGroup = group,
AfterGroupUuid = groupUuid
};

if (item1.Target.Type == HierarchyItemType.World)
{
return rearrangeLaneAction(list[^1], "");
return rearrangeLaneAction(list[^1], "", 0);
}
if (item1.Target.Target is Lane lane1)
{
return rearrangeLaneAction(lane1, lane1.Group);
return rearrangeLaneAction(lane1, lane1.Group, lane1.GroupUuid);
}
if (item1.Target.Target is LaneGroup group1)
{
if (item1.Target.Children.Count > 0 && item1.Target.Expanded)
return rearrangeLaneAction(null, group1.Name);
return rearrangeLaneAction(null, group1.Name, group1.UUID);
else
return rearrangeLaneAction(null, group1.Group);
return rearrangeLaneAction(null, group1.Group, group1.GroupUuid);
}
}
else if (item.Target.Target is LaneGroup group)
{
List<LaneGroup> list = Chartmaker.main.CurrentChart.Groups;
int index = list.IndexOf(group);

ChartmakerArrangeLaneGroupAction rearrangeGroupAction(LaneGroup adjacent, string parent) =>
ChartmakerArrangeLaneGroupAction rearrangeGroupAction(LaneGroup adjacent, string parent, ulong parentUuid) =>
IsLaneGroupDraggingIntoSelf(group, parent) ? null : new () {
Target = group,
BeforeAdjacent = index > 0 ? list[index - 1] : null,
BeforeAdjacentUuid = index > 0 ? list[index - 1].UUID : 0,
BeforeGroup = group.Group,
BeforeGroupUuid = group.GroupUuid,
AfterAdjacent = adjacent,
AfterGroup = parent
AfterAdjacentUuid = adjacent?.UUID ?? 0,
AfterGroup = parent,
AfterGroupUuid = parentUuid
};

Check notice on line 921 in Assets/JANOARG.Chartmaker/Scripts/Behaviors/Chartmaker/HierarchyPanel.cs

View check run for this annotation

codefactor.io / CodeFactor

Assets/JANOARG.Chartmaker/Scripts/Behaviors/Chartmaker/HierarchyPanel.cs#L921

Code should not contain multiple blank lines in a row. (SA1507)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code should not contain multiple blank lines in a row.

Suggested change


if (item1.Target.Type == HierarchyItemType.World)
{
return rearrangeGroupAction(list[^1], "");
return rearrangeGroupAction(list[^1], "", 0);
}
if (item1.Target.Target is LaneGroup group1)
{
if (item1.Target.Children.Count > 0 && item1.Target.Expanded)
return rearrangeGroupAction(null, group1.Name);
return rearrangeGroupAction(null, group1.Name, group1.UUID);
else
return rearrangeGroupAction(group1, group1.Group);
return rearrangeGroupAction(group1, group1.Group, group1.GroupUuid);
}
}
}
Expand Down
Loading