Skip to content

Commit a387eed

Browse files
committed
Revert "Maybe this did something?"
This reverts commit 1926a9c.
1 parent 1926a9c commit a387eed

8 files changed

Lines changed: 244 additions & 194 deletions

File tree

Assets/Scripts/Models/Scene/SceneReducers.cs

Lines changed: 230 additions & 178 deletions
Large diffs are not rendered by default.

Assets/Scripts/Models/Scene/SceneState.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ namespace Models.Scene
1111
[Serializable]
1212
public record SceneState
1313
{
14-
public ProbeState[] Probes = Array.Empty<ProbeState>();
15-
public ManipulatorState[] Manipulators = Array.Empty<ManipulatorState>();
14+
public List<ProbeState> Probes = new();
15+
public List<ManipulatorState> Manipulators = new();
1616

1717
#region Active Probe
1818

@@ -24,7 +24,7 @@ public record SceneState
2424
Probes.FirstOrDefault(state => state.Name == ActiveProbeName);
2525

2626
// Helper to get the active probe index.
27-
public int ActiveProbeIndex => Array.IndexOf(Probes, ActiveProbeState);
27+
public int ActiveProbeIndex => Probes.IndexOf(ActiveProbeState);
2828

2929
#endregion
3030

@@ -38,7 +38,7 @@ public record SceneState
3838
Manipulators.FirstOrDefault(state => state.Id == ActiveManipulatorId);
3939

4040
// Helper to get the active probe index.
41-
public int ActiveManipulatorIndex => Array.IndexOf(Manipulators, ActiveManipulatorState);
41+
public int ActiveManipulatorIndex => Manipulators.IndexOf(ActiveManipulatorState);
4242

4343
#endregion
4444

Assets/Scripts/Pinpoint/Probes/Controllers/CartesianProbeController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ public void DragMovementClick()
676676
var startingProbeState = startingSceneState.Probes.FirstOrDefault(state => state.Name == name);
677677

678678
if (EventSystem.current.IsPointerOverGameObject() || startingProbeState == null ||
679-
startingSceneState.Manipulators.Any(state => state.VisualizationProbeName == name) ||
679+
startingSceneState.Manipulators.Exists(state => state.VisualizationProbeName == name) ||
680680
startingProbeState.Locked) return;
681681
#else
682682
if (EventSystem.current.IsPointerOverGameObject() || ProbeManager.IsEphysLinkControlled || UnlockedDir != Vector4.one)
@@ -738,7 +738,7 @@ public void DragMovementDrag()
738738

739739
// Exit if there is no state.
740740
if (currentProbeState == null ||
741-
currentSceneState.Manipulators.Any(state => state.VisualizationProbeName == name) ||
741+
currentSceneState.Manipulators.Exists(state => state.VisualizationProbeName == name) ||
742742
currentProbeState.Locked) return;
743743
#else
744744
if (ProbeManager.IsEphysLinkControlled || UnlockedDir != Vector4.one)

Assets/Scripts/Pinpoint/Probes/Controllers/SagittalCoronalProbeController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ public void DragMovementClick()
669669
var startingProbeState = startingSceneState.Probes.FirstOrDefault(state => state.Name == name);
670670

671671
if (EventSystem.current.IsPointerOverGameObject() || startingProbeState == null ||
672-
startingSceneState.Manipulators.Any(state => state.VisualizationProbeName == name) ||
672+
startingSceneState.Manipulators.Exists(state => state.VisualizationProbeName == name) ||
673673
startingProbeState.Locked) return;
674674
#else
675675
if (EventSystem.current.IsPointerOverGameObject() || ProbeManager.IsEphysLinkControlled || UnlockedDir != Vector4.one)
@@ -731,7 +731,7 @@ public void DragMovementDrag()
731731

732732
// Exit if there is no state.
733733
if (currentProbeState == null ||
734-
currentSceneState.Manipulators.Any(state => state.VisualizationProbeName == name) ||
734+
currentSceneState.Manipulators.Exists(state => state.VisualizationProbeName == name) ||
735735
currentProbeState.Locked) return;
736736
#else
737737
if (ProbeManager.IsEphysLinkControlled || UnlockedDir != Vector4.one)

Assets/Scripts/Pinpoint/Probes/SurfaceCoordinate.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Linq;
21
using Models;
32
using Models.Scene;
43
using Models.Settings;
@@ -89,7 +88,7 @@ private void OnProbeWorldStateChanged(ProbeWorldState probeWorldState)
8988
// Update color to match probe color - need to get from SceneState
9089
var storeService = PinpointApp.Services.GetRequiredService<StoreService>();
9190
var sceneState = storeService.Store.GetState<SceneState>(SliceNames.SCENE_SLICE);
92-
var probeState = sceneState.Probes.FirstOrDefault(p => p.Name == _activeProbeWorldStateName);
91+
var probeState = sceneState.Probes.Find(p => p.Name == _activeProbeWorldStateName);
9392

9493
if (probeState != null)
9594
{

Assets/Scripts/Pinpoint/TP_InPlaneSlice.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Linq;
32
using System.Threading.Tasks;
43
using TMPro;
54
using UnityEngine;
@@ -91,7 +90,7 @@ private void Start()
9190
state =>
9291
{
9392
var sceneState = state.Get<SceneState>(SliceNames.SCENE_SLICE);
94-
return sceneState.Probes.FirstOrDefault(p => p.Name == sceneState.ActiveProbeName);
93+
return sceneState.Probes.Find(p => p.Name == sceneState.ActiveProbeName);
9594
},
9695
probeState =>
9796
{

Assets/Scripts/UI/ViewModels/ProbeListItemViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public ProbeListItemViewModel(ProbeState probeState, StoreService storeService)
3838

3939
IsVisualizationProbe = storeService
4040
.Store.GetState<SceneState>(SliceNames.SCENE_SLICE)
41-
.Manipulators.Any(state => state.VisualizationProbeName == probeState.Name);
41+
.Manipulators.Exists(state => state.VisualizationProbeName == probeState.Name);
4242
Color = _probeState.Color;
4343
Name = _probeState.Name;
4444
Hidden = _probeState.ProbeDisplayType == ProbeDisplayType.Line;

Assets/Scripts/UI/ViewModels/SceneViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ private void HandleActiveProbeChange(string newActiveProbeName)
147147
/// <summary>
148148
/// Check if any probe positions or angles have changed and trigger collision detection if so
149149
/// </summary>
150-
private void CheckForProbeMovement(ProbeState[] currentProbeStates)
150+
private void CheckForProbeMovement(List<ProbeState> currentProbeStates)
151151
{
152152
// If this is the first time or probe count changed, just update the cache
153-
if (_previousProbeStates.Count != currentProbeStates.Length)
153+
if (_previousProbeStates.Count != currentProbeStates.Count)
154154
{
155155
_previousProbeStates = currentProbeStates.Select(p => p).ToList();
156156
ColliderManager.CheckForCollisions();
@@ -159,7 +159,7 @@ private void CheckForProbeMovement(ProbeState[] currentProbeStates)
159159

160160
// Check if any probe's position or angles have changed
161161
bool probesMoved = false;
162-
for (int i = 0; i < currentProbeStates.Length; i++)
162+
for (int i = 0; i < currentProbeStates.Count; i++)
163163
{
164164
var current = currentProbeStates[i];
165165
var previous = _previousProbeStates.FirstOrDefault(p => p.Name == current.Name);

0 commit comments

Comments
 (0)