Skip to content
Snippets Groups Projects
create_fact.md 2.47 KiB
Newer Older
  • Learn to ignore specific revisions
  • Paul-Walcher's avatar
    Paul-Walcher committed
    
    # <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.
    
    
    Paul-Walcher's avatar
    Paul-Walcher committed
        2. 	define: A method parseFact(List<Fact> ret, MMTFact fact). 
                convert MMTFact fact to Unity Fact and add it to the List<Fact> ret
    
                hint: use FactRecorder.AllFacts[<uri>] to get the Unity Fact belonging to the <uri>
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    
        3.	define: public override bool HasDependentFact => [true/false]	
    
    
    Paul-Walcher's avatar
    Paul-Walcher committed
        4.	define: GetDeendentFactIds(), which gives back a string array of the dependent URIs of your facts.
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    
        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
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    2. Add the MMT-fact you Implemented into Assets\Scripts\MMTServer\CommunicationProtocol\MMTConstants.cs
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    3. Then, in Assets\Scripts\InteractionEngine\FactHandling\Facts\Fact.cs
    
    Paul-Walcher's avatar
    Paul-Walcher committed
        
    
    Paul-Walcher's avatar
    Paul-Walcher committed
        1. add an entry into ParsingDictionary.parseFactDictionary with your MMTConstant as key and the parseFact Method of the Fact class you implemented.
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    
        2. Then add a line to the lines that look like 
        [JsonSubtypes,.KnownSubType(typeof(YOUR_FACTCLASS), nameof(YOUR_FACTCLASS))]
    
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    4. In Assets\Scripts\InteractionEngine\FactHandling\FactSpawner.cs
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    
    
    Paul-Walcher's avatar
    Paul-Walcher committed
        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
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    5. In the Unity Editor in Assets\Ressources\Prefabs\Facts create the prefab for your Fact. 
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    6. Connect your Prefab to the FactSpawner class
    
    Paul-Walcher's avatar
    Paul-Walcher committed
    
    
    Paul-Walcher's avatar
    Paul-Walcher committed
        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"