Skip to content

Commit b77f69a

Browse files
committed
feat: RigData model
1 parent f9643ed commit b77f69a

File tree

7 files changed

+50
-12
lines changed

7 files changed

+50
-12
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class DataManager : MonoBehaviour
6+
{
7+
// Start is called before the first frame update
8+
void Start()
9+
{
10+
11+
}
12+
13+
// Update is called once per frame
14+
void Update()
15+
{
16+
17+
}
18+
}

Assets/Scripts/Pinpoint/JSON/DataManager.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/Pinpoint/JSON/RigData.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ public struct RigData
66
{
77
public string Name;
88
public Vector3 Position;
9-
10-
public string AtlasName;
11-
public string TransformName;
9+
public bool Active;
1210
}

Assets/Scripts/Pinpoint/Probes/ProbeManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ private void SetMaterialsLine()
10861086
}
10871087

10881088
[Serializable]
1089-
public struct ProbeData
1089+
public struct ProbeManagerData
10901090
{
10911091
// ProbeInsertion
10921092
public Vector3 APMLDV;
@@ -1117,9 +1117,9 @@ public struct ProbeData
11171117
public bool Drop2SurfaceWithDepth;
11181118
public bool IsRightHanded;
11191119

1120-
public static ProbeData ProbeManager2ProbeData(ProbeManager probeManager)
1120+
public static ProbeManagerData ProbeManager2ProbeData(ProbeManager probeManager)
11211121
{
1122-
ProbeData data = new ProbeData();
1122+
ProbeManagerData data = new ProbeManagerData();
11231123

11241124
data.APMLDV = probeManager.ProbeController.Insertion.apmldv;
11251125
data.Angles = probeManager.ProbeController.Insertion.angles;

Assets/Scripts/Pinpoint/TP_ToggleRigs.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,25 @@ public class TP_ToggleRigs : MonoBehaviour
1010
// Exposed list of rig UI objects
1111
[SerializeField] private GameObject _rigUIParentGO;
1212

13+
private RigData[] _rigData;
14+
public RigData[] Data { get { return _rigData; } }
15+
1316
// Start is called before the first frame update
1417
void Start()
1518
{
19+
_rigData = new RigData[_rigGOs.Count];
20+
1621
for (int i = 0; i < _rigGOs.Count; i++)
1722
{
1823
string rigKey = $"rig{i}";
1924
bool active = PlayerPrefs.HasKey(rigKey) && (PlayerPrefs.GetInt(rigKey, 0) == 1);
2025

2126
_rigGOs[i].SetActive(active);
2227
_rigUIParentGO.transform.GetChild(i).gameObject.GetComponent<Toggle>().SetIsOnWithoutNotify(active);
28+
29+
_rigData[i].Active = active;
30+
_rigData[i].Position = _rigGOs[i].transform.position;
31+
_rigData[i].Name = _rigGOs[i].name;
2332
}
2433
}
2534

@@ -28,6 +37,7 @@ public void ToggleRigVisibility(int rigIdx)
2837
bool active = _rigUIParentGO.transform.GetChild(rigIdx).GetComponent<Toggle>().isOn;
2938

3039
_rigGOs[rigIdx].SetActive(active);
40+
_rigData[rigIdx].Active = active;
3141

3242
Collider[] colliders = _rigGOs[rigIdx].transform.GetComponentsInChildren<Collider>();
3343
if (active)

Assets/Scripts/Pinpoint/TrajectoryPlannerManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public void DestroyProbe(ProbeManager probeManager)
331331
{
332332
var isActiveProbe = ProbeManager.ActiveProbeManager == probeManager;
333333

334-
_prevProbeData = JsonUtility.ToJson(ProbeData.ProbeManager2ProbeData(probeManager));
334+
_prevProbeData = JsonUtility.ToJson(ProbeManagerData.ProbeManager2ProbeData(probeManager));
335335

336336
// Cannot restore a ghost probe, so we set restored to true
337337
_restoredProbe = false;
@@ -390,7 +390,7 @@ private void RecoverActiveProbeController()
390390
{
391391
if (_restoredProbe) return;
392392

393-
ProbeData probeData = JsonUtility.FromJson<ProbeData>(_prevProbeData);
393+
ProbeManagerData probeData = JsonUtility.FromJson<ProbeManagerData>(_prevProbeData);
394394

395395
// Don't duplicate probes by accident
396396
if (!ProbeManager.Instances.Any(x => x.UUID.Equals(probeData.UUID)))
@@ -758,7 +758,7 @@ private List<string> GetActiveProbeJSON()
758758
ProbeManager probe = nonGhostProbeManagers[i];
759759

760760
if (probe.Saved)
761-
data.Add(JsonUtility.ToJson(ProbeData.ProbeManager2ProbeData(probe)));
761+
data.Add(JsonUtility.ToJson(ProbeManagerData.ProbeManager2ProbeData(probe)));
762762
}
763763

764764
return data;
@@ -772,7 +772,7 @@ private string GetActiveProbeJSONFlattened()
772772
for (int i = 0; i < nonGhostProbeManagers.Count; i++)
773773
{
774774
ProbeManager probe = nonGhostProbeManagers[i];
775-
data.Add(JsonUtility.ToJson(ProbeData.ProbeManager2ProbeData(probe)));
775+
data.Add(JsonUtility.ToJson(ProbeManagerData.ProbeManager2ProbeData(probe)));
776776
}
777777

778778
return string.Join(";", data);
@@ -896,7 +896,7 @@ private void LoadSavedProbesFromStringArray(string[] savedProbes)
896896
{
897897
Debug.Log(savedProbe);
898898

899-
ProbeData probeData = JsonUtility.FromJson<ProbeData>(savedProbe);
899+
ProbeManagerData probeData = JsonUtility.FromJson<ProbeManagerData>(savedProbe);
900900

901901
// Don't duplicate probes by accident
902902
if (!ProbeManager.Instances.Any(x => x.UUID.Equals(probeData.UUID)))

Assets/Scripts/Pinpoint/trajectoryplanner.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"GUID:1487851fb22c2cc4a85babd43c153c20",
2525
"GUID:20582ac19d7f4684f93b0c5ef62b2bcd",
2626
"GUID:baba835d3f6de1948879ba12c4c45295",
27-
"GUID:91360e4fc352e484eb74c8004f903d9c"
27+
"GUID:91360e4fc352e484eb74c8004f903d9c",
28+
"GUID:607bd5b74fabd34449aca1e00d3c898e"
2829
],
2930
"includePlatforms": [],
3031
"excludePlatforms": [],

0 commit comments

Comments
 (0)