using System.Collections.Generic; using System.Linq; using OmiLAXR.Composers; using OmiLAXR.Pipelines; using UnityEngine; using NotImplementedException = System.NotImplementedException; namespace OmiLAXR.xAPI.Composers.HigherComposers { public sealed class ExampleSemanticComposer : xApiSemanticComposer { public override Author GetAuthor() => new Author("Sergej Görzen", "goerzen@cs.rwth-aachen.de"); // Conditions that need to be met to trigger this composer protected override Dictionary> Conditions() => new Dictionary> { // actor clicked mouse { "clicked", new MatchCondition(1, stmt => stmt.MatchKeys("clicked", "mouse")) }, // actor moved mouse { "moved", new MatchCondition(10, stmt => stmt.MatchKeys("moved", "mouse")) } }; protected override void OnMatchAllConditions(Dictionary> matchingStatements) { // Get clicked statement var clickedStatement = matchingStatements["clicked"].First(); // Get first and last move statement var movedMatch = matchingStatements["moved"]; if (movedMatch == null) return; var firstMoveStatement = movedMatch.First(); var lastMoveStatement = movedMatch.Last(); var startPosition = firstMoveStatement.GetExtensionValue("mousePosition"); var endPosition = lastMoveStatement.GetExtensionValue("mousePosition"); // Compose new statement var stmt = actor.Does(xapi.generic.verbs.achieved) .Activity(xapi.generic.activities.goal) .WithResult(xapi.generic.extensions.result.startValue(startPosition).endValue(endPosition)) .WithExtension(xapi.generic.extensions.activity.name("dragged")); SendStatement(stmt); } } }