Connect scenery safety, drag camera and resume geometry in the game prefab
This commit is contained in:
@@ -12,6 +12,25 @@ namespace MagnetismHeroes.Editor
|
||||
public static class PlaygroundRestoreGeometryAssets
|
||||
{
|
||||
public const string CachePath = "Assets/MagnetismHeroes/UnityRuntime/Bootstrap/PlaygroundRestoreGeometry.asset";
|
||||
public static void BindGameApp()
|
||||
{
|
||||
var cache = AssetDatabase.LoadAssetAtPath<PlaygroundRestoreGeometry>(CachePath);
|
||||
if (cache == null) throw new InvalidOperationException("Restore geometry must exist before binding the game prefab.");
|
||||
const string path = "Assets/MagnetismHeroes/UnityRuntime/Presentation/Prefabs/GameApp.prefab";
|
||||
var prefab = PrefabUtility.LoadPrefabContents(path);
|
||||
try
|
||||
{
|
||||
var app = prefab.GetComponent<GameApp>();
|
||||
var data = new SerializedObject(app);
|
||||
var reference = data.FindProperty("_restoreGeometry");
|
||||
if (reference.objectReferenceValue == cache) return;
|
||||
Undo.RecordObject(app, "Bind playground restore geometry");
|
||||
reference.objectReferenceValue = cache; data.ApplyModifiedPropertiesWithoutUndo();
|
||||
EditorUtility.SetDirty(app); PrefabUtility.SaveAsPrefabAsset(prefab, path);
|
||||
Debug.Log("Bound the existing read-only restore geometry to the game prefab.");
|
||||
}
|
||||
finally { PrefabUtility.UnloadPrefabContents(prefab); }
|
||||
}
|
||||
public static void CreateCache()
|
||||
{
|
||||
if (AssetDatabase.LoadMainAssetAtPath(CachePath) != null) throw new InvalidOperationException("Restore geometry already exists; verify before replacing it.");
|
||||
|
||||
@@ -29,8 +29,6 @@ namespace MagnetismHeroes.Tests
|
||||
foreach (var camera in Object.FindObjectsByType<Camera>(FindObjectsSortMode.None)) camera.enabled = false;
|
||||
_app = Object.Instantiate(AssetDatabase.LoadAssetAtPath<GameObject>("Assets/MagnetismHeroes/UnityRuntime/Presentation/Prefabs/GameApp.prefab")).GetComponent<GameApp>();
|
||||
_store = new MemoryStore(); _app.Initialize(_store); _app.StartStage(6); _app.Voice.Clear();
|
||||
_app.Presenter.BindEnvironment(_app.Environment);
|
||||
_app.Orbit.BindEnvironment(_app.Environment);
|
||||
_disabledScenery.Clear();
|
||||
foreach (var collider in _app.Environment.GetComponentsInChildren<Collider>())
|
||||
if (!collider.isTrigger && !collider.name.Contains("Clearing") && collider.enabled) { _disabledScenery.Add(collider); collider.enabled = false; }
|
||||
|
||||
@@ -42,12 +42,10 @@ namespace MagnetismHeroes.Tests
|
||||
_app = Object.Instantiate(AssetDatabase.LoadAssetAtPath<GameObject>("Assets/MagnetismHeroes/UnityRuntime/Presentation/Prefabs/GameApp.prefab")).GetComponent<GameApp>();
|
||||
_store = new Store { Save = new ProgressSave { completedStageIds = Enumerable.Range(1, 30).ToArray(), seenTutorialIds = new[] { "merge", "split" } } };
|
||||
_app.Initialize(_store);
|
||||
_app.Presenter.BindEnvironment(_app.Environment);
|
||||
_app.BindRestoreGeometry(AssetDatabase.LoadAssetAtPath<PlaygroundRestoreGeometry>("Assets/MagnetismHeroes/UnityRuntime/Bootstrap/PlaygroundRestoreGeometry.asset"));
|
||||
yield return null;
|
||||
}
|
||||
[UnityTearDown] public IEnumerator Teardown() { foreach (var fixture in _fixtures) Object.Destroy(fixture); _fixtures.Clear(); Object.Destroy(_app.gameObject); yield return null; }
|
||||
private void Reload() { _app.Initialize(_store); _app.Presenter.BindEnvironment(_app.Environment); }
|
||||
private void Reload() { _app.Initialize(_store); }
|
||||
private TMP_Text Text(string field) => (TMP_Text)new SerializedObject(_app).FindProperty(field).objectReferenceValue;
|
||||
private BoxCollider Box(Vector3 center, Vector3 size)
|
||||
{
|
||||
|
||||
@@ -31,8 +31,6 @@ namespace MagnetismHeroes.Tests
|
||||
foreach (var camera in Object.FindObjectsByType<Camera>(FindObjectsSortMode.None)) camera.enabled = false;
|
||||
_app = Object.Instantiate(AssetDatabase.LoadAssetAtPath<GameObject>("Assets/MagnetismHeroes/UnityRuntime/Presentation/Prefabs/GameApp.prefab")).GetComponent<GameApp>();
|
||||
_store = new MemoryStore(); _app.Initialize(_store); _app.StartStage(6); _app.Voice.Clear();
|
||||
// Explicit test wiring until the single GameApp writer connects this production reference.
|
||||
_app.Presenter.BindEnvironment(_app.Environment);
|
||||
// Keep the real clearing; isolate movement cases from the unrelated authored props.
|
||||
foreach (var collider in _app.Environment.GetComponentsInChildren<Collider>())
|
||||
if (!collider.isTrigger && !collider.name.Contains("Clearing")) collider.enabled = false;
|
||||
|
||||
@@ -86,6 +86,8 @@ namespace MagnetismHeroes.UnityRuntime.Bootstrap
|
||||
}
|
||||
public void Initialize(IProgressStore store)
|
||||
{
|
||||
_presenter.BindEnvironment(_environment);
|
||||
_orbit.BindEnvironment(_environment);
|
||||
Session = new GameSession(_stages.Select(stage => stage.ToDefinition()), store);
|
||||
Session.SaveFinished += ShowSaveResult;
|
||||
_saveNotice.text = Session.LastSaveError == null ? "" : Session.LastSaveError.StartsWith("Recovered", StringComparison.Ordinal)
|
||||
|
||||
@@ -8509,6 +8509,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c76b84d0084f787458ed6a2d3cff26cf, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: MagnetismHeroes.UnityRuntime::MagnetismHeroes.UnityRuntime.Presentation.BoardEnvironment
|
||||
_collisionTolerance: 0.001
|
||||
--- !u!1 &5310382666504661114
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -10935,6 +10936,7 @@ MonoBehaviour:
|
||||
_nextButton: {fileID: 3927298547665816229}
|
||||
_environment: {fileID: 1624884106493650387}
|
||||
_demonstration: {fileID: 7659519030918255868}
|
||||
_restoreGeometry: {fileID: 11400000, guid: bbbd7c6c248fe414da209364fa007ca1, type: 2}
|
||||
--- !u!114 &5074812012251702751
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -10951,6 +10953,15 @@ MonoBehaviour:
|
||||
_minDistance: 3
|
||||
_maxDistance: 15
|
||||
_degreesPerPixel: 0.25
|
||||
_minElevation: -89
|
||||
_maxElevation: 89
|
||||
_collisionMargin: 0.35
|
||||
_assistSpeed: 6
|
||||
_assistAngle: 90
|
||||
_assistElevation: 30
|
||||
_nearbyDistance: 5
|
||||
_candidateHysteresis: 0.4
|
||||
_screenMargin: 0.12
|
||||
--- !u!114 &4917121841105511015
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
Reference in New Issue
Block a user