Exemple #1
0
        private IAction SendActionsAndWaitForResponse(
            IInitiativeActor activeEntity,
            ICharacterController activeController,
            IReadOnlyDictionary <uint, IAction> availableActions)
        {
            IAction selectedAction;

            do
            {
                // Send Actions to Controller
                _pendingSelectedActionId = null;
                activeController.SelectAction(activeEntity, availableActions, OnActionSelected);

                // Wait for Controller response
                do
                {
                    Thread.Sleep(ACTION_REQUEST_SLEEP_TIME);
                } while (!_pendingSelectedActionId.HasValue);

                // Validate response
                availableActions.TryGetValue(_pendingSelectedActionId.Value, out selectedAction);

                _pendingSelectedActionId = null;
            } while (selectedAction == null || !selectedAction.Available);

            return(selectedAction);
        }