diff --git a/Assets/Scripts/GameObjectExtensions.cs b/Assets/Scripts/GameObjectExtensions.cs index 89c88fe135b5f542225cdf4feb63d8e82b9be238..1a482a803b2f235e61a50d58d52cdccdc77472a6 100644 --- a/Assets/Scripts/GameObjectExtensions.cs +++ b/Assets/Scripts/GameObjectExtensions.cs @@ -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); diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactComparer.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactComparer.cs index 8a72b9c4fb2d23994431cf1bc8a351582a826b7d..d04cef01541ccf200aa7bc5c52e6bb7ac682e45c 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactComparer.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactComparer.cs @@ -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); } } diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs index 713dc46e3757736215387a9779af63fc03de3ea0..e1068f5512a989f33c5e7fd3dff1e3aceb427ef3 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs @@ -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)) { diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactSpawner.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactSpawner.cs index 1a2ca18736f6a0e95e0ab0302c937a8f48660151..71d9586da22189ff475df187ff2e5aa5e51e8693 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactSpawner.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactSpawner.cs @@ -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>(); diff --git a/Assets/Scripts/InteractionEngine/Gadgets/AngleTool.cs b/Assets/Scripts/InteractionEngine/Gadgets/AngleTool.cs index dceaf8136ba9341b65aa7b7a50d5fd5ebd920349..f142b6d38d3b283ad44b8e175a4299c272eeda36 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/AngleTool.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/AngleTool.cs @@ -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>(); - //Start: AngleMiddlePoint -> FirstPoint of Curve - linePositions.Add(angleModeSecondPointSelected.Point); + linePositions = new List<Vector3> + { + //Start: AngleMiddlePoint -> FirstPoint of Curve + angleModeSecondPointSelected.Point + }; for (float ratio = 0; ratio <= 1; ratio += 1.0f / this.curveDrawingVertexCount) { diff --git a/Assets/Scripts/InteractionEngine/Gadgets/LineTool.cs b/Assets/Scripts/InteractionEngine/Gadgets/LineTool.cs index 3143cf3480684295147921e1df0ae142a78dbfcb..213f5e00e309747539c0247cfcebfb0993d05322 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/LineTool.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/LineTool.cs @@ -63,20 +63,15 @@ public override void OnHit(RaycastHit hit) //TODO: check behaviour else if (hit.transform.gameObject.CompareTag("SnapZone")) { - if (this.LineModeIsFirstPointSelected) + 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; + var idB = this.LineModeFirstPointSelected.Id; + FactManager.AddAngleFact(idA, idB, FactManager.AddPointFact(hit).Id); - RaycastHit downHit; - - if (Physics.Raycast(hit.transform.gameObject.transform.position - Vector3.down * 2, Vector3.down, out downHit)) - { - //Create LineFact - var idA = downHit.transform.gameObject.GetComponent<FactObject>().URI; - var idB = this.LineModeFirstPointSelected.Id; - FactManager.AddAngleFact(idA, idB, FactManager.AddPointFact(hit).Id); - - this.ResetGadget(); - } + this.ResetGadget(); } } diff --git a/Assets/Scripts/InteractionEngine/Gadgets/Tape.cs b/Assets/Scripts/InteractionEngine/Gadgets/Tape.cs index feca718135373b154e89e0ba52ed24f546d20f78..9c6f4b62450f6a0e740c81f68c5876c44e06571e 100644 --- a/Assets/Scripts/InteractionEngine/Gadgets/Tape.cs +++ b/Assets/Scripts/InteractionEngine/Gadgets/Tape.cs @@ -68,19 +68,16 @@ public override void OnHit(RaycastHit hit) //TODO: check behaviour else if (hit.transform.gameObject.CompareTag("SnapZone")) { - if (this.TapeModeIsFirstPointSelected) + if (this.TapeModeIsFirstPointSelected + && Physics.Raycast(hit.transform.gameObject.transform.position - Vector3.down * 2, Vector3.down, out RaycastHit downHit)) { - RaycastHit downHit; - 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.Id; - var idC = FactManager.AddPointFact(hit).Id; - //Create LineFact - FactManager.AddAngleFact(idA, idB, idC, true); - - this.ResetGadget(); - } + var idA = downHit.transform.gameObject.GetComponent<FactObject>().URI; + var idB = this.TapeModeFirstPointSelected.Id; + var idC = FactManager.AddPointFact(hit).Id; + //Create LineFact + FactManager.AddAngleFact(idA, idB, idC, true); + + this.ResetGadget(); } } //If no Point was hit diff --git a/Assets/Scripts/InteractionEngine/WorldCursor.cs b/Assets/Scripts/InteractionEngine/WorldCursor.cs index b1edd22267700b4f1059e8e5ae31b6db6cad8960..fa6871fecdb2a1a2d9490cf7d17d4f9437e5ec0c 100644 --- a/Assets/Scripts/InteractionEngine/WorldCursor.cs +++ b/Assets/Scripts/InteractionEngine/WorldCursor.cs @@ -102,10 +102,4 @@ void CheckMouseButtons() } } - - - - - - } diff --git a/Assets/Scripts/JSONManager.cs b/Assets/Scripts/JSONManager.cs index 3a128fa77388610b12b379f73523b5ad7025c4b4..10818cca52d29db2df95f3e4393009ae61e3e8a8 100644 --- a/Assets/Scripts/JSONManager.cs +++ b/Assets/Scripts/JSONManager.cs @@ -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 | diff --git a/Assets/Scripts/Loading/Loader.cs b/Assets/Scripts/Loading/Loader.cs index 1704ccc0262d07a985477a594f5b655ad3927539..6ebc2bc5483ff6e4529d4dbb39c58aec787de8ac 100644 --- a/Assets/Scripts/Loading/Loader.cs +++ b/Assets/Scripts/Loading/Loader.cs @@ -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); diff --git a/Assets/Scripts/Loading/LoadingScreenPercentage.cs b/Assets/Scripts/Loading/LoadingScreenPercentage.cs index 2e2628a24e9e154189f7a46fcef6f861a19fc93a..7ddd52821ea6d63ce7d49b28e19d0fa3fc333cb6 100644 --- a/Assets/Scripts/Loading/LoadingScreenPercentage.cs +++ b/Assets/Scripts/Loading/LoadingScreenPercentage.cs @@ -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; diff --git a/Assets/Scripts/Loading/Stage.cs b/Assets/Scripts/Loading/Stage.cs index 84cb169ba3a0d3e3bbb8e6720511a8766f10d4ce..6e9f61cc90b37188121ce21803501f97a9068d1a 100644 --- a/Assets/Scripts/Loading/Stage.cs +++ b/Assets/Scripts/Loading/Stage.cs @@ -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); diff --git a/Assets/Scripts/Math3d.cs b/Assets/Scripts/Math3d.cs index 69d83484d2078f0b255412549523e0ec23757ec1..4c3ede917e5b2b67e9b3a02d4e88af8f6b0455c4 100644 --- a/Assets/Scripts/Math3d.cs +++ b/Assets/Scripts/Math3d.cs @@ -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. diff --git a/Assets/Scripts/Restart.cs b/Assets/Scripts/Restart.cs index 686d4198a2423bc7f429a678767d24b8e18502da..3fc2f536746b5fe84ed232748a23d3798df14e01 100644 --- a/Assets/Scripts/Restart.cs +++ b/Assets/Scripts/Restart.cs @@ -11,17 +11,18 @@ 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"); } public void LoadStartScreen() { - StartServer.process.Kill(); // null reference exception if Server started manually + StartServer.process.Kill(); // null reference exception if Server started manually SceneManager.LoadScene(0); } public void OnApplicationQuit() { - StartServer.process.Kill(); + StartServer.process.Kill(); // null reference exception if Server started manually } } diff --git a/Assets/Scripts/StageBehaviour.cs b/Assets/Scripts/StageBehaviour.cs index 0689d4c023133bff25bb0baf43f8a292bda24b97..a508070d7aea727ab411f655155cbf4cea0e74aa 100644 --- a/Assets/Scripts/StageBehaviour.cs +++ b/Assets/Scripts/StageBehaviour.cs @@ -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; diff --git a/Assets/Scripts/StageStatic.cs b/Assets/Scripts/StageStatic.cs index 39bbbc3069e9fefe88711f7a3ac66f3758e3003f..49c0d653d0149c778bd088ea1bfb11830c4f09d0 100644 --- a/Assets/Scripts/StageStatic.cs +++ b/Assets/Scripts/StageStatic.cs @@ -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; } - gameObject.UpdateTagActive("DevelopingMode", mode == Mode.Create); + 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); diff --git a/Assets/Scripts/UI/HideUI.cs b/Assets/Scripts/UI/HideUI.cs index ad66ba063e123759f8ee370564c34ac6ae24908a..4c2876472b45a5be02a6f0e441c3bfbf89e6f8c5 100644 --- a/Assets/Scripts/UI/HideUI.cs +++ b/Assets/Scripts/UI/HideUI.cs @@ -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, diff --git a/Assets/Scripts/UI/InputFieldPanel.cs b/Assets/Scripts/UI/InputFieldPanel.cs index ebdf681269029d3344be72632a22722d40bef444..c7fa70728e81892be21c49509307984a655896d7 100644 --- a/Assets/Scripts/UI/InputFieldPanel.cs +++ b/Assets/Scripts/UI/InputFieldPanel.cs @@ -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() { diff --git a/Assets/Scripts/UI/MainMenue/ListLoader.cs b/Assets/Scripts/UI/MainMenue/ListLoader.cs index c06c99bb5162a036f6bb62959479b1bf736198c6..1a0424074b9a0ee3204e70f9e5824db6a25f9ec0 100644 --- a/Assets/Scripts/UI/MainMenue/ListLoader.cs +++ b/Assets/Scripts/UI/MainMenue/ListLoader.cs @@ -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) diff --git a/Assets/Scripts/UI/MainMenue/MenueLoader.cs b/Assets/Scripts/UI/MainMenue/MenueLoader.cs index 6352d1e573cdb9a3bdbf9b9ddeb329774178bf85..2d3e1f6a184b5535f8e15e4ba8a32c208c03f9d7 100644 --- a/Assets/Scripts/UI/MainMenue/MenueLoader.cs +++ b/Assets/Scripts/UI/MainMenue/MenueLoader.cs @@ -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++) diff --git a/Assets/Scripts/UI/MainMenue/PageLoader/LocalLoader.cs b/Assets/Scripts/UI/MainMenue/PageLoader/LocalLoader.cs index bf7f6d47d5c2a790ee9c63c43c62d2cacbee2ea3..0c5619d7d0aae1b364f2beaa40ceff5802dab2ff 100644 --- a/Assets/Scripts/UI/MainMenue/PageLoader/LocalLoader.cs +++ b/Assets/Scripts/UI/MainMenue/PageLoader/LocalLoader.cs @@ -3,7 +3,9 @@ using System.Linq; using UnityEngine; - +/// <summary> +/// Dummy class; "needed" +/// </summary> public class LocalLoader : StageLoader { diff --git a/Assets/Scripts/UI/MainMenue/PageLoader/StageLoader.cs b/Assets/Scripts/UI/MainMenue/PageLoader/StageLoader.cs index 666a767909bafc9e71594e03ba3e96248a9f57c4..1fa1274734075d01676383ac3b20835a5d64cbf6 100644 --- a/Assets/Scripts/UI/MainMenue/PageLoader/StageLoader.cs +++ b/Assets/Scripts/UI/MainMenue/PageLoader/StageLoader.cs @@ -17,7 +17,7 @@ protected string NoId = "", NoStage = "-----", NoDescr = "No Entry found, please check directory!", - NoLocal = "No local Stage\nClick [+]"; + NoLocal = "No local Stage\nClick [+] button above"; public override void Init() { diff --git a/GlobalSuppressions.cs b/GlobalSuppressions.cs new file mode 100644 index 0000000000000000000000000000000000000000..3ab61ce724a9b41da661dd48507cc78bdc314a2d --- /dev/null +++ b/GlobalSuppressions.cs @@ -0,0 +1,14 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +//Global +[assembly: SuppressMessage("Style", "IDE1006:Benennungsstile", Justification = "<Ausstehend>")] + +//Local +[assembly: SuppressMessage("Style", "IDE0018:Inlinevariablendeklaration", Justification = "Readability", Scope = "member", Target = "~M:Math3d.GetLineSplineIntersections(UnityEngine.Vector2[],UnityEngine.Vector2[])")] +[assembly: SuppressMessage("Style", "IDE0018:Inlinevariablendeklaration", Justification = "Readability", Scope = "member", Target = "~M:Math3d.AreLineSegmentsCrossing(UnityEngine.Vector3,UnityEngine.Vector3,UnityEngine.Vector3,UnityEngine.Vector3)~System.Boolean")] +[assembly: SuppressMessage("Style", "IDE0075:Bedingten Ausdruck vereinfachen", Justification = "Readability", Scope = "member", Target = "~P:Loader.isDone")]