Skip to content
Snippets Groups Projects
Commit 63893d4c authored by MaZiFAU's avatar MaZiFAU
Browse files

Hot Patching Null Reference

Known Bugs:
+null reference when generating Demo files
parent 7bd80b2a
No related branches found
No related tags found
No related merge requests found
...@@ -267,7 +267,7 @@ public static void GenerateCanonBallStage2D() ...@@ -267,7 +267,7 @@ public static void GenerateCanonBallStage2D()
SOMDoc.MakeTupel(new OMLIT<float>[] { new((float)PythonParams[i].y1), new((float)PythonParams[i].y2) }), SOMDoc.MakeTupel(new OMLIT<float>[] { new((float)PythonParams[i].y1), new((float)PythonParams[i].y2) }),
}); });
} }
StageStatic.stage.solution.Add( string RRRRURI = StageStatic.stage.solution.Add(
new ListFact(null, RRRRTupel, null), new ListFact(null, RRRRTupel, null),
out bool _, true, null, null out bool _, true, null, null
); );
...@@ -292,6 +292,13 @@ public static void GenerateCanonBallStage2D() ...@@ -292,6 +292,13 @@ public static void GenerateCanonBallStage2D()
// Set Gadgets/ Scrolls // Set Gadgets/ Scrolls
StageStatic.stage.AllowedGadgets = null; StageStatic.stage.AllowedGadgets = null;
StageStatic.stage.AllowedScrolls = new() { MMTConstants.ScrollCannonBall2D }; StageStatic.stage.AllowedScrolls = new() { MMTConstants.ScrollCannonBall2D };
StageStatic.stage.solution.ScrollOverwrites.Add(MMTConstants.ScrollCannonBall2D, new[] {
(BallURI, 0, true),
(VecURI, 1, true),
(GravURI, 2, true),
(BounceURI, 3, true),
(RRRRURI, 4, true),
});
// Save // Save
StageStatic.SetMode(StageStatic.Mode.Create); StageStatic.SetMode(StageStatic.Mode.Create);
...@@ -481,7 +488,7 @@ public static void GenerateCanonBallStage3D() ...@@ -481,7 +488,7 @@ public static void GenerateCanonBallStage3D()
// Set Solution // Set Solution
#region CannonBallScroll #region CannonBallScroll
StageStatic.stage.solution.Add( // for CannonBallScroll string TriangleURI = StageStatic.stage.solution.Add( // for CannonBallScroll
new ListFact(Trieangles.Select(q => q.Id).ToArray(), null, new OMS(MMTConstants.TYPE_TO_OMS[typeof(TriangleFact)])), new ListFact(Trieangles.Select(q => q.Id).ToArray(), null, new OMS(MMTConstants.TYPE_TO_OMS[typeof(TriangleFact)])),
out bool _, true, null, null out bool _, true, null, null
); );
...@@ -494,7 +501,7 @@ public static void GenerateCanonBallStage3D() ...@@ -494,7 +501,7 @@ public static void GenerateCanonBallStage3D()
Walls[i].Pids.Select(p => new OMS(p)).ToArray() Walls[i].Pids.Select(p => new OMS(p)).ToArray()
); );
} }
StageStatic.stage.solution.Add( string QuadURI = StageStatic.stage.solution.Add(
new ListFact(null, RRRRTupel, null), new ListFact(null, RRRRTupel, null),
out bool _, true, null, null out bool _, true, null, null
); );
...@@ -524,6 +531,20 @@ public static void GenerateCanonBallStage3D() ...@@ -524,6 +531,20 @@ public static void GenerateCanonBallStage3D()
// Set Gadgets/ Scrolls // Set Gadgets/ Scrolls
StageStatic.stage.AllowedGadgets = null; StageStatic.stage.AllowedGadgets = null;
StageStatic.stage.AllowedScrolls = new() { MMTConstants.ScrollCannonBall3D, MMTConstants.ScrollCannonBallT3D }; StageStatic.stage.AllowedScrolls = new() { MMTConstants.ScrollCannonBall3D, MMTConstants.ScrollCannonBallT3D };
StageStatic.stage.solution.ScrollOverwrites.Add(MMTConstants.ScrollCannonBall3D, new[] {
(BallURI, 0, true),
(VecURI, 1, true),
(GravURI, 2, true),
(BounceURI, 3, true),
(QuadURI, 4, true),
});
StageStatic.stage.solution.ScrollOverwrites.Add(MMTConstants.ScrollCannonBallT3D, new[] {
(BallURI, 0, true),
(VecURI, 1, true),
(GravURI, 2, true),
(BounceURI, 3, true),
(TriangleURI, 4, true),
});
// Save // Save
StageStatic.SetMode(StageStatic.Mode.Create); StageStatic.SetMode(StageStatic.Mode.Create);
......
...@@ -646,7 +646,9 @@ protected bool DependentFactsEquivalent(T f1, T f2) ...@@ -646,7 +646,9 @@ protected bool DependentFactsEquivalent(T f1, T f2)
.Zip(f2.DependentFactIds, .Zip(f2.DependentFactIds,
(id1, id2) => (id1, id2) =>
id1 == id2 id1 == id2
|| FactRecorder.AllFacts[id1].Equivalent(FactRecorder.AllFacts[id2]) || (FactRecorder.AllFacts.ContainsKey(id1)
&& FactRecorder.AllFacts.ContainsKey(id2)
&& FactRecorder.AllFacts[id1].Equivalent(FactRecorder.AllFacts[id2]))
) )
.All(b => b); .All(b => b);
} }
......
...@@ -403,9 +403,9 @@ public class DynamicTupleFact : FactWrappedCRTP<DynamicTupleFact>, IUnpackable ...@@ -403,9 +403,9 @@ public class DynamicTupleFact : FactWrappedCRTP<DynamicTupleFact>, IUnpackable
protected override object GetCompiledValue() => payload; protected override object GetCompiledValue() => payload;
[JsonIgnore] [JsonIgnore]
object payload; object payload = null;
int count; int count = 0;
[JsonIgnore] [JsonIgnore]
public Type[] Signature => _Signature ??= payload.GetType().GetGenericArguments(); public Type[] Signature => _Signature ??= payload.GetType().GetGenericArguments();
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using MoreLinq;
using Newtonsoft.Json; using Newtonsoft.Json;
using static CommunicationEvents; using static CommunicationEvents;
...@@ -24,11 +25,12 @@ private const string ...@@ -24,11 +25,12 @@ private const string
/// </summary> /// </summary>
public List<SubSolution> ValidationSet = new(); public List<SubSolution> ValidationSet = new();
/// <summary> /// <summary> Contains <see cref="Fact.Id"/>s which are being exposed to the Player </summary>
/// Contains <see cref="Fact.Id"/>s which are being exposed to the Player
/// </summary>
public List<string> ExposedSolutionFacts = new(); public List<string> ExposedSolutionFacts = new();
/// <summary> Maps <see cref="REST_JSON_API.Scroll.ScrollReference"/>s to settings to apply to itself. </summary>
public Dictionary<string, (string Id, int index, bool show)[]> ScrollOverwrites = new();
/// <summary> /// <summary>
/// Sits at the heart, but represents only a part of the whole Solution. /// Sits at the heart, but represents only a part of the whole Solution.
/// </summary> /// </summary>
...@@ -159,6 +161,12 @@ SolutionRecorder IJSONsavable<SolutionRecorder>._IJPostProcess(SolutionRecorder ...@@ -159,6 +161,12 @@ SolutionRecorder IJSONsavable<SolutionRecorder>._IJPostProcess(SolutionRecorder
.Select(fid => old_to_new[fid]) .Select(fid => old_to_new[fid])
.ToList(); .ToList();
payload.ScrollOverwrites = raw_payload.ScrollOverwrites
.Select(kv => new KeyValuePair<string, (string Id, int index, bool show)[]>(
kv.Key,
kv.Value.Select(t => (old_to_new[t.Id], t.index, t.show)).ToArray())
).ToDictionary();
return payload; return payload;
} }
......
...@@ -43,7 +43,8 @@ public static ScrollDetails Instance ...@@ -43,7 +43,8 @@ public static ScrollDetails Instance
private bool DynamicScrollInQue = false; private bool DynamicScrollInQue = false;
private bool MagicInQue = false; private bool MagicInQue = false;
private readonly IReadOnlyList<string> NoDynamicScroll = new List<string>() { private readonly IReadOnlyList<string> NoDynamicScroll = new List<string>()
{
// Insert ScrollURIS that are poorly optimized // Insert ScrollURIS that are poorly optimized
}; };
...@@ -107,6 +108,15 @@ public void SetScroll(Scroll scroll_to_set) ...@@ -107,6 +108,15 @@ public void SetScroll(Scroll scroll_to_set)
originalRSF.Populate(ActiveScroll, i); originalRSF.Populate(ActiveScroll, i);
} }
if (StageStatic.stage.solution.ScrollOverwrites
.TryGetValue(ActiveScroll.ScrollReference, out (string, int, bool)[] population)
)
foreach ((string Id, int index, bool show) in population)
{
ParameterDisplays[index].URI = Id;
ParameterDisplays[index].transform.parent.gameObject.SetActive(show);
}
foreach (int i in PrePopulateActiveScroll()) foreach (int i in PrePopulateActiveScroll())
ParameterDisplays[i].transform.parent.gameObject.SetActive(false); ParameterDisplays[i].transform.parent.gameObject.SetActive(false);
} }
...@@ -116,8 +126,7 @@ public bool SetNextEmptyTo(FactObjectUI activator) ...@@ -116,8 +126,7 @@ public bool SetNextEmptyTo(FactObjectUI activator)
RenderedScrollFact check = ParameterDisplays RenderedScrollFact check = ParameterDisplays
.Find(RSF => RSF != null .Find(RSF => RSF != null
&& RSF.Payload != null && RSF.Payload != null
&& RSF.Payload.Equals(activator) && RSF.Payload.Equals(activator));
);
if (check != null) if (check != null)
{ {
......
...@@ -49,10 +49,15 @@ public class Stage : IJSONsavable<Stage> ...@@ -49,10 +49,15 @@ public class Stage : IJSONsavable<Stage>
[JsonIgnore, JSONsavable.JsonSeparate] [JsonIgnore, JSONsavable.JsonSeparate]
public SaveGame savegame = null; public SaveGame savegame = null;
[JsonProperty] // unused, but could be for resuming
private string record_index;
public List<PlayerRecord> solution_approches = new(); public List<PlayerRecord> solution_approches = new();
public List<string> AllowedScrolls = null; public List<string> AllowedScrolls = null;
public List<Gadget> AllowedGadgets = null; public List<Gadget> AllowedGadgets = null;
//TODO: auto fill for scrolls, take from solution
#region makros/shortcuts #region makros/shortcuts
/// <summary> /// <summary>
...@@ -73,8 +78,6 @@ public PlayerRecord player_record ...@@ -73,8 +78,6 @@ public PlayerRecord player_record
value.CopyExposedSolutionFacts(this); value.CopyExposedSolutionFacts(this);
} }
} }
[JsonProperty] // unused, but could be for resuming
private string record_index;
/// <summary> /// <summary>
/// A list containing all saved player progress. <br/> /// A list containing all saved player progress. <br/>
......
...@@ -27,6 +27,9 @@ public static List<TriangleFact> GenerateMMTCollider(GameObject obj = null) ...@@ -27,6 +27,9 @@ public static List<TriangleFact> GenerateMMTCollider(GameObject obj = null)
foreach (BoxCollider coll in FindObjectsOfType<BoxCollider>()) foreach (BoxCollider coll in FindObjectsOfType<BoxCollider>())
{ {
if(!UseMe(coll))
continue;
Vector3[] minmax = new Vector3[] Vector3[] minmax = new Vector3[]
{ {
coll.center - coll.size/2, coll.center - coll.size/2,
...@@ -60,7 +63,8 @@ void _TrisAdd(uint i, uint j, uint k) ...@@ -60,7 +63,8 @@ void _TrisAdd(uint i, uint j, uint k)
//foreach (MeshCollider coll in FindObjectsOfType<MeshCollider>()) //foreach (MeshCollider coll in FindObjectsOfType<MeshCollider>())
//{ //{
// if (!coll.sharedMesh.isReadable) // if (!UseMe(coll)
// || !coll.sharedMesh.isReadable)
// continue; // continue;
// for (int i = 0; i < coll.sharedMesh.triangles.Length; i += 3) // for (int i = 0; i < coll.sharedMesh.triangles.Length; i += 3)
...@@ -100,6 +104,8 @@ Vector3 _Transform(Vector3 vert, Matrix4x4 toworld) ...@@ -100,6 +104,8 @@ Vector3 _Transform(Vector3 vert, Matrix4x4 toworld)
Vector4 h = toworld * new Vector4(vert.x, vert.y, vert.z, 1f); Vector4 h = toworld * new Vector4(vert.x, vert.y, vert.z, 1f);
return new Vector3(h.x, h.y, h.z); return new Vector3(h.x, h.y, h.z);
} }
bool UseMe(Collider coll) => true; //TODO: filter for what we want
} }
/// <summary> /// <summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment