public bool GiveControl(GameEntity entity) { // todo: maybe instead when an actor is blocked, he should resolve his action // and store it and don't execute it until ready if (entity.hasBlockedUntil && DateTime.UtcNow < entity.blockedUntil.BlockedUntil) { return(false); } IGameAction gameAction; try { gameAction = _actionResolver.GetAction(entity); } catch (Exception e) { Debug.LogError(e.Message + ", stack trace: " + e.StackTrace); gameAction = new LambdaAction(entity, 1f, null, gameEntity => Enumerable.Empty <IActionEffect>()); } bool gameActionIsResolved = gameAction != null; if (gameActionIsResolved) { // Debug.Log($"{entity.view.Controller.Name} has action: {gameAction.GetType().Name}"); PerformTurn(entity, gameAction); return(true); } return(false); }
public IGameAction GetAction(GameEntity entity) { if (entity.isPlayerControlled) { return(_playerActionResolver.GetAction(entity)); } return(_aiActionResolver.GetAction(entity)); }