Exemplo n.º 1
0
    public void CorrectPosition(int lastControlCommandApplied, Vector3 correctPosition, Vector3 correctMomentum, float correctDirection, Vector3 correctVelocity, float crouch_factor)
    {
        ////Debug.Log (MyPlayer.networkView.viewID + ") " + "Correcting my position");
        LastCorrectionRespondedTo = lastControlCommandApplied;

        // 12A: Reposition the player to match when the server sent the correction
        MyPlayer.transform.position = correctPosition;
        MyPlayer.state.angle        = correctDirection;
        SceneCharacter3D p = (SceneCharacter3D)MyPlayer;

        p.state.pos      = correctPosition;
        p.state.momentum = correctMomentum;
        p.state.angle    = correctDirection;
        p.state.velocity = correctVelocity;
        p.crouch_factor  = crouch_factor;

        // 12B: Make up for control commands which were sent between when the server sent the correction and now
        ////Debug.Log (MyPlayer.networkView.viewID + ") " + "Applying missing commands, starting with " + (lastControlCommandApplied + 1) + ", up to " + CurrentControlCommandId);
        while (ControlCommands.ContainsKey(lastControlCommandApplied + 1))
        {
            Debug.Log(MyPlayer.GetComponent <NetworkView>().viewID + ") " + "Applying CC " + lastControlCommandApplied + 1);
            MyPlayer.ExecuteControlCommand(ControlCommands[lastControlCommandApplied + 1]);
            lastControlCommandApplied++;
        }

        UpdateCamera();
    }
Exemplo n.º 2
0
	public void NewMessage(ControlCommands command)
	{
		header.timestamp_us = Timestamp.TimestampUs ();
		header.protocol_version = CONTROL_PROTOCOL_VERSION;
		header.command = command;
		header.payload_length = 0;
	}
Exemplo n.º 3
0
	public void FromBinary(BinaryReader reader)
	{
		timestamp_us = (ulong)IPAddress.NetworkToHostOrder(reader.ReadInt64());
		protocol_version = reader.ReadByte ();
		command = (ControlCommands) reader.ReadSByte ();
		payload_length = (ushort)IPAddress.NetworkToHostOrder(reader.ReadInt16());
	}
Exemplo n.º 4
0
	private ModuleState ModuleStateFromControlCommand(ControlCommands cmd)
	{
		if (cmd == ControlCommands.ENABLED)
			return ModuleState.Online;
		if (cmd == ControlCommands.DISABLED)
			return ModuleState.Offline;
		if (cmd == ControlCommands.FAILED)
			return ModuleState.Failed;
		throw new ArgumentException("Unable to convert command " + cmd.ToString() + " to ModuleState");	
	}
Exemplo n.º 5
0
        /// <summary>
        /// This takes in a JSON string and parses it to add to the dictionary of player commands
        /// </summary>
        /// <param name="serializedObject">JSON string of the serialized object</param>
        /// <param name="ID">ID of the socket state for the command</param>
        private static void UpdateObject(string serializedObject, int ID)
        {
            JObject obj   = JObject.Parse(serializedObject);
            JToken  token = obj["moving"];

            if (token != null)
            {
                ControlCommands com = JsonConvert.DeserializeObject <ControlCommands>(serializedObject);
                TheWorld.UpdateCommand(ID, com);
                return;
            }
        }
Exemplo n.º 6
0
    /// <summary>
    /// 9: Send a new control request every frame
    /// </summary>
    private void UpdateControls()
    {
        // 9A: Create a new control command to record player's keyboard/mouse input for the frame
        CurrentControlCommandId++;
        CurrentControlCommand = new ControlCommand(((Character)MyPlayer).Id, CurrentControlCommandId);

        // 9B: Set the duration of the control command to be the duration since the last frame
        CurrentControlCommand.Duration = Time.fixedDeltaTime;

        UpdateMovementControls();

        UpdateMouseLookControls();

        // 9F: Add the control command for this frame to the list of control commands
        ControlCommands.Add(CurrentControlCommandId, CurrentControlCommand);
    }
Exemplo n.º 7
0
        /// <summary>
        /// The CLI thread
        /// </summary>
        private void RunCliThread()
        {
            ControlCommands controlCommands = new ControlCommands(_system, _controller);
            CommandExecutor executor        = new CommandExecutor(this, controlCommands);
            DebuggerPrompt  prompt          = new DebuggerPrompt(executor.CommandTreeRoot);

            CommandResult state = CommandResult.Normal;

            while (state != CommandResult.Quit &&
                   state != CommandResult.QuitNoSave)
            {
                state = CommandResult.Normal;
                try
                {
                    // Get the command string from the prompt.
                    string command = prompt.Prompt().Trim();

                    if (command != String.Empty)
                    {
                        state = executor.ExecuteCommand(command);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            //
            // Ensure the emulator is stopped.
            //
            _controller.StopExecution();

            //
            // Commit disks if asked to do so.
            //
            _commitDisksAtShutdown = (state == CommandResult.Quit);

            //
            // Ensure the main window is closed.
            //
            _mainWindow.Close();
        }
Exemplo n.º 8
0
	private void ProcessMessage(ControlMessage message)
	{
		ControlCommands cmd = message.GetCommand();

		switch (cmd)
		{
			case ControlCommands.KEEPALIVE:
				break;
			case ControlCommands.ENABLED:				
			case ControlCommands.DISABLED:
			case ControlCommands.FAILED: //failed has additional information on error code
				RobotModule module = modules.Find(m => (m.name == message.Attribute<string>(0)));
				print(name + " - " + module.name + " state changed to " + cmd.ToString());
				module.SetState(ModuleStateFromControlCommand(cmd));
				break;
			default:
				print(name + " - ignoring unsupported command " + message.GetType());
				break;
		}
	}
Exemplo n.º 9
0
 /// <summary>
 /// Register all commands
 /// </summary>
 public static void Register(EpsInterpreter interpreter)
 {
     DictionaryCommands.Register(interpreter);
     StackCommands.Register(interpreter);
     ArithmeticCommands.Register(interpreter);
     CombinedCommands.Register(interpreter);
     PathCommands.Register(interpreter);
     MiscCommands.Register(interpreter);
     GraphicStateCommands.Register(interpreter);
     PaintingCommands.Register(interpreter);
     DeviceSetupCommands.Register(interpreter);
     ArrayCommands.Register(interpreter);
     MatrixCommands.Register(interpreter);
     ControlCommands.Register(interpreter);
     BooleanCommands.Register(interpreter);
     ConversionCommands.Register(interpreter);
     StringCommands.Register(interpreter);
     MemoryCommands.Register(interpreter);
     ResourceCommands.Register(interpreter);
     FontCommands.Register(interpreter);
     InterpreterCommands.Register(interpreter);
     FileCommands.Register(interpreter);
     PatternCommands.Register(interpreter);
 }
Exemplo n.º 10
0
 public SwitchWindowRule(ControlCommands ctrlCommands) =>
Exemplo n.º 11
0
 public CloseWindowRule(ControlCommands ctrlCommands) =>
 public void SwitchWindow()
 {
     ControlCommands.SwitchWindow();
 }
 public void CloseWindow()
 {
     ControlCommands.CloseWindow();
 }
 public SwitchWindowRule(ControlCommands ctrlCommands)
 {
     _ctrlCommands = ctrlCommands;
 }
 public CloseWindowRule(ControlCommands ctrlCommands)
 {
     _ctrlCommands = ctrlCommands;
 }