Skip to content
Snippets Groups Projects
Commit b1d7e508 authored by Marco Zimmer's avatar Marco Zimmer
Browse files

+FactOrganizer: hid FactDict +Facts: re-renamed URI to Id, enabled persistend,...

+FactOrganizer: hid FactDict +Facts: re-renamed URI to Id, enabled persistend, generated and compact LabelNamingSpace
parent f50302c5
No related branches found
No related tags found
No related merge requests found
Showing
with 154 additions and 147 deletions
......@@ -31,6 +31,8 @@ public class TaskCharakterAnimation : MonoBehaviour
private float happyTime = 7.5f;
private static bool playerInTalkingZone = false;
// TODO: Level Reset doesn't reset this?
private static bool taskCharacterAddressed = false;
......
......@@ -82,36 +82,55 @@ public abstract class Fact
{
public GameObject Representation;
public string URI { get { return _URI; } }
public string Id { get { return _URI; } }
protected string _URI;
public string Label;
public string Label {
get { // in case of renamed dependables
return string.IsNullOrEmpty(_CustomLabel) ?
generateLabel() :
_CustomLabel;
}
}
protected string _CustomLabel = null;
private int LabelId = 0;
protected FactOrganizer _Facts;
private static int LabelId = 0;
private static int MaxLabelId = 0;
private static SortedSet<int> UnusedLabelIds = new SortedSet<int>();
protected Fact(FactOrganizer organizer)
{
this._Facts = organizer;
}
//TODO: notify about updated dependable Labelnames
public void rename(string newLabel)
{
this.Label = newLabel;
if (_Facts.ContainsLabel(newLabel))
return;
freeLabel();
_CustomLabel = newLabel;
}
//If FactType depends on other Facts, e.g. AngleFacts depend on 3 PointFacts
public abstract Boolean hasDependentFacts();
public abstract bool hasDependentFacts();
public abstract string[] getDependentFactIds();
public abstract GameObject instantiateDisplay(GameObject prefab, Transform transform);
public virtual void delete()
public virtual void delete(bool keep_clean = true)
{
//TODO: MMT: delete over there
if (keep_clean)
freeLabel();
if (VerboseURI)
Debug.Log("Server removed Fact:\n" + this.URI);
Debug.Log("Server removed Fact:\n" + this.Id);
}
public abstract bool Equivalent(Fact f2);
......@@ -120,26 +139,39 @@ public virtual void delete()
public abstract override int GetHashCode();
protected abstract string generateLabel();
// TODO: "ID"/ Letter Management
protected string generateLetter()
// TODO? only get _Fact to freeLabel/
public void freeLabel()
{
return ((char)(64 + LabelId++ + 1)).ToString();
if (LabelId > 0)
{
UnusedLabelIds.Add(LabelId);
// store Label for name-persistance
LabelId = -LabelId;
}
/* Keeping track of free Ids
private static List<int> NextEmpties = new List<int>();
NextEmpties.Add(LabelId++);
if (!string.IsNullOrEmpty(_CustomLabel))
_CustomLabel = null;
}
public int GetFirstEmptyID()
protected virtual string generateLabel()
{
if (LabelId == 0)
if (UnusedLabelIds.Count == 0)
LabelId = ++MaxLabelId;
else
{
LabelId = UnusedLabelIds.Min;
UnusedLabelIds.Remove(LabelId);
}
else if (LabelId < 0)
// reload Label if possible
{
NextEmpties.Sort();
LabelId = -LabelId;
UnusedLabelIds.Remove(LabelId);
}
int id = NextEmpties[0];
NextEmpties.RemoveAt(0);
if (NextEmpties.Count == 0)
NextEmpties.Add(LabelId++);
}*/
return ((char)(64 + LabelId)).ToString();
}
}
......@@ -186,7 +218,6 @@ private void set_public_members(string pid1, string pid2)
{
this.Pid1 = pid1;
this.Pid2 = pid2;
this.Label = generateLabel();
PointFact pf1 = _Facts[pid1] as PointFact;
PointFact pf2 = _Facts[pid2] as PointFact;
this.Dir = (pf2.Point - pf1.Point).normalized;
......@@ -237,7 +268,6 @@ public PointFact(Vector3 P, Vector3 N, FactOrganizer organizer) : base(organizer
{
this.Point = P;
this.Normal = N;
this.Label = generateLabel();
List<MMTTerm> arguments = new List<MMTTerm>
{
......@@ -259,7 +289,6 @@ public PointFact(float a, float b, float c, string uri, FactOrganizer organizer)
{
this.Point = new Vector3(a, b, c);
this.Normal = new Vector3(0, 1, 0);
this.Label = generateLabel();
this._URI = uri;
}
......@@ -278,11 +307,6 @@ public static PointFact parseFact(Scroll.ScrollFact fact) {
}
}
protected override string generateLabel()
{
return generateLetter();
}
public override Boolean hasDependentFacts() {
return false;
}
......@@ -326,8 +350,8 @@ public LineFact(string pid1, string pid2, FactOrganizer organizer) : base(pid1,
PointFact pf1 = _Facts[pid1] as PointFact;
PointFact pf2 = _Facts[pid2] as PointFact;
string p1URI = pf1.URI;
string p2URI = pf2.URI;
string p1URI = pf1.Id;
string p2URI = pf2.Id;
float v = (pf1.Point - pf2.Point).magnitude;
MMTTerm lhs =
......@@ -406,8 +430,8 @@ public RayFact(string pid1, string pid2, FactOrganizer organizer) : base(pid1, p
PointFact pf1 = _Facts[pid1] as PointFact;
PointFact pf2 = _Facts[pid2] as PointFact;
string p1URI = pf1.URI;
string p2URI = pf2.URI;
string p1URI = pf1.Id;
string p2URI = pf2.Id;
List<MMTTerm> arguments = new List<MMTTerm>
{
......@@ -449,7 +473,6 @@ protected override string generateLabel()
public override GameObject instantiateDisplay(GameObject prefab, Transform transform) {
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = this.Label;
//obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(Facts2[f.Pid2].Id);
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
......@@ -477,12 +500,11 @@ public OnLineFact(string pid, string rid, FactOrganizer organizer) : base(organi
{
this.Pid = pid;
this.Rid = rid;
this.Label = generateLabel();
PointFact pf = _Facts[pid] as PointFact;
RayFact rf = _Facts[rid] as RayFact;
string pURI = pf.URI;
string rURI = rf.URI;
string pURI = pf.Id;
string rURI = rf.Id;
List<MMTTerm> innerArguments = new List<MMTTerm>
{
......@@ -508,7 +530,6 @@ public OnLineFact(string pid, string rid, string uri, FactOrganizer organizer) :
{
this.Pid = pid;
this.Rid = rid;
this.Label = generateLabel();
this._URI = uri;
}
......@@ -586,12 +607,11 @@ public AngleFact(string pid1, string pid2, string pid3, FactOrganizer organizer)
PointFact pf3 = _Facts[pid3] as PointFact;
float v = GetAngle(); // sets is_right_angle
this.Label = generateLabel(); //needs is_right_angle
MMTDeclaration mmtDecl;
string p1URI = pf1.URI;
string p2URI = pf2.URI;
string p3URI = pf3.URI;
string p1URI = pf1.Id;
string p2URI = pf2.Id;
string p3URI = pf3.Id;
if (is_right_angle)
mmtDecl = generate90DegreeAngleDeclaration(v, p1URI, p2URI, p3URI);
else
......@@ -607,7 +627,6 @@ public AngleFact(string Pid1, string Pid2, string Pid3, string backendURI, FactO
this.Pid3 = Pid3;
GetAngle();
this.Label = generateLabel();
this._URI = backendURI;
}
......
......@@ -6,7 +6,7 @@ public abstract class FactComparer : EqualityComparer<Fact>
{
protected bool search_righthanded;
protected abstract bool Compare (Fact search, Fact fact);
protected abstract bool Compare (Fact solution, Fact fact);
public FactComparer SetSearchRight()
{
......@@ -26,25 +26,25 @@ public override bool Equals(Fact left, Fact right)
public override int GetHashCode(Fact obj)
{
return 0; //obj.GetHashCode();
return obj.GetType().GetHashCode();
}
}
public class FactEquivalentsComparer : FactComparer
{
protected override bool Compare (Fact search, Fact fact)
protected override bool Compare (Fact solution, Fact fact)
{
return search.Equivalent(fact);
return solution.Equivalent(fact);
}
}
class LineFactHightDirectionComparer : FactComparer
{
protected override bool Compare (Fact search, Fact fact)
protected override bool Compare (Fact solution, Fact fact)
{
return fact is LineFact && search is LineFact
&& Math3d.IsApproximatelyParallel(((LineFact) fact).Dir, ((LineFact) search).Dir)
&& ((LineFact) fact).Distance + Math3d.vectorPrecission >= ((LineFact) search).Distance;
return fact is LineFact && solution is LineFact
&& Math3d.IsApproximatelyParallel(((LineFact) fact).Dir, ((LineFact) solution).Dir)
&& ((LineFact) fact).Distance + Math3d.vectorPrecission >= ((LineFact) solution).Distance;
// && Mathf.Approximately(((LineFact) x).Distance, ((LineFact) y).Distance);
}
}
......@@ -50,7 +50,7 @@ void AddHitIfOnLine(RaycastHit hit)
{
if (Math3d.IsPointApproximatelyOnLine(rayP1.Point, rayFact.Dir, hit.transform.position))
{
AddOnLineFact(hit.transform.gameObject.GetComponent<FactObject>().URI, rayFact.URI, true);
AddOnLineFact(hit.transform.gameObject.GetComponent<FactObject>().URI, rayFact.Id, true);
}
}
......@@ -61,8 +61,8 @@ void AddHitIfOnLine(RaycastHit hit)
AddHitIfOnLine(hit);
// for good measure
AddOnLineFact(rayFact.Pid1, rayFact.URI, true);
AddOnLineFact(rayFact.Pid2, rayFact.URI, true);
AddOnLineFact(rayFact.Pid1, rayFact.Id, true);
AddOnLineFact(rayFact.Pid2, rayFact.Id, true);
return rayFact;
}
......
......@@ -4,18 +4,15 @@
using System.Linq;
//TODO? PERF? (often inserts) SortedDict <-> Dict (often reads)
//TODO? hide base dict
//TODO: MMT: move some functionality there
//TODO: consequent!= samestep != dependent
//PERF: avoid string as key (general: allocations & dict: hash -> colission? -> strcmp[!])
[System.Serializable]
public class FactOrganizer: Dictionary<string, Fact>
public class FactOrganizer
{
// InvokeEvents?
private bool invoke;
private Dictionary<string, Fact> FactDict;
private Dictionary<string, meta> MetaInf = new Dictionary<string, meta>();
private List<stepnote> Workflow = new List<stepnote>();
// notes position in Workflow for un-/redo; the pointed to element is non-acitve
......@@ -25,6 +22,8 @@ public class FactOrganizer: Dictionary<string, Fact>
private int backlog = 0;
// set if recently been resetted
private bool soft_resetted = false;
// InvokeEvents?
private bool invoke;
private struct stepnote
{
......@@ -52,7 +51,7 @@ public stepnote(string Id, bool samestep, bool creation, FactOrganizer that)
this.steplink = prev.samestep ? prev.steplink : that.marker - 1;
}
else
// steproot sets steplink after itself (end of steptail)
// steproot sets steplink after itself (end of steptail)
this.steplink = that.marker + 1;
}
......@@ -74,29 +73,49 @@ public meta(int workflow_id, bool active = true)
}
}
public FactOrganizer(bool invoke = false) : base()
public FactOrganizer(bool invoke = false)
{
FactDict = new Dictionary<string, Fact>();
this.invoke = invoke;
}
public FactOrganizer(IDictionary<string, Fact> dictionary, bool invoke = false) : base(dictionary)
public FactOrganizer(IDictionary<string, Fact> dictionary, bool invoke = false)
{
FactDict = new Dictionary<string, Fact>(dictionary);
this.invoke = invoke;
}
public Fact this[string id]
{
get{ return FactDict[id]; }
}
public bool ContainsKey(string id)
{
return FactDict.ContainsKey(id);
}
public bool ContainsLabel(string label)
{
if (string.IsNullOrEmpty(label))
return false;
var hit = FactDict.FirstOrDefault(e => e.Value.Label == label);
return !hit.Equals(System.Activator.CreateInstance(hit.GetType()));
}
//TODO? MMT? PERF: O(n), every Fact-insertion
private bool FindEquivalent(Fact search, out string found, out bool exact)
// Looks for existent facts (found) which are very similar to prposed fact (search)
// does not check active state
{
if (exact = this.ContainsKey(search.URI))
if (exact = FactDict.ContainsKey(search.Id))
{
found = search.URI;
found = search.Id;
return true;
}
foreach (var entry in this)
foreach (var entry in FactDict)
{
if (entry.Value.Equivalent(search))
{
......@@ -150,7 +169,7 @@ private void PruneWorkflow()
// remove for good, if original creation gets pruned
{
this[last.Id].delete();
base.Remove(last.Id);
FactDict.Remove(last.Id);
MetaInf.Remove(last.Id);
}
}
......@@ -160,12 +179,6 @@ private void PruneWorkflow()
}
}
public new void Add(string key, Fact value)
// hide
{
this.Add(value, out _);
}
public string Add(Fact value, out bool exists, bool samestep = false)
// also checks for duplicates and active state
// returns key of actual Fact
......@@ -192,8 +205,8 @@ public string Add(Fact value, out bool exists, bool samestep = false)
else
// brand new Fact
{
key = value.URI;
base.Add(key, value);
key = value.Id;
FactDict.Add(key, value);
MetaInf.Add(key, new meta(marker, true));
}
......@@ -201,21 +214,15 @@ public string Add(Fact value, out bool exists, bool samestep = false)
return key;
}
public new bool Remove(string key)
// hide
{
return this.Remove(key, false);
}
public bool Remove(Fact value, bool samestep = false)
{
return this.Remove(value.URI, samestep);
return this.Remove(value.Id, samestep);
}
public bool Remove(string key, bool samestep = false)
//no reset check needed (impossible state)
{
if (!base.ContainsKey(key))
if (!FactDict.ContainsKey(key))
return false;
//TODO: see issue #58
......@@ -332,10 +339,10 @@ public void redo()
}
}
public new void Clear()
public void Clear()
// Does not Invoke RemoveFactEvent(s)!
{
base.Clear();
FactDict.Clear();
MetaInf.Clear();
Workflow.Clear();
marker = 0;
......@@ -346,7 +353,7 @@ public void redo()
public void hardreset(bool invoke_event = true)
{
foreach(var entry in this)
foreach(var entry in FactDict)
{
if (invoke_event && invoke && MetaInf[entry.Key].active)
CommunicationEvents.RemoveFactEvent.Invoke(entry.Value);
......@@ -389,6 +396,7 @@ public void load(bool draw_all = true)
// call this after assigning a stored instance in an empty world
{
// TODO: see issue #58
// TODO: communication with MMT
foreach (var mett in MetaInf)
{
......@@ -422,6 +430,9 @@ private void InvokeFactEvent(bool creation, string Id)
CommunicationEvents.AddFactEvent.Invoke(this[Id]);
else
CommunicationEvents.RemoveFactEvent.Invoke(this[Id]);
if (!creation)
FactDict[Id].freeLabel();
}
public bool StaticlySovled(List<Fact> StaticSolution, out List<Fact> MissingElements, out List<Fact> Solutions)
......@@ -433,7 +444,7 @@ public bool StaticlySovled(List<Fact> StaticSolution, out List<Fact> MissingElem
//TODO: PERF: see CommunicationEvents.Solution
public bool DynamiclySolved(List<Fact> MinimalSolution, out List<Fact> MissingElements, out List<Fact> Solutions, FactComparer FactComparer)
{
Solutions = this.Values.Where(f => MetaInf[f.URI].active)
Solutions = FactDict.Values.Where(f => MetaInf[f.Id].active)
.Where(active => MinimalSolution.Contains(active, FactComparer.SetSearchRight()))
.ToList();
......
......@@ -56,7 +56,7 @@ public Fact SpawnPoint(Fact pointFact)
point.transform.position = fact.Point;
point.transform.up = fact.Normal;
point.GetComponentInChildren<TextMeshPro>().text = fact.Label;
point.GetComponent<FactObject>().URI = fact.URI;
point.GetComponent<FactObject>().URI = fact.Id;
fact.Representation = point;
return fact;
}
......@@ -92,7 +92,7 @@ public Fact SpawnLine(Fact fact)
//line.GetComponentInChildren<TextMeshPro>().text = letter;
line.GetComponentInChildren<TextMeshPro>().text = pointFact1.Label + pointFact2.Label;
line.GetComponentInChildren<TextMeshPro>().text += " = " + Math.Round((point1-point2).magnitude, 2) + " m";
line.GetComponentInChildren<FactObject>().URI = lineFact.URI;
line.GetComponentInChildren<FactObject>().URI = lineFact.Id;
lineFact.Representation = line;
return lineFact;
......@@ -134,7 +134,7 @@ public Fact SpawnRay(Fact fact)
line.transform.GetChild(0).rotation = Quaternion.FromToRotation(Vector3.right, point2 - point1);
line.GetComponentInChildren<TextMeshPro>().text = rayFact.Label;
line.GetComponentInChildren<FactObject>().URI = rayFact.URI;
line.GetComponentInChildren<FactObject>().URI = rayFact.Id;
rayFact.Representation = line;
return rayFact;
......@@ -190,7 +190,7 @@ public Fact SpawnAngle(Fact fact)
foreach (CircleSegmentGenerator c in segments)
c.setAngle(angleValue);
angle.GetComponentInChildren<FactObject>().URI = angleFact.URI;
angle.GetComponentInChildren<FactObject>().URI = angleFact.Id;
angleFact.Representation = angle;
return angleFact;
}
......
......@@ -56,9 +56,9 @@ public override void OnHit(RaycastHit hit)
{
//Create AngleFact
//Check if new Point is equal to one of the previous points -> if true -> cancel
if (!(this.angleModeFirstPointSelected.URI == tempFact.URI || this.angleModeSecondPointSelected.URI == tempFact.URI))
if (!(this.angleModeFirstPointSelected.Id == tempFact.Id || this.angleModeSecondPointSelected.Id == tempFact.Id))
{
FactManager.AddAngleFact(((PointFact)this.angleModeFirstPointSelected).URI, ((PointFact)this.angleModeSecondPointSelected).URI, ((PointFact)tempFact).URI);
FactManager.AddAngleFact(((PointFact)this.angleModeFirstPointSelected).Id, ((PointFact)this.angleModeSecondPointSelected).Id, ((PointFact)tempFact).Id);
}
ResetGadget();
......@@ -67,7 +67,7 @@ public override void OnHit(RaycastHit hit)
else if (this.angleModeIsFirstPointSelected && !this.angleModeIsSecondPointSelected)
{
//Check if the 2 selected points are the same: If not
if (this.angleModeFirstPointSelected.URI != tempFact.URI)
if (this.angleModeFirstPointSelected.Id != tempFact.Id)
{
this.angleModeIsSecondPointSelected = true;
this.angleModeSecondPointSelected = tempFact;
......@@ -135,32 +135,8 @@ public void ActivateCurveDrawing()
public void UpdateCurveDrawing(Vector3 currentPosition)
{
//TODO! PERF O(n)
//Find the nearest of all potential third points
PointFact nearestPoint = null;
foreach (var entry in LevelFacts)
{
Fact fact = entry.Value;
if (fact is PointFact && fact.URI != angleModeFirstPointSelected.URI && fact.URI != angleModeSecondPointSelected.URI && nearestPoint == null)
nearestPoint = (PointFact)fact;
else if (fact is PointFact && fact.URI != angleModeFirstPointSelected.URI && fact.URI != angleModeSecondPointSelected.URI && (nearestPoint.Point - currentPosition).magnitude > (((PointFact)fact).Point - currentPosition).magnitude)
nearestPoint = (PointFact)fact;
}
Vector3 startPoint = new Vector3(0, 0, 0);
if (nearestPoint != null)
{
Vector3 planePoint = Vector3.ProjectOnPlane(currentPosition, Vector3.Cross((nearestPoint.Point - angleMiddlePoint), (curveEndPoint - angleMiddlePoint)));
//Determine the Start-Point for the nearest third-point
startPoint = angleMiddlePoint + curveRadius * (planePoint - angleMiddlePoint).normalized;
}
else
{
//Determine the Start-Point
startPoint = angleMiddlePoint + curveRadius * (currentPosition - angleMiddlePoint).normalized;
}
//Determine the Start-Point
Vector3 startPoint = angleMiddlePoint + curveRadius * (currentPosition - angleMiddlePoint).normalized;
//Determine the Center of Start-Point and End-Point
Vector3 tempCenterPoint = Vector3.Lerp(startPoint, curveEndPoint, 0.5f);
......
......@@ -43,10 +43,10 @@ public override void OnHit(RaycastHit hit)
Fact tempFact = LevelFacts[hit.transform.GetComponent<FactObject>().URI];
//If first point was already selected AND second point != first point
if (this.LineModeIsFirstPointSelected && this.LineModeFirstPointSelected.URI != tempFact.URI)
if (this.LineModeIsFirstPointSelected && this.LineModeFirstPointSelected.Id != tempFact.Id)
{
//Create LineFact
FactManager.AddRayFact(this.LineModeFirstPointSelected.URI, tempFact.URI);
FactManager.AddRayFact(this.LineModeFirstPointSelected.Id, tempFact.Id);
this.ResetGadget();
}
......@@ -72,8 +72,8 @@ public override void OnHit(RaycastHit hit)
{
//Create LineFact
var idA = downHit.transform.gameObject.GetComponent<FactObject>().URI;
var idB = this.LineModeFirstPointSelected.URI;
FactManager.AddAngleFact(idA, idB, FactManager.AddPointFact(hit).URI);
var idB = this.LineModeFirstPointSelected.Id;
FactManager.AddAngleFact(idA, idB, FactManager.AddPointFact(hit).Id);
this.ResetGadget();
}
......
......@@ -65,7 +65,7 @@ void CreateRayAndAngles(string pidIntersectionPoint, string pidLotPoint, bool sa
Vector3 LotPoint = Math3d.ProjectPointOnLine(hit.point, this.LotModeLineSelected.Dir, this.LotModeIntersectionPoint.Point);
//TODO: which normal?
CreateRayAndAngles(this.LotModeIntersectionPoint.URI, FactManager.AddPointFact(LotPoint, hit.normal).URI, true);
CreateRayAndAngles(this.LotModeIntersectionPoint.Id, FactManager.AddPointFact(LotPoint, hit.normal).Id, true);
this.ResetGadget();
}
......@@ -85,12 +85,12 @@ void CreateRayAndAngles(string pidIntersectionPoint, string pidLotPoint, bool sa
//TODO: test Facts existance
//add Facts
var intersectionId = FactManager.AddPointFact(intersectionPoint, this.LotModeLineHit.normal).URI;
var intersectionId = FactManager.AddPointFact(intersectionPoint, this.LotModeLineHit.normal).Id;
if(this.LotModeLineSelected is RayFact) //Add OnLineFact only on Ray not Line
FactManager.AddOnLineFact(intersectionId, this.LotModeLineSelected.URI, true);
FactManager.AddOnLineFact(intersectionId, this.LotModeLineSelected.Id, true);
CreateRayAndAngles(intersectionId, tempFact.URI, true);
CreateRayAndAngles(intersectionId, tempFact.Id, true);
this.ResetGadget();
}
......
......@@ -28,7 +28,7 @@ public override void OnHit(RaycastHit hit)
{
if (!this.isActiveAndEnabled) return;
var pid = FactManager.AddPointFact(hit).URI;
var pid = FactManager.AddPointFact(hit).Id;
if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Ray"))
{
......
......@@ -49,10 +49,10 @@ public override void OnHit(RaycastHit hit)
return;
//If first point was already selected AND second point != first point
if (this.TapeModeIsFirstPointSelected && this.TapeModeFirstPointSelected.URI != tempFact.URI)
if (this.TapeModeIsFirstPointSelected && this.TapeModeFirstPointSelected.Id != tempFact.Id)
{
//Create LineFact
FactManager.AddLineFact(this.TapeModeFirstPointSelected.URI, tempFact.URI);
FactManager.AddLineFact(this.TapeModeFirstPointSelected.Id, tempFact.Id);
this.ResetGadget();
}
......@@ -77,8 +77,8 @@ public override void OnHit(RaycastHit hit)
if (Physics.Raycast(hit.transform.gameObject.transform.position - Vector3.down * 2, Vector3.down, out downHit))
{
var idA = downHit.transform.gameObject.GetComponent<FactObject>().URI;
var idB = this.TapeModeFirstPointSelected.URI;
var idC = FactManager.AddPointFact(hit).URI;
var idB = this.TapeModeFirstPointSelected.Id;
var idC = FactManager.AddPointFact(hit).Id;
//Create LineFact
FactManager.AddAngleFact(idA, idB, idC, true);
......
......@@ -45,16 +45,16 @@ void Start()
}
public void AddFact(Fact fact) {
var fid = fact.URI;
var fid = fact.Id;
var obj = CreateDisplay(transform, fact);
obj.GetComponent<RectTransform>().localPosition = GetPosition(displayedFacts.Count);
displayedFacts.Add(fact.URI, obj);
displayedFacts.Add(fact.Id, obj);
}
public void RemoveFact(Fact fact)
{
GameObject.Destroy(displayedFacts[fact.URI]);
displayedFacts.Remove(fact.URI);
GameObject.Destroy(displayedFacts[fact.Id]);
displayedFacts.Remove(fact.Id);
UpdatePositions();
}
......@@ -66,7 +66,7 @@ public void UpdatePositions()
}
public void AnimateFact(Fact fact) {
var factIcon = displayedFacts[fact.URI];
var factIcon = displayedFacts[fact.Id];
factIcon.GetComponentInChildren<ImageHintAnimation>().AnimationTrigger();
}
......
......@@ -25,7 +25,7 @@ public void OnDrop(PointerEventData eventData)
current.transform.SetParent(gameObject.transform, false);
currentFact = eventData.pointerDrag.GetComponent<FactWrapper>().fact;
Debug.Log("recieved Fact: " + currentFact.URI);
Debug.Log("recieved Fact: " + currentFact.Id);
CommunicationEvents.NewAssignmentEvent.Invoke();
}
......
......@@ -145,7 +145,7 @@ private string prepareScrollAssignments()
if (tempFact != null)
{
listEntry.fact = new Scroll.UriReference(this.scroll.requiredFacts[i].@ref.uri);
listEntry.assignment = new JSONManager.OMS(tempFact.URI);
listEntry.assignment = new JSONManager.OMS(tempFact.Id);
assignmentList.Add(listEntry);
}
}
......@@ -218,7 +218,7 @@ public List<string> processRenderedScroll(Scroll rendered, List<string> hintUris
if (currentFact != null && currentFact.hasDependentFacts())
{
//Hint available for abstract-problem uri
hintUris.Add(currentFact.URI);
hintUris.Add(currentFact.Id);
LatestRenderedHints.Add(currentFact);
}
}
......@@ -244,10 +244,10 @@ public void animateHint(GameObject scrollParameter, string scrollParameterUri) {
fact.Representation.GetComponentInChildren<MeshRendererHintAnimation>().AnimationTrigger();
}
}
else if (LatestRenderedHints.Exists(x => x.URI.Equals(scrollParameterUri)))
else if (LatestRenderedHints.Exists(x => x.Id.Equals(scrollParameterUri)))
{
fact = LatestRenderedHints.Find(x => x.URI.Equals(scrollParameterUri));
var factId = fact.URI;
fact = LatestRenderedHints.Find(x => x.Id.Equals(scrollParameterUri));
var factId = fact.Id;
//If there is an equal existing fact -> Animate that fact AND ScrollParameter
if (LevelFacts.ContainsKey(factId))
......
......@@ -23,14 +23,14 @@ void Start()
SolutionManager.Add(buttom, out _);
SolutionManager.Add(top, out _, true);
LineFact target = new LineFact(buttom.URI, top.URI, SolutionManager);
LineFact target = new LineFact(buttom.Id, top.Id, SolutionManager);
Solution.Add(SolutionManager[SolutionManager.Add(target, out _, true)]);
}
public static bool gameSolved()
{
solved =
LevelFacts.DynamiclySolved(Solution, out _, out List<Fact> hits, new LineFactHightDirectionComparer());
LevelFacts.DynamiclySolved(Solution, out _, out List<Fact> hits, FactComparer: new LineFactHightDirectionComparer());
if (solved)
foreach (var hit in hits)
......
......@@ -6,7 +6,6 @@ public class Restart : MonoBehaviour
public void LevelReset()
{
CommunicationEvents.LevelReset.Invoke(); // currently unused
Level.solved = false; // needed since static
// delete Facts at Server
CommunicationEvents.LevelFacts.hardreset(false);
......
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