Command Action and Data
CommandAction Enum
Specifies a command action.
Syntax
[Sansar.Script.Interface] [System.Flags] public enum CommandAction
Remarks
Members
Member Name | Description |
---|---|
All | A combination of all other values. |
Invalid | An invalid command action. |
Pressed | Fired when the command is pressed. |
Released | Fired when the command is released. |
Requirements
Namespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
CommandData
CommandData Class
Command events are generated by the client when input events occur.
Syntax
Remarks
Command | Default Key Binding |
---|---|
Trigger | Left Mouse Button |
PrimaryAction | F |
SecondaryAction | R |
Modifier | Shift |
Action1 to Action0 | Number keys 1 to 0 |
Confirm | Enter |
Cancel | Escape |
SelectLeft | Left arrow |
SelectRight | Right arrow |
SelectUp | Up arrow |
SelectDown | Down arrow |
Keypad0 to Keypad9 | Numberpad keys 0 to 9 |
KeypadEnter | Numberpad Enter |
An example script for handling client commands:
C# Example |
When using this content, you must:
� Acknowledge that the content is from the Sansar Knowledge Base.
� Include our copyright notice: "� 2017 Linden Research, Inc."
� Indicate that the content is licensed under the Creative Commons Attribution-Share Alike 4.0 International License.
� Include the URL for, or link to, the license summary at https://creativecommons.org/licenses/by-sa/4.0/deed.hi (and, if possible, to the complete license terms at https://creativecommons.org/licenses/by-sa/4.0/legalcode.
For example:
"This work uses content from the Sansar Knowledge Base. � 2017 Linden Research, Inc. Licensed under the Creative Commons Attribution 4.0 International License (license summary available at https://creativecommons.org/licenses/by/4.0/ and complete license terms available at https://creativecommons.org/licenses/by/4.0/legalcode)." */ using Sansar.Script; using Sansar.Simulation; public class CommandExample : SceneObjectScript { #region ScriptParameters [Tooltip(@"The command to enable listening for the Action Command. Default: Confirm (Enter)")] [DefaultValue("Confirm")] [DisplayName("Subscribe Command")] public readonly string SubscribeCommand; [Tooltip(@"The command to disable listening for the Action Command. Default: Cancel (Escape)")][DefaultValue("Cancel")][DisplayName("Unsubscribe Command")]public readonly string UnsubscribeCommand;[Tooltip(@"If the command has been subscribed to by the 'Subscribe Command', this will log the action to the script console.")][DefaultValue("Trigger")][DisplayName("Action Command")]public readonly string ActionCommand;#endregion ScriptParameterspublic override void Init(){// Subscribe to new user events;ScenePrivate.User.Subscribe(User.AddUser, NewUser);}IEventSubscription subscription = null;void NewUser(UserData newUser){ Client client = ScenePrivate.FindAgent(newUser.User).Client; // CommandReceived will be called every time the command it triggered on the client // CommandCanceled will be called if the subscription fails if (SubscribeCommand != "") { client.SubscribeToCommand(SubscribeCommand, CommandAction.Pressed, (data) => { if (subscription == null) { Log.Write(GetType().Name, $"[{SubscribeCommand}] Subscribing to {ActionCommand}."); subscription = client.SubscribeToCommand(ActionCommand, CommandAction.All, CommandReceived, CommandCanceled); } }, CommandCanceled); } if (UnsubscribeCommand != "") { client.SubscribeToCommand(UnsubscribeCommand, CommandAction.Pressed, (data) => { if (subscription != null) { Log.Write(GetType().Name, $"[{UnsubscribeCommand}] Unsubscribing to {ActionCommand}."); subscription.Unsubscribe(); subscription = null; } }, CommandCanceled); }}void CommandReceived(CommandData command){ Log.Write(GetType().Name, $"Received command {command.Command}: {command.Action}. Targeting Info: {command.TargetingComponent}, Origin:{command.TargetingOrigin}, Position:{command.TargetingPosition}, Normal{command.TargetingNormal}");}void CommandCanceled(CancelData data){ Log.Write(GetType().Name, "Subscription canceled: "+data.Message);} } |
Requirements
Namespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
Members
Member Details
Action Property
The action which occurred.
Syntax[get: Sansar.Script.Interface] public CommandAction Action { get; }
Value
Remarks
RequirementsNamespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
CameraControlMode Property
Syntax[get: Sansar.Script.Interface] public CameraControlMode CameraControlMode { get; }
Value
Remarks
RequirementsNamespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
Command Property
The command which occurred.
Syntax[get: Sansar.Script.Interface] public string Command { get; }
Value
Remarks
RequirementsNamespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
ControlPoint Property
Syntax[get: Sansar.Script.Interface] public ControlPointType ControlPoint { get; }
Value
Remarks
RequirementsNamespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
MouseLookMode Property
Syntax[get: Sansar.Script.Interface] public bool MouseLookMode { get; }
Value
Remarks
RequirementsNamespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
SessionId Property
The client which generated the event.
SyntaxValue
Remarks
RequirementsNamespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
SimulationFrame Property
Syntax[get: Sansar.Script.Interface] public ulong SimulationFrame { get; }
Value
Remarks
RequirementsNamespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
TargetingComponent Property
SyntaxValue
Remarks
RequirementsNamespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
TargetingNormal Property
Syntax[get: Sansar.Script.Interface] public Sansar.Vector TargetingNormal { get; }
Value
Remarks
RequirementsNamespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
TargetingOrigin Property
Syntax[get: Sansar.Script.Interface] public Sansar.Vector TargetingOrigin { get; }
Value
Remarks
RequirementsNamespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
TargetingPosition Property
Syntax[get: Sansar.Script.Interface] public Sansar.Vector TargetingPosition { get; }
Value
Remarks
RequirementsNamespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
ToString Method
A string representation of this object.
Syntax[Sansar.Script.Interface] public override string ToString ()
Returns
A string representation of this object.
RemarksThe format of this string may change between releases.
RequirementsNamespace: Sansar.Simulation Assembly: Sansar.Simulation (in Sansar.Simulation.dll) Assembly Versions: 1.1.0.0
Last updated