Page 1 of 1

Wrong initial IPlayer.CurrentCommandIndex value

Posted: Fri Mar 25, 2022 5:40 pm
by NearHuscarl
When a player is spawned, the initial IPlayer.CurrentCommandIndex value is -1, this is inconsistent with the docs:
CurrentCommandIndex[get]
Returns the current command action index being processed. If this equals to PerformedCommandActionsCount then no more command actions are queued
This means when there are no other commands to execute, CurrentCommandIndex = PerformedCommandActionsCount - 1. Calling ClearCommandQueue() will then reset the CurrentCommandIndex to 0 which is the correct initial value.

Current behavior:

Code: Select all

player.SetInputEnabled(false);

// CurrentCommandIndex: -1, PerformedCommandCount: 0
player.AddCommand(new PlayerCommand(PlayerCommandType.StartCrouch));
// CurrentCommandIndex: 0, PerformedCommandCount: 1
player.AddCommand(new PlayerCommand(PlayerCommandType.Grab));
// CurrentCommandIndex: 1, PerformedCommandCount: 2
Expected result (without having to call ClearCommandQueue()):

Code: Select all

player.SetInputEnabled(false);
player.ClearCommandQueue();

// CurrentCommandIndex: 0, PerformedCommandCount: 0
player.AddCommand(new PlayerCommand(PlayerCommandType.StartCrouch));
// CurrentCommandIndex: 1, PerformedCommandCount: 1
player.AddCommand(new PlayerCommand(PlayerCommandType.Grab));
// CurrentCommandIndex: 2, PerformedCommandCount: 2