Host methods
Contens
General description
SymOntoClay is a game-AI engine which is abstracted from concrete host (a game engine, like Unity, with which SymOntoClay is connected). It means SymOntoClay can not interact directly with objects on a game scene.
But sometimes game logic requires interaction with objects on a game scene. For instance:
- Implementation of walking could require interaction with Unity NavMeshAgent and Animator.
- Implementation of shooting require interaction with Unity Light, ParticleSystem and AudioSource.
Host methods are defined on Unity MonoBehaviour level and are imported into a namespace of SymOntoClay DSL. It allows us to call the methods on SymOntoClay DSL level by system variable @@host and interact with objects on a game scene in the methods.
Host method declaration
Host method is usual C# method on Unity MonoBehaviour level.
Host method must be annotated by BipedEndpointAttribute. The first parameter of the atribute ("Go") is a name of the method in a namespace of SymOntoClay DSL. The name can be different from C#-name of the method. The next parameters are Devices (like right of left leg or hand) which required for exeqution of the method.
Host method must return only void.
The first parameter of the method must be CancellationToken. Periodically you should check IsCancellationRequested or call ThrowIfCancellationRequested() of the CancellationToken to correctly cancel the method.
Next parameters are passed from SymOntoClay DSL using Type сonversion. Attribute EndpointParamAttribute allows to set different name of the parameter ("To") and advice for Type сonversion.
Generalized host method declaration
Sometimes host method can be unimplemented but call of the method should be logged instead of error of call undefined method. For instance, in CLI host methods (like "Go" or "Take") are not implemented but can be called.
Generalized host method allows calling undefined host methods.
Generalized host method is usual C# method on Unity MonoBehaviour level.
Generalized host method must be annotated by BipedEndpointAttribute. The annotation should have just one parameter "*".
Generalized host method must return only void.
Generalized host method must have parameters:
- CancellationToken cancellationToken
- Periodically you should check IsCancellationRequested or call ThrowIfCancellationRequested() of the CancellationToken to correctly cancel the method.
- string methodName
- Contains name of called method.
- bool isNamedParameters
- Contains true if method is called by named parameters, otherwise contains false.
- Dictionary<string, object> namedParameters
- Contais Dictionary with named parameters if method is called by named parameters, otherwise contains null.
- List<object> positionedParameters
- Contains List with parameters if method is called by positioneds parameters, otherwise contains null.
Devices
Devices represent parts of character's body which can be used in character's actions. For instance, head, right hand, left hand, right leg, left leg. Available devices are described in DeviceOfBiped.
Devices in host method declaration allow coordination between different host methods which want to use the same devices.
If many host methods claim to use the same device, higher priority method will cath device. Other methods will be rejected. If lower priority method is already using this device, the lower priority method will be canceled.
Type сonversion
SymOntoClay provides automatic type conversion.
In future It will be described in details.