/// <summary>
        /// Executes behavior with given context
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public override BehaviorReturnCode Behave(IBehaviorContext context)
        {
            PlayerBehaviorContext playerContext = context as PlayerBehaviorContext;

            if (playerContext == null)
            {
                returnCode = BehaviorReturnCode.Failure;
                return(returnCode);
            }

            Player player = playerContext.Player;
            PlayerRelationValue relation = playerContext.RelationValues.Current;

            if (player == null || relation.DeclarationCooldown != 0 || relation.PropositionState != DiplomaticActions.None || !relation.AvailableActions.HasFlag(DiplomaticAction))
            {
                returnCode = BehaviorReturnCode.Failure;
                return(returnCode);
            }

            Player otherPlayer = relation.Player;

            if (otherPlayer == null || otherPlayer.IsEliminated)
            {
                returnCode = BehaviorReturnCode.Failure;
                return(returnCode);
            }

            bool currentState = relation.GetActionState(DiplomaticAction);

            if (currentState)
            {
                returnCode = BehaviorReturnCode.Failure;
                return(returnCode);
            }

            bool canActivate = relation.GetDiplomaticActionEnableState(DiplomaticAction, player.GameSession.EnvironmentConfig.DiplomacyConfig);

            if (canActivate)
            {
                DispatcherHelper.InvokeOnMainThread(otherPlayer, new Action(() =>
                {
                    player.ProposeDiplomaticAction(relation, DiplomaticAction);
                }));

                returnCode = BehaviorReturnCode.Success;
                return(returnCode);
            }

            returnCode = BehaviorReturnCode.Failure;
            return(returnCode);
        }
        /// <summary>
        /// Executes behavior with given context
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public override BehaviorReturnCode Behave(IBehaviorContext context)
        {
            PlayerBehaviorContext playerContext = context as PlayerBehaviorContext;

            if (playerContext == null)
            {
                returnCode = BehaviorReturnCode.Failure;
                return(returnCode);
            }

            Player player = playerContext.Player;
            PlayerRelationValue relation = playerContext.RelationValues.Current;

            /*
             * if (!relation.AvailableActions.HasFlag(Action))
             * {
             *  returnCode = BehaviorReturnCode.Failure;
             *  return returnCode;
             * }
             */

            Player otherPlayer = relation.Player;

            if (otherPlayer == null)
            {
                returnCode = BehaviorReturnCode.Failure;
                return(returnCode);
            }

            if (otherPlayer.IsEliminated)
            {
                returnCode = BehaviorReturnCode.Success;
                return(returnCode);
            }

            bool currentState = relation.GetActionState(Action);

            if (currentState == State || !relation.AvailableActions.HasFlag(Action))
            {
                returnCode = BehaviorReturnCode.Failure;
                return(returnCode);
            }

            if (Action == DiplomaticActions.BordersControl && relation.IsEntryAllowed == State)
            {
                returnCode = BehaviorReturnCode.Failure;
                return(returnCode);
            }

            bool canActivate = relation.GetDiplomaticActionEnableState(Action, player.GameSession.EnvironmentConfig.DiplomacyConfig);

            if (canActivate || IsProposition)
            {
                if (!IsProposition)
                {
                    float cost = player.GameSession.EnvironmentConfig.DiplomacyConfig.GetActionCost(Action);
                    if (cost > player.Intelligence)
                    {
                        returnCode = BehaviorReturnCode.Failure;
                        return(returnCode);
                    }
                }

                if (State)
                {
                    DispatcherHelper.InvokeOnMainThread(relation.Player, new Action(() =>
                    {
                        player.ActivateDiplomaticAction(relation, Action, !IsProposition);
                    }));
                }
                else
                {
                    DispatcherHelper.InvokeOnMainThread(relation.Player, new Action(() =>
                    {
                        player.DeactivateDiplomaticAction(relation, Action, !IsProposition);
                    }));
                }

                returnCode = BehaviorReturnCode.Success;
                return(returnCode);
            }

            returnCode = BehaviorReturnCode.Failure;
            return(returnCode);
        }