From 7c9ddfa7c8467d99dcaa8b96bd82c892f3ccce1f Mon Sep 17 00:00:00 2001
From: PaulWalcher <EthicalMonk@proton.me>
Date: Fri, 8 Mar 2024 12:02:41 +0100
Subject: [PATCH] fact documentation

---
 DOC/create_fact.md  | 57 +++++++++++++++++++++++++++++++++++++++++++++
 DOC/create_fact.txt | 56 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 113 insertions(+)
 create mode 100644 DOC/create_fact.md

diff --git a/DOC/create_fact.md b/DOC/create_fact.md
new file mode 100644
index 0000000..80fb3cd
--- /dev/null
+++ b/DOC/create_fact.md
@@ -0,0 +1,57 @@
+
+# <u><b>Create Fact</b></u>
+
+### <u>Dependency: MMT-Fact already implemented</u>
+
+1. In Assets\InteractionEngine\FactHandling\Facts create your own fact
+
+    <u>Your fact should include</u>:
+
+    (<i>use the already existing Facts as examples</i>)
+    <br>
+
+    1. 	A constructor that calls base(). Constructor can have SomDoc, which is the MMT URI as OMS.
+
+    2. 	define: A method parseFact(List<Fact>, MMTFact fact). 
+            MMTFact is the fact you received from the server.
+            Then, in this method, you will try to add your fact to the ParsingDictionary in Assets\InteractionEngine\FactHandling\Facts,
+            then add it to the first argument (the list).
+
+    3.	define: public override bool HasDependentFact => [true/false]	
+
+    4.	define: GetDeendentFactIds(), which gives back a string array of the dependent Ids of your facts.
+
+    5.	define: GetHashCode()
+
+    6. 	define: EquivalentWrapped(YOUR_FACTCLASS, YOUR_FACTCLASS), which is a Method that
+            returns true if the two facts are (approximately) equal
+
+    7.	define: _ReInitializeMe(Dictionary<string, string> old_to_new), that gets called when the Fact
+            gets reinstantiated
+
+    8.	define: MakeMMTDecalaration(), which gives back a new MMTFact.
+    
+    9.	define: Defines(), which gives back a SOMDoc(MMTObject) of your class
+<br>
+2. Add the MMT-fact you Implemented into Assets\Scripts\MMTServer\CommunicationProtocol\MMTConstants.cs
+<br>
+3. Then, in Assets\Scripts\InteractionEngine\FactHandling\Facts\Fact.cs
+<br>
+    1. add an entry into ParsingDictionary.parseFactDictionary with your MMTConstant as key and the parseFact Method of the Fact class you implemented.
+    2. Then add a line to the lines that look like [JsonSubtypes,.KnownSubType(typeof(YOUR_FACTCLASS), nameof(YOUR_FACTCLASS))]
+<br>
+4. In Assets\Scripts\InteractionEngine\FactHandling\FactSpawner.cs
+<br>
+    1. Add a variable of type GameObject for your fact.
+    2. Create a spawn method for your fact.
+    3. In SpawnFactRepresentation add your Fact to the switch-case statement
+<br>
+5. In the Unity Editor in Assets\Ressources\Prefabs\Facts create the prefab for your Fact. 
+<br>
+6. Connect your Prefab to the FactSpawner class
+<br>
+    1. Open Assets\Scenes\Worlds\RiverWorld. 
+    2. In the Unity Project Tab goto folder Assets\Scripts\InteractionEngine\FactHandling
+    3. Rightclick FactSpawner.cs and select "Find References In Scene".
+    4. In Hirarchy select WorldCursor and add your Fact Prefab into the Inspector.
+    5. Alternative to 6.2 & 6.3: in hirarchy search: "ref:Assets/Scripts/InteractionEngine/FactHandling/FactSpawner.cs"
\ No newline at end of file
diff --git a/DOC/create_fact.txt b/DOC/create_fact.txt
index 7fb1a92..5f07483 100644
--- a/DOC/create_fact.txt
+++ b/DOC/create_fact.txt
@@ -11,3 +11,59 @@ Fact.cs: Caches all facts
 see  TestFact as an example
 parseFact interprets new MMT fact.
 
+--------------------------------------
+
+In Assets\InteractionEngine\FactHandling\Facts create your own fact
+
+First, add your scroll you Implemented into Assets\Scripts\MMTServer\CommunicationProtocal\MMTConstants.cs
+Follow the definitions of previous srolls/functions.
+
+Then, in Assets\InteractionEngine\FactHandling\Facts.ParsingDictionary.Dictionary add an entry with your
+MMTConstant as key and the parseFact Method of the Fact class you're going to implement.
+
+Then in Assets\InteractionEngine\FactHandling\Facts.ParsingDictionary add a line to the lines
+that look like [JsonSubtypes,.KnownSubType(typeof(YOUR_FACTCLASS), nameof(YOUR_FACTCLASS))]
+
+Your fact should include:
+
+1.) 	A constructor that calls base(). Constructor can have SomDoc, which is the MMT URI as OMS.
+
+2.) 	define: A method parseFact(List<Fact>, MMTFact fact). 
+		Then, in this method, you will try to add your fact to the ParsingDictionary in Assets\InteractionEngine\FactHandling\Facts,
+		then add it to the first argument (the list).
+
+3.)	define: public override bool HasDependentFact => [true/false]	
+
+4.)	define: GetDeendentFactIds(), which gives back a string array of the dependent Ids of your facts.
+
+5.)	define: GetHashCode()
+
+6.) 	define: EquivalentWrapped(YOUR_FACTCLASS, YOUR_FACTCLASS), which is a Method that
+		returns true if the two facts are (approximately) equal
+
+7.)	define: _ReInitializeMe(Dictionary<string, string> old_to_new), that gets called when the Fact
+		gets reinstantiated
+
+8.)	define: MakeMMTDecalaration(), which gives back a new MMTFact
+
+9.)	define: Defines(), which gives back a SOMDoc(MMTObject) of your class
+
+
+
+
+----------------------------------------------------------
+
+1.) In Assets\InteractionEngine\FactHandling\Facts create your own fact. ()
+
+	
+2.) 
+
+
+
+
+
+
+
+
+
+
-- 
GitLab