Indiefreaks.Xna.Logic.Command.Process C# (CSharp) Method

Process() private method

private Process ( float elapsed ) : void
elapsed float
return void
        internal void Process(float elapsed)
        {
            if(_tick < 1f / _frequencyValue)
                return;

            _tick = 0f;

            if (Condition != null)
            {
                if (!Condition.Invoke())
                    return;
            }

            if (WaitingForServerReply)
                return;

            // If command is local, we just execute the command
            if (Type == CommandType.Local)
            {
                ClientExecution(this);
            }
            // If command is local & server, we execute the command locally and request the command to be executed on the server. Once
            // executed, the server will get back to us requesting to perform the command with a server computed value.
            else if (Type == CommandType.LocalAndServer)
            {
                NetworkValue = ClientExecution(this);

                SessionManager.CurrentSession.ExecuteCommandOnServer(this);
            }
            // If command is server only, we ask the server to execute it
            else
            {
                if (SessionManager.CurrentSession.IsHost)
                {
                    NetworkValue = ServerExecution(this, null);

                    if (ApplyServerResult != null)
                        SessionManager.CurrentSession.ExecuteServerCommandOnClients(this);
                }
            }
        }

Usage Example

Esempio n. 1
0
 protected virtual void Process(float elapsed)
 {
     for (int i = 0; i < Commands.Count; i++)
     {
         Command command = Commands[i];
         command.Process(elapsed);
     }
 }