Skip to content
Snippets Groups Projects
Commit 8fa3d1ad authored by MaZiFAU's avatar MaZiFAU
Browse files

Refactored; BugFix;

Refactored:
+FactWrapper,Object,AttachedFuncFact
+Fact.SendToMMT: asynchron

BugFix:
+ OMDoc/RAW in Scroll msg => added RAW
parent b12afe2d
No related branches found
No related tags found
No related merge requests found
Showing
with 1554 additions and 1481 deletions
......@@ -117,7 +117,20 @@ public static void GenerateRiverStage()
// Set Gadgets/ Scrolls
StageStatic.stage.AllowedGadgets = new() { new Pointer(), new Tape(), new AngleTool(), new LineTool(), new LotTool(), new Pendulum(), new Remover() }; //, new EqualCircleGadget(), new TestMiddlePoint() };
StageStatic.stage.AllowedScrolls = new() { "OppositeLen" };//, "AngleSum", "Pythagoras", "CircleScroll", "CircleAreaScroll", "ConeVolumeScroll", "TruncatedConeVolumeScroll", "CylinderVolumeScroll", "MidPoint", "CircleLineAngleScroll", "CircleLineAngleToAngle", "SupplementaryAngles" };
StageStatic.stage.AllowedScrolls = new() {
"http://mathhub.info/FrameIT/frameworld?OppositeLen",
//"http://mathhub.info/FrameIT/frameworld?SupplementaryAngles",
//"http://mathhub.info/FrameIT/frameworld?AngleSum",
//"http://mathhub.info/FrameIT/frameworld?Pythagoras",
//"http://mathhub.info/FrameIT/frameworld?CylinderVolumeScroll",
//"http://mathhub.info/FrameIT/frameworld?CircleLineAngleToAngleScroll",
//"http://mathhub.info/FrameIT/frameworld?Midpoint",
//"http://mathhub.info/FrameIT/frameworld?CircleScroll",
//"http://mathhub.info/FrameIT/frameworld?CircleLineAngleScroll",
//"http://mathhub.info/FrameIT/frameworld?CircleAreaScroll",
//"http://mathhub.info/FrameIT/frameworld?ConeVolumeScroll",
//"http://mathhub.info/FrameIT/frameworld?TruncatedConeVolumeScroll",
};
// Save
StageStatic.SetMode(StageStatic.Mode.Create);
......@@ -226,7 +239,7 @@ public static void GenerateCanonBallStage()
out _, false, null, null);
StageStatic.stage.solution.ExposedSolutionFacts.Add(BallURI);
CanonBallProblemCalculator calc = new (Walls, StartPos, StartVec, Gravity, dim_const, dim_A, dim_B, StageStatic.stage.solution);
CanonBallProblemCalculator calc = new(Walls, StartPos, StartVec, Gravity, dim_const, dim_A, dim_B, StageStatic.stage.solution);
string attacheFactURI = StageStatic.stage.solution.Add(
new AttachedPositionFunction(BallURI, calc.Result_FuncCall_Id.ToArray(), StageStatic.stage.solution),
......
......@@ -2,6 +2,19 @@
public class GlobalBehaviour : MonoBehaviour, ISerializationCallbackReceiver
{
public static GlobalBehaviour Instance
{
get => _Instance;
set
{
if (_Instance == null)
_Instance = value;
else
Destroy(value);
}
}
private static GlobalBehaviour _Instance;
//Make sure when using RGBA-Colors, the A-value of animationStartColor
//and animationEndColor is the same OR try with value = 255
public static Color hintAnimationStartColor;
......@@ -56,4 +69,9 @@ void ISerializationCallbackReceiver.OnBeforeSerialize()
_GadgetPhysicalDistance = GadgetPhysicalDistance;
}
#endregion
private void Awake()
{
Instance = this;
}
}
......@@ -9,43 +9,9 @@
/// <summary>
/// <see cref="Fact.Id"/>/ <c>MonoBehaviour</c> wrapper to be attached to <see cref="Fact.Representation"/>
/// </summary>
//[DisallowMultipleComponent]
public class FactObject : MonoBehaviour, ISerializationCallbackReceiver
[DisallowMultipleComponent]
public class FactObject : FactWrapper, ISerializationCallbackReceiver
{
/// <summary>
/// <see cref="Fact.Id"/> to identify arbitrary <see cref="Fact"/> by its <see cref="Fact.Representation"/>
/// </summary>
public string URI
{
get => _URI;
set
{
_Fact = null;
_URI = value;
FactUpdated();
}
}
private string _URI;
/// <summary>
/// Shorthand and Cache for <see cref="FactOrganizer.AllFacts.TryGetValue(string, out Fact)"/>.
/// </summary>
public Fact Fact
{
get
{
if (_Fact == null) FactOrganizer.AllFacts.TryGetValue(URI, out _Fact);
return _Fact;
}
set
{
_Fact = value;
_URI = value.Id;
FactUpdated();
}
}
private Fact _Fact;
public enum FactMaterials
{
Default = 0,
......@@ -131,7 +97,7 @@ private void Awake()
AllChildren.Remove(this);
}
protected virtual void FactUpdated()
protected override void FactUpdated()
{
Awake();
......@@ -141,7 +107,7 @@ protected virtual void FactUpdated()
{
childObject._URI = _URI;
childObject._Fact = null;
childObject.FactUpdated();
childObject.ReLabel();
}
}
......
using UnityEngine;
/// <summary>
/// <see cref="Fact.Id"/> <c>MonoBehaviour</c> wrapper to be attached to a <see cref="GameObject"/>
/// </summary>
public abstract class FactWrapper : MonoBehaviour//, ISerializationCallbackReceiver
{
/// <summary>
/// <see cref="Fact.Id"/> to identify arbitrary <see cref="Fact"/> by its <see cref="Fact.Representation"/>
/// </summary>
public string URI
{
get => _URI;
set
{
_Fact = null;
_URI = value;
FactUpdated();
}
}
[HideInInspector, SerializeField]
protected string _URI;
/// <summary>
/// Shorthand and Cache for <see cref="FactOrganizer.AllFacts.TryGetValue(string, out Fact)"/>.
/// </summary>
public Fact Fact
{
get
{
if (_Fact == null) FactOrganizer.AllFacts.TryGetValue(URI, out _Fact);
return _Fact;
}
set
{
_Fact = value;
_URI = value.Id;
FactUpdated();
}
}
protected Fact _Fact;
protected abstract void FactUpdated();
}
\ No newline at end of file
fileFormatVersion: 2
guid: ba6d0bde735420141a43a09a220c99d9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -133,7 +133,7 @@ public AngleFact(string pid1, string pid2, string pid3, FactOrganizer organizer)
angle = is_right_angle ? 90f : angle;
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
/// <summary>
......@@ -225,7 +225,7 @@ public RightAngleFact(string pid1, string pid2, string pid3, FactOrganizer organ
{
angle = 90f;
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
/// <summary>
......
......@@ -134,7 +134,7 @@ public LineFact(string pid1, string pid2, string backendURI, FactOrganizer organ
/// <summary> \copydoc AbstractLineFact.AbstractLineFact(string, string, FactOrganizer) </summary>
public LineFact(string pid1, string pid2, FactOrganizer organizer) : base(pid1, pid2, organizer)
{
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override MMTDeclaration MakeMMTDeclaration()
......@@ -198,7 +198,7 @@ public RayFact(string pid1, string pid2, string backendURI, FactOrganizer organi
/// <summary> \copydoc AbstractLineFact.AbstractLineFact(string, string, FactOrganizer) </summary>
public RayFact(string pid1, string pid2, FactOrganizer organizer) : base(pid1, pid2, organizer)
{
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override MMTDeclaration MakeMMTDeclaration()
......
......@@ -2,11 +2,12 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using TMPro;
using Newtonsoft.Json;
using JsonSubTypes;
using System.Linq;
using static SOMDocManager;
using System.Collections;
using static Scroll;
public static class ParsingDictionary
{
......@@ -62,66 +63,6 @@ public static class ParsingDictionary
public static Dictionary<string, string> parseTermsToId = new();
}
/// <summary>
/// class to Read AddFact Responses.
/// </summary>
// TODO: docu
public class AddFactResponse
{
public string uri;
public static bool sendAdd(MMTDeclaration mmtDecl, out string uri)
{
string body = MMTSymbolDeclaration.ToJson(mmtDecl);
bool success = sendAdd(CommunicationEvents.ServerAdress + "/fact/add", body, out uri);
if (mmtDecl is MMTSymbolDeclaration mMTSymbol && mMTSymbol.defines != null)
ParsingDictionary.parseTermsToId[mMTSymbol.defines.ToString()] = uri;
return success;
}
public static bool sendAdd(string path, string body, out string uri)
{
if (!CommunicationEvents.ServerRunning)
{
Debug.LogWarning("Server not running");
uri = null;
return false;
}
if (CommunicationEvents.VerboseURI)
Debug.Log("Sending to Server:\n" + body);
//Put constructor parses stringbody to byteArray internally (goofy workaround)
using UnityWebRequest www = UnityWebRequest.Put(path, body);
www.method = UnityWebRequest.kHttpVerbPOST;
www.SetRequestHeader("Content-Type", "application/json");
www.timeout = 1;
//TODO: implement real asynchronous communication ...
AsyncOperation op = www.SendWebRequest();
while (!op.isDone) ;
if (www.result == UnityWebRequest.Result.ConnectionError
|| www.result == UnityWebRequest.Result.ProtocolError)
{
Debug.LogWarning(www.error);
uri = null;
return false;
}
else
{
string answer = www.downloadHandler.text;
AddFactResponse res = JsonUtility.FromJson<AddFactResponse>(answer);
if (CommunicationEvents.VerboseURI)
Debug.Log("Server added Fact:\n" + res.uri);
uri = res.uri;
return true;
}
}
}
/// <summary>
/// %Fact representation of Unity; mostly mirrors Facts of MMT.
......@@ -190,15 +131,20 @@ public abstract class Fact
/// <value>
/// Unique Id. e.g.: MMT URI
/// </value>
[JsonIgnore]
public string Id
{
get { return _URI; }
set { _URI ??= value; } // needed for JSON
get
{
while (FetchURICoroutine.MoveNext()) ; //active wait for server
return _URI;
}
}
/// <summary>
/// MMT URI
/// </summary>
[JsonProperty]
protected string _URI;
/// <value>
......@@ -303,6 +249,7 @@ protected set
}
private Vector3 _LocalScale;
private IEnumerator FetchURICoroutine = IEnumeratorExtensions.yield_break;
/// <summary>
/// Only being used by [JsonReader](https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_JsonReader.htm) to initiate empty \ref Fact "Facts".
......@@ -461,6 +408,74 @@ public static Fact parseFact(MMTDeclaration fact)
LabelId = -LabelId;
}
}
public void SendToMMT()
{
MMTDeclaration mmtDecl = MakeMMTDeclaration();
GlobalBehaviour.Instance.StartCoroutine(
FetchURICoroutine = sendAdd(
CommunicationEvents.ServerAdress + "/fact/add",
mmtDecl.ToJson(),
(string uri) => sendURICallback(mmtDecl, uri)
));
return;
void sendURICallback(MMTDeclaration mmtDecl, string uri)
{
this._URI = uri;
if (mmtDecl is MMTSymbolDeclaration mMTSymbol && mMTSymbol.defines != null)
ParsingDictionary.parseTermsToId[mMTSymbol.defines.ToString()] = uri;
}
IEnumerator sendAdd(string path, string body, Action<string> uriCallback)
{
if (!CommunicationEvents.ServerRunning)
{
Debug.LogWarning("Server not running");
uriCallback(null);
yield break;
}
if (CommunicationEvents.VerboseURI)
Debug.Log("Sending to Server:\n" + body);
//Put constructor parses stringbody to byteArray internally (goofy workaround)
using UnityWebRequest www = UnityWebRequest.Put(path, body);
www.method = UnityWebRequest.kHttpVerbPOST;
www.SetRequestHeader("Content-Type", "application/json");
www.timeout = 1;
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.ConnectionError
|| www.result == UnityWebRequest.Result.ProtocolError)
{
Debug.LogWarning(www.error);
uriCallback(null);
yield break;
}
else
{
string answer = null;
while (string.IsNullOrEmpty(answer))
{
yield return null;
answer = www.downloadHandler.text;
}
UriReference res = JsonUtility.FromJson<UriReference>(answer);
if (CommunicationEvents.VerboseURI)
Debug.Log("Server added Fact:\n" + res.uri);
uriCallback(res.uri);
yield break;
}
}
}
}
/// <summary>
......@@ -526,7 +541,7 @@ public PointFact(Vector3 P, Vector3 N, FactOrganizer organizer) : base(organizer
this.Point = P;
this.Normal = N;
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform()
......@@ -571,7 +586,7 @@ public PointFact(Vector3 point, string uri, FactOrganizer organizer) : base(orga
public override bool HasDependentFacts => false;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { };
/// \copydoc Fact.GetHashCode
......@@ -635,7 +650,7 @@ public OnLineFact(string pid, string rid, FactOrganizer organizer) : base(organi
this.Pid = pid;
this.Rid = rid;
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform()
......@@ -698,7 +713,7 @@ protected override string generateLabel()
public override bool HasDependentFacts => true;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { Pid, Rid };
protected override bool EquivalentWrapped(OnLineFact f1, OnLineFact f2)
......@@ -759,7 +774,7 @@ public ParallelLineFact(string lid1, string lid2, FactOrganizer organizer) : bas
this.Lid1 = lid1;
this.Lid2 = lid2;
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform() { }
......@@ -826,7 +841,7 @@ protected override MMTDeclaration MakeMMTDeclaration()
public override bool HasDependentFacts => true;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { Lid1, Lid2 };
/// \copydoc Fact.Equivalent(Fact, Fact)
......@@ -883,7 +898,7 @@ public CircleFact(string pid1, string pid2, float radius, Vector3 normal, FactOr
this.radius = radius;
this.normal = normal;
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform()
......@@ -1016,7 +1031,7 @@ protected override MMTDeclaration MakeMMTDeclaration()
public override bool HasDependentFacts => true;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { Pid1, Pid2 };
/// \copydoc Fact.Equivalent(Fact, Fact)
......@@ -1063,7 +1078,7 @@ public OnCircleFact(string pid, string cid, FactOrganizer organizer) : base(orga
this.Pid = pid;
this.Cid = cid; ;
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform()
......@@ -1111,7 +1126,7 @@ protected override string generateLabel()
public override bool HasDependentFacts => true;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { Pid, Cid };
/// \copydoc Fact.Equivalent(Fact, Fact)
......@@ -1186,7 +1201,7 @@ public AngleCircleLineFact(string cid1, string rid2, FactOrganizer organizer) :
this.angle = Math3d.AngleVectorPlane(Ray.Dir, Circle.normal).ToDegrees();
Math3d.LinePlaneIntersection(out intersection, Ray.Point1.Position, Ray.Dir, Circle.normal, Circle.Position);
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform()
......@@ -1280,7 +1295,7 @@ protected override MMTDeclaration MakeMMTDeclaration()
public override bool HasDependentFacts => true;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { Cid1, Rid2 };
/// \copydoc Fact.Equivalent(Fact, Fact)
......@@ -1323,7 +1338,7 @@ public RadiusFact(string cid1, FactOrganizer organizer) : base(organizer)
this.Cid1 = cid1;
this.rad = Circle.radius;
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform()
......@@ -1387,7 +1402,7 @@ protected override MMTDeclaration MakeMMTDeclaration()
public override bool HasDependentFacts => true;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { Cid1 };
/// \copydoc Fact.Equivalent(Fact, Fact)
......@@ -1432,7 +1447,7 @@ public AreaCircleFact(string cid1, FactOrganizer organizer) : base(organizer)
this.A = Circle.radius * Circle.radius * ((float)System.Math.PI);
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform()
......@@ -1490,7 +1505,7 @@ protected override MMTDeclaration MakeMMTDeclaration()
public override bool HasDependentFacts => true;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { Cid1 };
/// \copydoc Fact.GetHashCode
......@@ -1545,7 +1560,7 @@ public ConeVolumeFact(string cid1, string pid1, float vol, FactOrganizer organiz
this.Pid1 = pid1;
this.vol = vol;
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform()
......@@ -1676,7 +1691,7 @@ public OrthogonalCircleLineFact(string cid1, string lid1, FactOrganizer organize
this.Lid1 = lid1;
Math3d.LinePlaneIntersection(out intersection, Ray.Point1.Position, Ray.Dir, Circle.normal, Circle.Position);
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform()
......@@ -1756,7 +1771,7 @@ protected override MMTDeclaration MakeMMTDeclaration()
public override bool HasDependentFacts => true;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { Cid1, Lid1 };
/// \copydoc Fact.Equivalent(Fact, Fact)
......@@ -1817,7 +1832,7 @@ public TruncatedConeVolumeFact(string cid1, string cid2, float vol, string unequ
this.unequalCirclesProof = unequalproof;
this.vol = vol;
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform()
......@@ -1891,7 +1906,7 @@ protected override MMTDeclaration MakeMMTDeclaration()
public override bool HasDependentFacts => true;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { Cid1, Cid2 };
/// \copydoc Fact.Equivalent(Fact, Fact)
......@@ -1951,7 +1966,7 @@ public CylinderVolumeFact(string cid1, string cid2, float vol, string eqProof, O
this.equalCirclesProof = eqProof;
this.vol = vol;
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform()
......@@ -2026,7 +2041,7 @@ protected override MMTDeclaration MakeMMTDeclaration()
public override bool HasDependentFacts => true;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { Cid1, Cid2, equalCirclesProof };
/// \copydoc Fact.Equivalent(Fact, Fact)
......@@ -2072,7 +2087,7 @@ public EqualCirclesFact(string cid1, string cid2, FactOrganizer organizer) : bas
this.Cid1 = cid1;
this.Cid2 = cid2;
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform()
......@@ -2143,7 +2158,7 @@ protected override MMTDeclaration MakeMMTDeclaration()
public override bool HasDependentFacts => true;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { Cid1, Cid2 };
/// \copydoc Fact.Equivalent(Fact, Fact)
......@@ -2189,7 +2204,7 @@ public UnEqualCirclesFact(string cid1, string cid2, FactOrganizer organizer) : b
this.Cid1 = cid1;
this.Cid2 = cid2;
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform()
......@@ -2256,7 +2271,7 @@ protected override MMTDeclaration MakeMMTDeclaration()
public override bool HasDependentFacts => true;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { Cid1, Cid2 };
/// \copydoc Fact.Equivalent(Fact, Fact)
......@@ -2295,11 +2310,7 @@ public TestFact() : base()
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public TestFact(FactOrganizer organizer) : base(organizer)
{
// mmtDecl = generateCircleFactDeclaration(p1URI, p2URI, radius, normal);
AddFactResponse.sendAdd(MakeMMTDeclaration(), out this._URI);
SendToMMT();
}
protected override void RecalculateTransform() { }
......@@ -2332,18 +2343,18 @@ public TestFact(string backendURI, FactOrganizer organizer) : base(organizer)
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
protected override string generateLabel()
=> "test";
/// \copydoc Fact.hasDependentFacts
public override bool HasDependentFacts => false;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetGetDependentFactIds()
protected override string[] GetGetDependentFactIds()
=> new string[] { };
/// \copydoc Fact.GetHashCode
public override int GetHashCode()
public override int GetHashCode()
=> base.GetHashCode();// this.Pid1.GetHashCode() ^ this.Pid2.GetHashCode();
/// \copydoc Fact.Equivalent(Fact, Fact)
......
......@@ -17,7 +17,7 @@ public class ShinyThings : MonoBehaviour
private IEnumerator rain;
public Light directionalLight;
private Color darkColor = new (0.2f, 0.2f, 0.2f);
private Color darkColor = new(0.2f, 0.2f, 0.2f);
private Color light_colour;
private GameObject active_rainwork;
......@@ -131,8 +131,9 @@ IEnumerator BlossomAndDie()
public void LetItRain(Fact startFact, Scroll.ScrollApplicationInfo _)
{
// check if couroutine is waiting
if (!rain_wait.MoveNext()) {
// check if couroutine is waiting or finished
if (!rain_wait.MoveNext() || !rain.MoveNext())
{
StopCoroutine(rain);
StartCoroutine(rain = BlossomAndDie());
}
......
......@@ -4,7 +4,7 @@
using UnityEngine;
public class AttachedPositionFunctionBehaviour : FactObject
public class AttachedPositionFunctionBehaviour : FactWrapper
{
private Transform startcondition;
......@@ -49,31 +49,16 @@ public void NewExecutingInstance()
if (!original)
return;
GameObject clone = Instantiate(gameObject);
clone.GetComponent<FactObject>().URI = (Fact as AttachedPositionFunction).Fact.Id;
AttachedPositionFunctionBehaviour cloneComp =
Instantiate(gameObject)
.GetComponent<AttachedPositionFunctionBehaviour>();
AttachedPositionFunctionBehaviour cloneComp =
clone.GetComponent<AttachedPositionFunctionBehaviour>();
cloneComp.URI = URI;
cloneComp.original = false;
cloneComp.Start();
cloneComp.FactUpdated();
cloneComp.StartExecution();
}
private void Awake()
{
// TODO! SE: not great, but terrible
AllChildren = new();
FactText = new();
StringLabelFormats = new();
}
// TODO! SE: not great, but terrible
protected override void FactUpdated() { }
private void Start()
{
protected override void FactUpdated(){
startcondition = transform;
f_t_to_pos = (Fact as AttachedPositionFunction).FunctionCallFacts.ToList();
}
......
......@@ -52,7 +52,7 @@ private void Compute()
SOMDoc BuildOMA_XVA()
{ //Pos = Pos + Vel * t + 0.5 * g * t**2
return
new OMBINDC("Pos", typeof(Vector3),
new OMBINDC("Pos", MMT_OMS_URI.Tuple,
new OMBINDC("Vel", typeof(Vector3),
new OMBINDC("Acc", typeof(Vector3),
new OMBINDC("t", "R",
......@@ -167,11 +167,7 @@ float SolveForDistanceOnPlane(Vector3 Pos, Vector3 Vel, LineFact Top, float t)
.SelectMany(wt => new[] { (wt.w, t: wt.tarr.Item1), (wt.w, t: wt.tarr.Item2) })
.Where(wt => wt.t >= 0)
.Select(wt => (wt.w, wt.t, x: SolveForDistanceOnPlane(pos, vel, wt.w.Topology, wt.t)))
.Where(wt =>
{
float dist = SolveForDistanceOnPlane(pos, vel, wt.w.Topology, wt.t);
return dist >= 0 && dist <= wt.w.Topology.Distance;
})
.Where(wt => wt.x >= 0 && wt.x <= wt.w.Topology.Distance)
.OrderBy(wt => wt.t)
.ToArray();
......
......@@ -101,14 +101,16 @@ IEnumerator getScrollsfromServer()
void BuildScrolls(string jsonString)
{
System.DateTime startTime = System.DateTime.UtcNow;
AvailableScrolls = JsonConvert.DeserializeObject<List<Scroll>>(jsonString);
Debug.Log("Scroll Parsing in: " + (System.DateTime.UtcNow - startTime).TotalMilliseconds + "ms");
AllowedScrolls = AvailableScrolls
.Where(s => StageStatic.stage.AllowedScrolls?.Contains(s.label) ?? true)
.Where(s => StageStatic.stage.AllowedScrolls?.Contains(s.@ref) ?? true)
.ToList();
ScrollButtons = new GameObject[AllowedScrolls.Count()];
//Build Selection-GUI of Scrolls
ScrollButtons = new GameObject[AllowedScrolls.Count()];
for (int i = 0; i < AllowedScrolls.Count; i++)
{
var obj = Instantiate(ScrollPrefab, Vector3.zero, Quaternion.identity, scrollscreenContent);
......
......@@ -294,6 +294,7 @@ private static LambdaExpression MakeArray(LambdaExpression[] args_lamda, Paramet
[JsonSubtypes.KnownSubType(typeof(OMSTR), "OMSTR")]
[JsonSubtypes.KnownSubType(typeof(OMF), "OMF")]
[JsonSubtypes.KnownSubType(typeof(OMV), "OMV")]
[JsonSubtypes.KnownSubType(typeof(RAW), "RAW")]
//[JsonSubtypes.KnownSubType(typeof(OMC<T>), "OMC<" + typeof(T) + ">")]
[JsonSubtypes.KnownSubType(typeof(OMC<Vector3>), "OMC<UnityEngine.Vector3>")]
[JsonSubtypes.KnownSubType(typeof(OMC<float>), "OMC<System.Single>")]
......@@ -411,7 +412,6 @@ public abstract class SOMDocCRTP<T> : SOMDoc where T : SOMDocCRTP<T>
{
protected SOMDocCRTP() : base() { }
/// \copydoc Fact.Equivalent(Fact)
public override bool Equivalent(SOMDoc sd2)
=> this.GetType() == sd2.GetType() && (this as T).EquivalentWrapped(sd2 as T);
......@@ -658,6 +658,38 @@ public override OMV MapURIsWrapped(Dictionary<string, string> old_to_new)
=> (OMV)this.MemberwiseClone();
}
public class RAW : SOMDocCRTP<RAW>
{
public new string kind = "RAW";
public string xml;
[JsonConstructor]
public RAW(string xml) : base()
{
this.xml = xml;
}
public override RAW MapURIsWrapped(Dictionary<string, string> old_to_new)
{
string copy = xml;
foreach (KeyValuePair<string, string> KeyVal in old_to_new)
copy = copy.Replace(KeyVal.Key, KeyVal.Value);
return new RAW(copy);
}
public override string ToString()
=> xml;
protected override bool EquivalentWrapped(RAW sd2)
=> throw new NotImplementedException(); //xml == sd2.xml; // only exact
protected internal override LambdaExpression GetLambdaExpression(LambdaExpression[] lambda_args, ParameterExpression[] bound_params)
{
throw new NotImplementedException();
}
}
[JsonConverter(typeof(JsonSubtypes), "kind")]
[JsonSubtypes.KnownSubType(typeof(MMTSymbolDeclaration), "general")]
......@@ -676,12 +708,10 @@ public static MMTDeclaration FromJson(string json)
return mmtDecl;
}
public static string ToJson(MMTDeclaration mmtDecl)
public string ToJson()
{
mmtDecl.label ??= string.Empty;
string json = JsonConvert.SerializeObject(mmtDecl);
return json;
label ??= string.Empty;
return JsonConvert.SerializeObject(this);
}
public abstract string getType();
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -8,7 +8,7 @@
"ValidationSet": [
{
"MasterIDs": [
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3800"
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3"
],
"SolutionIndex": [],
"RelationIndex": [],
......@@ -21,17 +21,17 @@
"-1": null
},
"MetaInf": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3798": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact1": {
"workflow_id": 0,
"active": true,
"isImmutable": false
},
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3799": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact2": {
"workflow_id": 1,
"active": true,
"isImmutable": false
},
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3800": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3": {
"workflow_id": 2,
"active": true,
"isImmutable": false
......@@ -39,34 +39,34 @@
},
"Workflow": [
{
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3798",
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact1",
"samestep": false,
"steplink": 3,
"creation": true,
"gadget_rank": -1,
"scroll_label": null,
"GadgetFlow": [],
"GadgetTime": 0.17582429997855797
"GadgetTime": 7.678122400000575
},
{
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3799",
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact2",
"samestep": true,
"steplink": 0,
"creation": true,
"gadget_rank": -1,
"scroll_label": null,
"GadgetFlow": [],
"GadgetTime": 0.17582429997855797
"GadgetTime": 7.678122400000575
},
{
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3800",
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3",
"samestep": true,
"steplink": 0,
"creation": true,
"gadget_rank": -1,
"scroll_label": null,
"GadgetFlow": [],
"GadgetTime": 0.17582429997855797
"GadgetTime": 7.678122400000575
}
],
"marker": 3,
......@@ -77,7 +77,7 @@
"MaxLabelId": 2,
"UnusedLabelIds": [],
"JsonFactSpace": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3798": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact1": {
"Point": {
"x": 0.0,
"y": 0.0,
......@@ -93,13 +93,13 @@
"sqrMagnitude": 1.0
},
"s_type": "PointFact",
"_URI": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact1",
"DependentFactIds": [],
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3798",
"Label": "A",
"hasCustomLabel": false,
"LabelId": 1
},
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3799": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact2": {
"Point": {
"x": 0.0,
"y": 6.0,
......@@ -122,16 +122,16 @@
"sqrMagnitude": 1.0
},
"s_type": "PointFact",
"_URI": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact2",
"DependentFactIds": [],
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3799",
"Label": "B",
"hasCustomLabel": false,
"LabelId": 2
},
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3800": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3": {
"s_type": "LineFact",
"Pid1": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3798",
"Pid2": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3799",
"Pid1": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact1",
"Pid2": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact2",
"Dir": {
"x": 0.0,
"y": -1.0,
......@@ -139,11 +139,11 @@
"magnitude": 1.0,
"sqrMagnitude": 1.0
},
"_URI": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3",
"DependentFactIds": [
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3798",
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3799"
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact1",
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact2"
],
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3800",
"Label": "[AB]",
"hasCustomLabel": false,
"LabelId": 0
......
......@@ -8,7 +8,7 @@
"ValidationSet": [
{
"MasterIDs": [
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3803"
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact6"
],
"SolutionIndex": [],
"RelationIndex": [],
......@@ -16,7 +16,7 @@
},
{
"MasterIDs": [
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3803"
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact6"
],
"SolutionIndex": [],
"RelationIndex": [],
......@@ -39,17 +39,17 @@
"-1": null
},
"MetaInf": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3801": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact4": {
"workflow_id": 0,
"active": true,
"isImmutable": false
},
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3802": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact5": {
"workflow_id": 1,
"active": true,
"isImmutable": false
},
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3803": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact6": {
"workflow_id": 2,
"active": true,
"isImmutable": false
......@@ -57,34 +57,34 @@
},
"Workflow": [
{
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3801",
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact4",
"samestep": false,
"steplink": 3,
"creation": true,
"gadget_rank": -1,
"scroll_label": null,
"GadgetFlow": [],
"GadgetTime": 0.17582429997855797
"GadgetTime": 7.678122400000575
},
{
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3802",
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact5",
"samestep": true,
"steplink": 0,
"creation": true,
"gadget_rank": -1,
"scroll_label": null,
"GadgetFlow": [],
"GadgetTime": 0.17582429997855797
"GadgetTime": 7.678122400000575
},
{
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3803",
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact6",
"samestep": true,
"steplink": 0,
"creation": true,
"gadget_rank": -1,
"scroll_label": null,
"GadgetFlow": [],
"GadgetTime": 0.17582429997855797
"GadgetTime": 7.678122400000575
}
],
"marker": 3,
......@@ -95,7 +95,7 @@
"MaxLabelId": 2,
"UnusedLabelIds": [],
"JsonFactSpace": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3801": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact4": {
"Point": {
"x": 0.0,
"y": 0.0,
......@@ -111,13 +111,13 @@
"sqrMagnitude": 1.0
},
"s_type": "PointFact",
"_URI": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact4",
"DependentFactIds": [],
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3801",
"Label": "A",
"hasCustomLabel": false,
"LabelId": 1
},
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3802": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact5": {
"Point": {
"x": 0.0,
"y": 6.0,
......@@ -140,16 +140,16 @@
"sqrMagnitude": 1.0
},
"s_type": "PointFact",
"_URI": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact5",
"DependentFactIds": [],
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3802",
"Label": "B",
"hasCustomLabel": false,
"LabelId": 2
},
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3803": {
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact6": {
"s_type": "LineFact",
"Pid1": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3801",
"Pid2": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3802",
"Pid1": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact4",
"Pid2": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact5",
"Dir": {
"x": 0.0,
"y": -1.0,
......@@ -157,11 +157,11 @@
"magnitude": 1.0,
"sqrMagnitude": 1.0
},
"_URI": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact6",
"DependentFactIds": [
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3801",
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3802"
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact4",
"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact5"
],
"Id": "http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact3803",
"Label": "[AB]",
"hasCustomLabel": false,
"LabelId": 0
......@@ -172,7 +172,7 @@
},
"solution_approches": [],
"AllowedScrolls": [
"OppositeLen"
"http://mathhub.info/FrameIT/frameworld?OppositeLen"
],
"AllowedGadgets": [
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment