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

+Doxygen +misc

parent 952d6fa2
No related branches found
No related tags found
No related merge requests found
Showing
with 183 additions and 93 deletions
......@@ -9,7 +9,7 @@ public static void UpdateTagActive(this GameObject root, string tag, bool enable
for (int i = 0; i < root.transform.childCount; i++)
{
GameObject child = root.transform.GetChild(i).gameObject;
if (child.tag == tag)
if (child.CompareTag(tag))
child.SetActive(enable);
else
UpdateTagActive(child, tag, enable);
......
......@@ -93,9 +93,9 @@ class LineFactHightDirectionComparer : FactComparer
/// \copydoc FactComparer.Compare
protected override bool Compare (Fact solution, Fact fact)
{
return fact is LineFact && solution is LineFact
&& Math3d.IsApproximatelyParallel(((LineFact) fact).Dir, ((LineFact) solution).Dir)
&& ((LineFact) fact).Distance + Math3d.vectorPrecission >= ((LineFact) solution).Distance;
return fact is LineFact factLine && solution is LineFact solutionLine
&& Math3d.IsApproximatelyParallel(factLine.Dir, solutionLine.Dir)
&& factLine.Distance + Math3d.vectorPrecission >= solutionLine.Distance;
// && Mathf.Approximately(((LineFact) x).Distance, ((LineFact) y).Distance);
}
}
......@@ -406,7 +406,9 @@ private void PruneWorkflow()
public string Add(Fact value, out bool exists, bool samestep = false)
{
soft_resetted = false;
#pragma warning disable IDE0018 // Inlinevariablendeklaration
string key;
#pragma warning restore IDE0018 // Inlinevariablendeklaration
if (exists = FindEquivalent(value, out key, out bool exact))
{
......
......@@ -158,7 +158,7 @@ public Fact SpawnAngle(Fact fact)
//Length of the Angle relative to the Length of the shortest of the two lines (point2->point1) and (point2->point3)
float lengthFactor = 0.3f;
float length = 0;
float length;
if ((point1 - point2).magnitude >= (point3 - point2).magnitude)
length = lengthFactor * (point3 - point2).magnitude;
else
......@@ -178,10 +178,8 @@ public Fact SpawnAngle(Fact fact)
v3T = new Vector3(length, v3T.y, length);
Vector3 up = Vector3.Cross(to, from);
angle.transform.rotation = Quaternion.LookRotation(Vector3.Cross((from+to).normalized,up), up);
//Place the Angle at position of point2
angle.transform.position = point2;
angle.transform.SetPositionAndRotation(point2, Quaternion.LookRotation(Vector3.Cross((from+to).normalized,up), up));
//Set text of angle
TextMeshPro[] texts = angle.GetComponentsInChildren<TextMeshPro>();
......
......@@ -143,9 +143,11 @@ public void UpdateCurveDrawing(Vector3 currentPosition)
Vector3 tempCenterPoint = Vector3.Lerp(startPoint, curveEndPoint, 0.5f);
Vector3 curveMiddlePoint = angleMiddlePoint + curveRadius * (tempCenterPoint - angleMiddlePoint).normalized;
linePositions = new List<Vector3>();
linePositions = new List<Vector3>
{
//Start: AngleMiddlePoint -> FirstPoint of Curve
linePositions.Add(angleModeSecondPointSelected.Point);
angleModeSecondPointSelected.Point
};
for (float ratio = 0; ratio <= 1; ratio += 1.0f / this.curveDrawingVertexCount)
{
......
......@@ -63,12 +63,8 @@ public override void OnHit(RaycastHit hit)
//TODO: check behaviour
else if (hit.transform.gameObject.CompareTag("SnapZone"))
{
if (this.LineModeIsFirstPointSelected)
{
RaycastHit downHit;
if (Physics.Raycast(hit.transform.gameObject.transform.position - Vector3.down * 2, Vector3.down, out downHit))
if (this.LineModeIsFirstPointSelected
&& Physics.Raycast(hit.transform.gameObject.transform.position - Vector3.down * 2, Vector3.down, out RaycastHit downHit))
{
//Create LineFact
var idA = downHit.transform.gameObject.GetComponent<FactObject>().URI;
......@@ -78,7 +74,6 @@ public override void OnHit(RaycastHit hit)
this.ResetGadget();
}
}
}
//If no Point was hit
else
......
......@@ -68,10 +68,8 @@ public override void OnHit(RaycastHit hit)
//TODO: check behaviour
else if (hit.transform.gameObject.CompareTag("SnapZone"))
{
if (this.TapeModeIsFirstPointSelected)
{
RaycastHit downHit;
if (Physics.Raycast(hit.transform.gameObject.transform.position - Vector3.down * 2, Vector3.down, out downHit))
if (this.TapeModeIsFirstPointSelected
&& Physics.Raycast(hit.transform.gameObject.transform.position - Vector3.down * 2, Vector3.down, out RaycastHit downHit))
{
var idA = downHit.transform.gameObject.GetComponent<FactObject>().URI;
var idB = this.TapeModeFirstPointSelected.Id;
......@@ -82,7 +80,6 @@ public override void OnHit(RaycastHit hit)
this.ResetGadget();
}
}
}
//If no Point was hit
else
{
......
......@@ -102,10 +102,4 @@ void CheckMouseButtons()
}
}
}
......@@ -171,8 +171,10 @@ public static void WriteToJsonFile(string filePath, object objectToWrite, int ma
int current_depth = 0;
// This tells your serializer that multiple references are okay.
var settings = new JsonSerializerSettings();
settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
var settings = new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
};
BindingFlags bindFlags =
BindingFlags.Instance |
......
......@@ -7,23 +7,38 @@
public static class Loader
{
/// <summary> <see langword="null"/> or current <see cref="AsyncOperation"/> loading a <see cref="Scene"/>.</summary>
private static AsyncOperation loadingscene;
/// <summary> Defines last <see cref="Scene"/> loaded by this and/ or to be loaded when calling <see cref="LoaderCallback"/>.</summary>
private static string nextscene;
private class MonoDummy : MonoBehaviour { };
/// <summary>
/// <c>return <see cref="loadingscene"/> == <see langword="null"/> ? 1f : <see cref="loadingscene"/>.progress;</c>
/// </summary>
public static float progress {
get {
return loadingscene == null ? 1f : loadingscene.progress;
}
}
/// <summary>
/// <c>return <see cref="loadingscene"/> == null ? <see langword="true"/> : <see cref="loadingscene"/>.isDone;</c>
/// </summary>
public static bool isDone {
get {
return loadingscene == null ? true : loadingscene.isDone;
}
}
/// <summary>
/// Tries to init (via <see cref="StageStatic.LoadInitStage(string, bool, bool, GameObject)"/>) defined <see cref="Stage"/> and load it (via <see cref="LoadScene(string)"/>).
/// </summary>
/// <param name="name">defines <see cref="Stage.name"/></param>
/// <param name="local">defines !<see cref="Stage.use_install_folder"/></param>
/// <param name="restore_session">see <see cref="StageStatic.LoadInitStage(string, bool, bool, GameObject)"/></param>
/// <returns>see <see cref="StageStatic.LoadInitStage(string, bool, bool, GameObject)"/></returns>
public static bool LoadStage(string name, bool local, bool restore_session)
{
if (!StageStatic.LoadInitStage(name, local, restore_session))
......@@ -33,6 +48,10 @@ public static bool LoadStage(string name, bool local, bool restore_session)
return true;
}
/// <summary>
/// Sets <see cref="nextscene"/> and synchronously loads "LoadingScene", which in turn will asynchronously load <paramref name="scene"/>.
/// </summary>
/// <param name="scene">sets <see cref="nextscene"/></param>
public static void LoadScene(string scene)
{
nextscene = scene;
......@@ -40,18 +59,27 @@ public static void LoadScene(string scene)
// loads LoadingScreen, which will call LoaderCallback() in LoadingScreenPercentage
}
/// <summary>
/// Wrapps <see cref="LoadScene(string)"/>
/// <br/> // TODO: needed? used in Inspector?
/// </summary>
/// \copybrief LoadScene(string)
public static void LoadScene(Scene scene)
{
nextscene = scene.name;
SceneManager.LoadScene("LoadingScene");
// loads LoadingScreen, which will call LoaderCallback() in LoadingScreenPercentage
LoadScene(scene.name);
}
/// <summary> Called when <see cref="LoadingScreenPercentage"/> is destroyed. </summary>
/// <remarks> Does currently nothing. </remarks>
public static void PostLoad()
{
;
}
/// <summary>
/// Called when <see cref="LoadingScreenPercentage"/> starts and loads asynchronously <see cref="nextscene"/>. <br/>
/// sets <see cref="loadingscene"/>
/// </summary>
public static void LoaderCallback()
{
loadingscene = SceneManager.LoadSceneAsync(nextscene);
......
......@@ -2,6 +2,10 @@
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Attached in the Loading-Screen to <see cref="TMPro"/> object for progress display.
/// Loads set <see cref="Loader.nextscene"/> and updates progress in <see cref="TMPro.TextMeshProUGUI"/>.
/// </summary>
public class LoadingScreenPercentage : MonoBehaviour
{
public float maxFrameIncrease = 100f / 100;
......
......@@ -432,11 +432,7 @@ public void store(bool reset_player = false)
/// - <see cref="ShallowLoad(ref Stage, string, List<Directories>, bool)"/>
/// - <see cref="DeepLoad"/>
/// </summary>
/// <param name="set">see <see cref="ShallowLoad(ref Stage, string, List<Directories>, bool)"/></param>
/// <param name="name">see <see cref="ShallowLoad(ref Stage, string, List<Directories>, bool)"/></param>
/// <param name="hierarchie">see <see cref="ShallowLoad(ref Stage, string, List<Directories>, bool)"/></param>
/// <param name="use_install_folder">see <see cref="ShallowLoad(ref Stage, string, List<Directories>, bool)"/></param>
/// <returns><see langword="true"/> iff succeeded</returns>
/// \copydetails ShallowLoad(ref Stage, string, List<Directories>, bool)
public static bool load(ref Stage set, string name, List<Directories> hierarchie = null, bool use_install_folder = false)
{
Stage ret = new Stage();
......@@ -523,7 +519,7 @@ public bool DeepLoad()
}
/// <summary>
/// Looks for saved <see cref="Stage">Stages</see> in parametised directories.
/// Looks for saved <see cref="Stage">Stages</see> in parametised directories and calls on them <see cref="ShallowLoad(ref Stage, string)"/>.
/// </summary>
/// <param name="hierarchie">see <see cref="hierarchie"/> //TODO? Interface</param>
/// <param name="use_install_folder">see <see cref="use_install_folder"/></param>
......@@ -694,9 +690,11 @@ public PlayerRecord Clone(List<Directories> hierarchie)
hierarchie ??= new List<Directories>();
hierarchie.AddRange(hierStage.AsEnumerable());
var ret = new PlayerRecord(this.name);
ret.solved = this.solved;
ret.seconds = this.seconds;
var ret = new PlayerRecord(this.name)
{
solved = this.solved,
seconds = this.seconds
};
ret.load(hierarchie);
hierarchie.RemoveRange(hierarchie.Count - hierStage.Count, hierStage.Count);
......
......@@ -739,8 +739,7 @@ public static void PlaneFrom3Points(out Vector3 planeNormal, out Vector3 planePo
//of the triangle defined by the 3 points.
//We could use LineLineIntersection instead of ClosestPointsOnTwoLines but due to rounding errors
//this sometimes doesn't work.
Vector3 temp;
ClosestPointsOnTwoLines(out planePoint, out temp, middleAB, middleABtoC, middleAC, middleACtoB);
ClosestPointsOnTwoLines(out planePoint, out _, middleAB, middleABtoC, middleAC, middleACtoB);
}
//Returns the forward vector of a quaternion
......@@ -813,18 +812,15 @@ public static void TransformWithParent(out Quaternion childRotation, out Vector3
childPosition = Vector3.zero;
//set the parent start transform
tempParent.rotation = startParentRotation;
tempParent.position = startParentPosition;
tempParent.SetPositionAndRotation(startParentPosition, startParentRotation);
tempParent.localScale = Vector3.one; //to prevent scale wandering
//set the child start transform
tempChild.rotation = startChildRotation;
tempChild.position = startChildPosition;
tempChild.SetPositionAndRotation(startChildPosition, startChildRotation);
tempChild.localScale = Vector3.one; //to prevent scale wandering
//translate and rotate the child by moving the parent
tempParent.rotation = parentRotation;
tempParent.position = parentPosition;
tempParent.SetPositionAndRotation(parentPosition, parentRotation);
//get the child transform
childRotation = tempChild.rotation;
......@@ -859,9 +855,7 @@ public static void PreciseAlign(ref GameObject gameObjectInOut, Vector3 alignWit
//Convert a position, direction, and normal vector to a transform
public static void VectorsToTransform(ref GameObject gameObjectInOut, Vector3 positionVector, Vector3 directionVector, Vector3 normalVector)
{
gameObjectInOut.transform.position = positionVector;
gameObjectInOut.transform.rotation = Quaternion.LookRotation(directionVector, normalVector);
gameObjectInOut.transform.SetPositionAndRotation(positionVector, Quaternion.LookRotation(directionVector, normalVector));
}
//This function finds out on which side of a line segment the point is located.
......
......@@ -11,6 +11,7 @@ public void LevelReset()
public void LoadMainMenue()
{
//not over SceneManager.LoadScene as MainMenue is too light to need to load over a LoadingScreen
SceneManager.LoadScene("MainMenue");
}
......@@ -22,6 +23,6 @@ public void LoadStartScreen()
public void OnApplicationQuit()
{
StartServer.process.Kill();
StartServer.process.Kill(); // null reference exception if Server started manually
}
}
......@@ -3,13 +3,22 @@
using UnityEngine;
using static StageStatic;
/// <summary>
/// Attached to prefab Def_Stage
/// </summary>
public class StageBehaviour : MonoBehaviour
{
/// <summary>
/// Re-loads <see cref="StageStatic.stage"/> to display all <see cref="Fact">Facts</see>.
/// </summary>
void Start()
{
StageStatic.LoadInitStage(true /*StageStatic.stage.player_record.solved*/, gameObject);
}
/// <summary>
/// Resets changes made by <see cref="StageStatic.stage"/> and frees ressources.
/// </summary>
private void OnDestroy()
{
StageStatic.SetMode(Mode.Play); // no Mode.Create
......@@ -17,12 +26,19 @@ private void OnDestroy()
StageStatic.stage.factState.hardreset();
}
// needed as endpoint for unity buttons
/// <summary>
/// Wrapps <see cref="SetMode(Mode, GameObject)"/>. Needed as endpoint for unity buttons.
/// </summary>
/// <param name="create"><c>SetMode(create ? Mode.Create : Mode.Play);</c></param>
public void SetMode(bool create)
{
SetMode(create ? Mode.Create : Mode.Play);
}
/// <summary>
/// Wrapps <see cref="StageStatic.SetMode(Mode, GameObject)"/>. Defaulting <paramref name="obj"/> to <see cref="this.gameObject"/>.
/// </summary>
/// \copydetails StageStatic.SetMode(Mode, GameObject)
public void SetMode(Mode mode, GameObject obj = null)
{
obj ??= gameObject;
......
......@@ -234,8 +234,10 @@ public static StageErrorStruct LoadNewStage(string category, int id, string name
if (!ret.pass)
return ret;
stage = new Stage(category, id, name, description, scene, true);
stage.creatorMode = true;
stage = new Stage(category, id, name, description, scene, true)
{
creatorMode = true
};
stage.store();
LoadCreate();
......@@ -276,6 +278,13 @@ public static int NextNumber(bool local, string category)
return last + 1;
}
/// <summary>
/// Looks wether an <see cref="Stage.number"/> <paramref name="i"/> exists within a certain <see cref="Stage.category"/> <paramref name="category"/> in local saves (<paramref name="local"/> == <see langword="true"/>) or install path.
/// </summary>
/// <param name="category">to look in</param>
/// <param name="i">to look for</param>
/// <param name="local">where to look</param>
/// <returns></returns>
public static bool ContainsNumber(string category, int i, bool local)
{
return (local ? StageLocal : StageOfficial).Values
......@@ -284,34 +293,59 @@ public static bool ContainsNumber(string category, int i, bool local)
.Contains(i);
}
/// <summary>
/// Looks for and initial loads (see <see cref="Stage.ShallowLoad(ref Stage, string)"/>) <see cref="Stage">Stages</see> in <see cref="local_stage"/> and !<see cref="local_stage"/>.
/// </summary>
public static void ShallowLoadStages()
{
StageOfficial = Stage.Grup(null, true);
StageLocal = Stage.Grup(null, false);
}
/// <summary>
/// Sets parameters, defining what to load in <see cref="LoadInitStage(bool, GameObject)"/> and <see cref="LoadInitStage(string, bool, bool, GameObject)"/>.
/// </summary>
/// <param name="name">sets <see cref="current_name"/></param>
/// <param name="local">sets <see cref="local_stage"/></param>
public static void SetStage(string name, bool local)
{
local_stage = local;
current_name = name;
}
/// <summary>
/// Returns a <see cref="Stage"/> or throws <see cref="Exception"/> if not found.
/// </summary>
/// <param name="name"><see cref="Stage.name"/></param>
/// <param name="local">where to look</param>
/// <returns><c>(local ? StageLocal : StageOfficial)[name];</c></returns>
public static Stage GetStage(string name, bool local)
{
return (local ? StageLocal : StageOfficial)[name];
}
/// <summary>
/// Deletes a <see cref="Stage"/> and all its associated files (including save games).
/// <seealso cref="Stage.delete(bool)"/>
/// </summary>
/// <param name="stage">to be deleted</param>
public static void Delete(Stage stage)
{
GetStage(stage.name, !stage.use_install_folder).delete(true);
(!stage.use_install_folder ? StageLocal : StageOfficial).Remove(stage.name);
}
/// <summary>
/// Wrapps <see cref="LoadInitStage(bool, GameObject)"/> with extra parameters.
/// Loads and initiates <see cref="Stage"/> defined by <paramref name="name"/> and <paramref name="local"/>.
/// </summary>
/// <param name="name">sets <see cref="current_name"/> iff succeedes</param>
/// <param name="local">sets <see cref="current_name"/> iff succeedes</param>
/// <param name="restore_session">wether to restore last (loaded) player session (<see langword="true"/>) or start from scratch (<see langword="false"/>).</param>
/// <param name="gameObject">(e.g. UI/ Def_Stage) toggles recursively children with tag "DevelopingMode" to <see cref="mode"/> == <see cref="Mode.Create"/>.</param>
/// <returns><see langword="false"/> iff <see cref="Stage"/> defined by <paramref name="name"/> and <paramref name="local"/> could not be *found* or *loaded*.</returns>
public static bool LoadInitStage(string name, bool local = false, bool restore_session = true, GameObject gameObject = null)
{
if (!ContainsKey(name, local))
return false;
bool old_l = local_stage;
string old_n = current_name;
SetStage(name, local);
......@@ -326,13 +360,17 @@ public static bool LoadInitStage(string name, bool local = false, bool restore_s
return true;
}
/// <summary>
/// Loads and initiates <see cref="Stage"/> defined by <see cref="current_name"/> and <see cref="local_stage"/>.
/// </summary>
/// <param name="restore_session">wether to restore last (loaded) player session (<see langword="true"/>) or start from scratch (<see langword="false"/>).</param>
/// <param name="gameObject">(e.g. UI/ Def_Stage) toggles recursively children with tag "DevelopingMode" to <see cref="mode"/> == <see cref="Mode.Create"/>.</param>
/// <returns><see langword="false"/> iff <see cref="Stage"/> defined by <see cref="current_name"/> and <see cref="local_stage"/> could not be *found* or *loaded*.</returns>
public static bool LoadInitStage(bool restore_session, GameObject gameObject = null)
{
if (current_name == null || current_name.Length == 0 || !stage.DeepLoad())
if (!ContainsKey(current_name, local_stage) || !stage.DeepLoad())
return false;
gameObject ??= new GameObject();
if (restore_session)
{
stage.factState.invoke = true;
......@@ -345,15 +383,24 @@ public static bool LoadInitStage(bool restore_session, GameObject gameObject = n
stage.player_record.seconds = -1;
}
if(gameObject != null)
gameObject.UpdateTagActive("DevelopingMode", mode == Mode.Create);
SetMode(stage.creatorMode ? Mode.Create : Mode.Play);
return true;
}
/// <summary>
/// Wrapps <see cref="ContainsKey(string, bool)"/>; defaulting local to <see cref="local_stage"/>
/// </summary>
public static bool ContainsKey(string key)
{
return ContainsKey(key, local_stage);
}
/// <summary>
/// Looks for a <see cref="Stage"/> <paramref name="key"/> in <see cref="StageLocal"/> (<paramref name="local"/>==<see langword="true"/>) or <see cref="StageOfficial"/> (<paramref name="local"/>==<see langword="false"/>).
/// </summary>
/// <returns><c>(local ? StageLocal : StageOfficial).ContainsKey(key)</c></returns>
public static bool ContainsKey(string key, bool local)
{
return (local ? StageLocal : StageOfficial).ContainsKey(key);
......
......@@ -6,7 +6,7 @@ public class HideUI : MonoBehaviour
{
public KeyCode Key = KeyCode.F1;
//public KeyCode ScreenshotKey = KeyCode.F2;
//public KeyCode ScreenshotKey = KeyCode.F12;
public string
modifier,
......
......@@ -3,11 +3,14 @@
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// Just adds a " " to the end of <see cref="TMPro"/> input-field-text-box. <br/>
/// This fixes some graphical glitches, occuring when typing a [newline].
/// </summary>
public class InputFieldPanel : MonoBehaviour
{
private TMPro.TextMeshProUGUI output;
private TMPro.TMP_InputField input;
private string newline;
void Start()
{
......
......@@ -3,10 +3,15 @@
using System.Linq;
using UnityEngine;
//TODO: SE: Split for Stage/Local
/// <summary>
/// Allowes for Pages of <see cref="MenueLoader"/> to contain Lists.
/// </summary>
/// <typeparam name="T">Type to list</typeparam>
public abstract class ListLoader<T> : MenueLoader
{
/// <summary> <see cref="GameObject"/> to which new <see cref="EntryHeader"/> entries are being added. </summary>
public GameObject List;
/// <summary> Template for new entries to be added to <see cref="List"/> </summary>
public GameObject EntryHeader;
protected void OnEnable()
......@@ -20,13 +25,16 @@ protected void OnDisable()
Clear();
}
/// <summary> Creates listing </summary>
public abstract void Init();
/// <summary> Removes all list-entries</summary>
protected virtual void Clear()
{
List.DestroyAllChildren();
}
/// <summary> Creates a Default listing.</summary>
protected abstract void Default();
public virtual void ListButtons(List<T> list)
......
......@@ -3,6 +3,9 @@
using System.Linq;
using UnityEngine;
/// <summary>
/// Allows multiple Pages (direct children of this) to switch/ scroll through.
/// </summary>
public class MenueLoader : MonoBehaviour
{
public MenueLoader pageMenue;
......@@ -18,25 +21,20 @@ protected void Start()
scroll.verticalNormalizedPosition = 1f;
}
/// <summary>
/// Reverts to last opend Page.
/// </summary>
public void RevertMode()
{
SetMode(mode_last);
}
/// <summary>
/// Deactivates all Pages, then activates Page <paramref name="select"/>.
/// </summary>
/// <param name="select">Page to switch to</param>
public void SetMode(int select)
{
switch (select)
{
case 0:
case 1:
case 2:
break;
case 3:
//Pages.transform.GetChild(select).GetComponent<>
break;
}
Clear();
mode_last = mode;
......@@ -45,6 +43,9 @@ public void SetMode(int select)
Pages.transform.GetChild(select).gameObject.SetActive(true);
}
/// <summary>
/// Deactivates all Pages.
/// </summary>
private void Clear()
{
for (int i = 0; i < Pages.transform.childCount; i++)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment