Example #1
0
        public static GameState Parse(string fen)
        {
            var parts = fen.Split(' ');

            var board  = parts[0];
            var colour = parts[1] == "w" ? Colour.White : Colour.Black;

            StateFlag castlingRights = ParseCastlingRights(parts[2]);

            SquareFlag enPassantSquare = 0;

            if (parts[3] != "-")
            {
                Enum.TryParse(parts[3].ToUpper(), out enPassantSquare);
            }

            var halfTurnCounter = 0;
            var fullMoveNumber  = 0;

            if (parts.Length > 4)
            {
                halfTurnCounter = int.Parse(parts[4]);
            }

            if (parts.Length > 5)
            {
                fullMoveNumber = int.Parse(parts[5]);
            }

            return(CreateGameState(board, colour, castlingRights, enPassantSquare, halfTurnCounter, fullMoveNumber));
        }
Example #2
0
        private StateFlag RemoveCastleAvailability(Colour colour, MoveType moveType, StateFlag boardState)
        {
            if (colour == Colour.White)
            {
                if (moveType == MoveType.CastleKing)
                {
                    boardState &= ~StateFlag.WhiteCanCastleKingSide;
                }
                if (moveType == MoveType.CastleQueen)
                {
                    boardState &= ~StateFlag.WhiteCanCastleQueenSide;
                }
            }
            else
            {
                if (moveType == MoveType.CastleKing)
                {
                    boardState &= ~StateFlag.BlackCanCastleKingSide;
                }
                if (moveType == MoveType.CastleQueen)
                {
                    boardState &= ~StateFlag.BlackCanCastleQueenSide;
                }
            }

            return(boardState);
        }
Example #3
0
 public RelativeBoard(
     Colour colour,
     SquareFlag myPawns,
     SquareFlag myRooks,
     SquareFlag myKnights,
     SquareFlag myBishops,
     SquareFlag myQueens,
     SquareFlag myKing,
     SquareFlag opponentPawns,
     SquareFlag opponentRooks,
     SquareFlag opponentKnights,
     SquareFlag opponentBishops,
     SquareFlag opponentQueens,
     SquareFlag opponentKing,
     StateFlag boardState)
 {
     Colour          = colour;
     OpponentColour  = colour.Opposite();
     MyPawns         = myPawns;
     MyRooks         = myRooks;
     MyKnights       = myKnights;
     MyBishops       = myBishops;
     MyQueens        = myQueens;
     MyKing          = myKing;
     OpponentPawns   = opponentPawns;
     OpponentRooks   = opponentRooks;
     OpponentKnights = opponentKnights;
     OpponentBishops = opponentBishops;
     OpponentQueens  = opponentQueens;
     OpponentKing    = opponentKing;
     _boardState     = boardState;
 }
Example #4
0
        private static StateFlag ParseCastlingRights(string castlingRights)
        {
            if (castlingRights == "-")
            {
                return(0);
            }

            StateFlag castlingState = 0;

            if (castlingRights.Contains("K"))
            {
                castlingState |= StateFlag.WhiteCanCastleKingSide;
            }

            if (castlingRights.Contains("Q"))
            {
                castlingState |= StateFlag.WhiteCanCastleQueenSide;
            }

            if (castlingRights.Contains("k"))
            {
                castlingState |= StateFlag.BlackCanCastleKingSide;
            }

            if (castlingRights.Contains("q"))
            {
                castlingState |= StateFlag.BlackCanCastleQueenSide;
            }

            return(castlingState);
        }
Example #5
0
        public bool SelectSelectorStateArea(Button selectedArea, int selectorPlayerNumber)
        {
            int selectedStateNumber = selectedTakeOverAreaNodes.First().ownedStateNumber;

            if (IsSelectorPlayerState(selectedArea, selectorPlayerNumber))
            {
                if (IsAreaAdjacent(selectedArea, selectedStateNumber, selectorBetAreaNodes))
                {
                    AreaSelectNode saverButton = new AreaSelectNode()
                    {
                        ownedStateNumber = StateFlag.GetPlayerNumberWithFlag(selectedArea.BackColor),
                        currentFlag      = selectedArea.BackColor,
                        areaNumber       = int.Parse(selectedArea.Name)
                    };

                    selectorBetAreaNodes.Push(saverButton);

                    selectedArea.BackColor = Color.White;

                    return(true);
                }
                else
                {
                    WarningMessager.AreaNotAdjacent();
                }
            }

            else
            {
                WarningMessager.NotSelectorPlayerState();
            }

            return(false);
        }
Example #6
0
        /// <summary>
        /// Change companion state machine state
        /// </summary>
        /// <param name="stateFlag">Flag of allowed state</param>
        private void ChangeState(StateFlag stateFlag)
        {
            if (this.States == null)
            {
                throw new InvalidStateException("State machine is not ready! Call setup first.");
            }

            if (!this.States.TryGetValue(stateFlag, out ICompanionState newState))
            {
                throw new InvalidStateException($"Invalid state {stateFlag.ToString()}. Is state machine correctly set up?");
            }

            if (this.currentState == newState)
            {
                return;
            }

            if (this.currentState != null)
            {
                this.currentState.Exit();
            }

            newState.Entry();
            this.currentState = newState;
            this.Monitor.Log($"{this.Name} changed state: {this.CurrentStateFlag.ToString()} -> {stateFlag.ToString()}");
            this.CurrentStateFlag = stateFlag;
        }
 public FSMState(string name, T entity, FSMStateMachine <T> parentFSM)
 {
     mName      = name;
     mEntity    = entity;
     mParentFSM = parentFSM;
     mStateFlag = StateFlag.BeforeEnter;
 }
Example #8
0
 public void Set(
     Colour colour,
     SquareFlag myPawns,
     SquareFlag myRooks,
     SquareFlag myKnights,
     SquareFlag myBishops,
     SquareFlag myQueens,
     SquareFlag myKing,
     SquareFlag opponentPawns,
     SquareFlag opponentRooks,
     SquareFlag opponentKnights,
     SquareFlag opponentBishops,
     SquareFlag opponentQueens,
     SquareFlag opponentKing,
     StateFlag boardState,
     SquareFlag enPassantSquare)
 {
     Colour          = colour;
     OpponentColour  = colour.Opposite();
     MyPawns         = myPawns;
     MyRooks         = myRooks;
     MyKnights       = myKnights;
     MyBishops       = myBishops;
     MyQueens        = myQueens;
     MyKing          = myKing;
     OpponentPawns   = opponentPawns;
     OpponentRooks   = opponentRooks;
     OpponentKnights = opponentKnights;
     OpponentBishops = opponentBishops;
     OpponentQueens  = opponentQueens;
     OpponentKing    = opponentKing;
     _boardState     = boardState;
     EnPassant       = enPassantSquare;
 }
Example #9
0
        public Board(
            SquareFlag whitePawns,
            SquareFlag whiteRooks,
            SquareFlag whiteKnights,
            SquareFlag whiteBishops,
            SquareFlag whiteQueens,
            SquareFlag whiteKing,
            SquareFlag blackPawns,
            SquareFlag blackRooks,
            SquareFlag blackKnights,
            SquareFlag blackBishops,
            SquareFlag blackQueens,
            SquareFlag blackKing,
            StateFlag state,
            SquareFlag enPassant)
        {
            WhitePawns   = whitePawns;
            WhiteRooks   = whiteRooks;
            WhiteKnights = whiteKnights;
            WhiteBishops = whiteBishops;
            WhiteQueens  = whiteQueens;
            WhiteKing    = whiteKing;
            BlackPawns   = blackPawns;
            BlackRooks   = blackRooks;
            BlackKnights = blackKnights;
            BlackBishops = blackBishops;
            BlackQueens  = blackQueens;
            BlackKing    = blackKing;

            keyGen.Init();

            Key = keyGen.Hash(this, Colour.White);

            history.Push(new BoardStateInfo(Key, 0, state, enPassant));
        }
        public void CreateMap(int numberPlayers, string[] stateNames)
        {
            CreateGameStates(numberPlayers, stateNames);
            CreateStateAreas(currentAreas, gameStates);
            const int FIRSTXCOORDINATE = 60;
            int       xCoordinate      = FIRSTXCOORDINATE;
            int       yCoordinate      = 0;

            for (int buttonRecorder = 0; buttonRecorder < currentAreas.Length; buttonRecorder++)
            {
                int playerNumber = FindPlayerNumberWithArea(numberPlayers, buttonRecorder);

                gameStates[playerNumber].ownedAreas.Add(buttonRecorder);

                CreateButtonProperties(buttonRecorder, xCoordinate, yCoordinate, StateFlag.GetFlag(playerNumber));


                if (xCoordinate - FIRSTXCOORDINATE >= 580)
                {
                    yCoordinate += 20;
                    xCoordinate  = FIRSTXCOORDINATE;
                }
                else
                {
                    xCoordinate += 20;
                }
            }
        }
Example #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bs"></param>
        public void SetSendData(byte[] bs)
        {
            //System.Diagnostics.Debug.Assert( _state == StateFlag.Idly );

            this._sendData = bs;
            this._sendTime = DateTime.Now;
            this._state    = StateFlag.Sended;
        }
Example #12
0
 /// <summary>
 ///
 /// </summary>
 public void Reset()
 {
     this._state       = StateFlag.Idly;
     this._sendTime    = DateTime.MinValue;
     this._receiveTime = DateTime.MinValue;
     this._sendData    = null;
     this._receiveData = null;
 }
Example #13
0
        private string[] GetDefaultStateName(int numberPlayers)
        {
            string[] stateNames = new string[numberPlayers];

            for (int stateNameRecorder = 0; stateNameRecorder < stateNames.Length; stateNameRecorder++)
            {
                stateNames[stateNameRecorder] = StateFlag.GetFlag(stateNameRecorder).Name;
            }

            return(stateNames);
        }
Example #14
0
        private void AnnexAreas(int annextationStateNumber, int requestedStateNumber, Stack <AreaSelectNode> annexedAreas)
        {
            while (annexedAreas.Count != 0)
            {
                AreaSelectNode oldAreaNode = annexedAreas.Pop();
                currentAreas[oldAreaNode.areaNumber].BackColor = StateFlag.GetFlag(annextationStateNumber);

                gameStates[annextationStateNumber].ownedAreas.Add(oldAreaNode.areaNumber);
                gameStates[requestedStateNumber].ownedAreas.Remove(oldAreaNode.areaNumber);
            }
        }
Example #15
0
 /// <summary>
 /// See <see cref="BeginGetGraphicsDevice"/> for details
 /// </summary>
 /// <param name="dirtyDeviceState"></param>
 public void EndGetGraphicsDevice(StateFlag dirtyDeviceState)
 {
     if (dirtyDeviceState != StateFlag.None)
     {
         if (protectedState)
         {
             throw new ArgumentException("StateFlag.None is the only supported parameter in the current context.");
         }
         DirtyInternalRenderState(dirtyDeviceState);
     }
 }
Example #16
0
        private void OnStateChange(int vehicle, StateFlag states)
        {
            if (vehicle != _vehicle)
            {
                return;
            }

            foreach (var state in (StateFlag[])Enum.GetValues(typeof(StateFlag)))
            {
                _states[state].Enabled = (states & state) == state;
            }
        }
 public ISMStateBase(string name, int priority, params string[] groups)
 {
     mName = name;
     if (groups == null)
     {
         GroupMask = 1;
     }
     else
     {
         GroupMask = ISMStateGroupMgr.Instance.CalculateGroupMask(groups);
     }
     PRIORITY   = priority;
     mStateFlag = StateFlag.BeforeEnter;
 }
Example #18
0
        private static void SetState(int vehicle, StateFlag flag, bool value)
        {
            var state = (StateFlag)API.DecorGetInt(vehicle, StateFlagsDecor);

            if (value)
            {
                state |= flag;
            }
            else
            {
                state &= ~flag;
            }

            API.DecorSetInt(vehicle, StateFlagsDecor, (int)state);
        }
        private void CreateGameStates(int numberPlayers, string [] stateNames)
        {
            gameStates = new GameState[numberPlayers];

            for (int playerRecorder = 0; playerRecorder < gameStates.Length; playerRecorder++)
            {
                GameState newGameState = new GameState
                {
                    name       = stateNames[playerRecorder],
                    ownedAreas = new List <object>(),
                    flag       = StateFlag.GetFlag(playerRecorder)
                };

                gameStates[playerRecorder] = newGameState;
            }
        }
Example #20
0
        public BoardStateInfo(ulong key, uint move, StateFlag state, SquareFlag enPassant) : this()
        {
            Key        = key;
            Move       = move;
            StateFlags = state;
            EnPassant  = enPassant;

            var movePieceType = move.GetPieceType();
            var moveType      = move.GetMoveType();

            if (movePieceType == PieceType.Pawn ||
                moveType == MoveType.CastleKing ||
                moveType == MoveType.CastleQueen)
            {
                IsIrreversible = true;
            }
        }
Example #21
0
 internal void ResetState(StateFlag state, ref DeviceRenderState current, DeviceContext device, bool reverseCull)
 {
     if ((state & StateFlag.StencilTest) != 0)
     {
         StencilTest.ResetState(ref current.StencilTest, device);
     }
     if ((state & StateFlag.AlphaBlend) != 0)
     {
         AlphaBlend.ResetState(ref current.AlphaBlend, device);
     }
     if ((state & StateFlag.AlphaTest) != 0)
     {
         AlphaTest.ResetState(ref current.AlphaTest, device);
     }
     if ((state & StateFlag.DepthColourCull) != 0)
     {
         DepthColourCull.ResetState(ref current.DepthColourCull, device, reverseCull);
     }
 }
Example #22
0
    /* --------------------------------------------------
     * Private Function
     * -------------------------------------------------- */

    private void Draw()
    {
        if (((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) ||
             (Input.GetMouseButton(0))) && touchCount == 0)
        {
            var        Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(Ray, out hit))
            {
                posStr = hit.point;
                posEnd = posStr;
                touchCount++;
            }
        }

        else if (((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) ||
                  (Input.GetMouseButton(0))))
        {
            var        Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(Ray, out hit))
            {
                posEnd = hit.point;
            }
        }

        if (posEnd != posStr)
        {
            var dir = posEnd - posStr;
            transform.position   = posStr + dir / 2.0f;
            transform.localScale = new Vector3(transform.localScale.x, dir.magnitude / SegmentHeight, transform.localScale.z);
            transform.rotation   = Quaternion.FromToRotation(Vector3.up, dir);
        }

        if (((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended) ||
             (Input.GetMouseButtonUp(0))))
        {
            stateFlag = StateFlag.INACTIVE;
        }
    }
Example #23
0
        public bool SelectOtherStateArea(Button selectedArea, int selectorPlayerNumber)
        {
            if (!IsSelectorPlayerState(selectedArea, selectorPlayerNumber))
            {
                if (!IsStateOfAnotherEnemyPlayer(selectedArea))
                {
                    if (IsAreaAdjacent(selectedArea, selectorPlayerNumber, selectedTakeOverAreaNodes))
                    {
                        AreaSelectNode areaNode = new AreaSelectNode()
                        {
                            ownedStateNumber = StateFlag.GetPlayerNumberWithFlag(selectedArea.BackColor),
                            currentFlag      = selectedArea.BackColor,
                            areaNumber       = int.Parse(selectedArea.Name)
                        };

                        selectedTakeOverAreaNodes.Push(areaNode);

                        selectedArea.BackColor = Color.Black;

                        return(true);
                    }
                    else
                    {
                        WarningMessager.AreaNotAdjacent();
                    }
                }

                else
                {
                    WarningMessager.StateOfEnemyPlayer();
                }
            }

            else
            {
                WarningMessager.SelectorPlayerState();
            }

            return(false);
        }
 public virtual void Enter()
 {
     mStateFlag = StateFlag.Executing;
 }
Example #25
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                string str  = trigger.Text.NextModifiers();
                string name = "";

                if (str.Contains("n"))
                {
                    name = trigger.Text.NextWord();
                }
                Unit target = trigger.Args.Target;

                if (target == null)
                {
                    trigger.Reply("No target found.");
                }
                else
                {
                    Map rgn = target.Map;
                    if (rgn == null)
                    {
                        trigger.Reply("Instances are currently not supported.");
                    }
                    else
                    {
                        NPC npc = null;
                        rgn.ExecuteInContext(() =>
                        {
                            foreach (WorldObject worldObject in rgn)
                            {
                                if (worldObject is NPC && (name == "" || worldObject.Name.ContainsIgnoreCase(name)))
                                {
                                    npc = (NPC)worldObject;
                                    break;
                                }
                            }
                        });
                        if (npc == null)
                        {
                            trigger.Reply("Could not find a matching NPC.");
                        }
                        else
                        {
                            Character character = trigger.Args.Character;
                            if (trigger.Args.HasCharacter)
                            {
                                if (name == "" && character.Target != null)
                                {
                                    if (character.Target is NPC)
                                    {
                                        npc = character.Target as NPC;
                                    }
                                    else
                                    {
                                        character.Target = npc;
                                    }
                                }
                                else
                                {
                                    character.Target = npc;
                                }
                            }
                            else
                            {
                                trigger.Args.Target  = npc;
                                trigger.Args.Context = npc;
                            }

                            trigger.Reply("Selected: {0}", (object)npc);
                            NPCFlags npcFlags = npc.NPCFlags;
                            trigger.Reply("NPCFlags {0}:{1}", (object)npcFlags, (object)npcFlags);
                            UnitDynamicFlags dynamicFlags = npc.DynamicFlags;
                            trigger.Reply("DynamicFlags {0}:{1}", (object)dynamicFlags, (object)dynamicFlags);
                            UnitExtraFlags extraFlags = npc.ExtraFlags;
                            trigger.Reply("ExtraFlags {0}:{1}", (object)extraFlags, (object)extraFlags);
                            StateFlag stateFlags = npc.StateFlags;
                            trigger.Reply("StateFlags {0}:{1}", (object)stateFlags, (object)stateFlags);
                            UnitFlags unitFlags = npc.UnitFlags;
                            trigger.Reply("UnitFlags {0}:{1}", (object)unitFlags, (object)(int)unitFlags);
                            UnitFlags2 unitFlags2 = npc.UnitFlags2;
                            trigger.Reply("UnitFlags2 {0}:{1}", (object)unitFlags2, (object)unitFlags2);
                        }
                    }
                }
            }
Example #26
0
        /// <summary>
        /// <para>WARNING: Use with caution. Dirties internally tracked render state caches</para>
        /// <para>See documentation for <see cref="BeginGetGraphicsDevice"/>.</para>
        /// </summary>
        /// <param name="dirtyState"></param>
        public void DirtyInternalRenderState(StateFlag dirtyState)
        {
#if DEBUG
            System.Threading.Interlocked.Increment(ref application.currentFrame.DirtyRenderStateCount);
#endif
            ValidateProtected();

            if ((dirtyState & StateFlag.Shaders) != 0)
            {
#if DEBUG
                System.Threading.Interlocked.Increment(ref application.currentFrame.DirtyRenderShadersStateCount);
#endif
                boundShader           = null;
                boundShaderType       = null;
                boundShaderStateDirty = true;
            }

            if ((dirtyState & StateFlag.VerticesAndIndices) != 0)
            {
#if DEBUG
                System.Threading.Interlocked.Increment(ref application.currentFrame.DirtyRenderVerticesAndIndicesStateCount);
#endif
                for (int i = 0; i < vertexStreams.Length; i++)
                {
                    vertexStreams[i].vb     = null;
                    vertexStreams[i].offset = -1;
                    vertexStreams[i].stride = -1;
                }
                vertexDecl  = null;
                indexBuffer = null;
            }

            if ((dirtyState & StateFlag.Textures) != 0)
            {
#if DEBUG
                System.Threading.Interlocked.Increment(ref application.currentFrame.DirtyRenderTexturesStateCount);
#endif
                boundShaderStateDirty = true;
                boundShader           = null;
                for (int i = 0; i < psSamplerDirty.Length; i++)
                {
                    psSamplerDirty[i] = true;
                }
                for (int i = 0; i < vsSamplerDirty.Length; i++)
                {
                    vsSamplerDirty[i] = true;
                }

                for (int i = 0; i < psTextures.Length; i++)
                {
                    psTextures[i] = null;
                }
                for (int i = 0; i < vsTextures.Length; i++)
                {
                    vsTextures[i] = null;
                }

#if DEBUG
                for (int i = 0; i < psTexturesDEBUG.Length; i++)
                {
                    psTexturesDEBUG[i] = null;
                }
                for (int i = 0; i < vsTexturesDEBUG.Length; i++)
                {
                    vsTexturesDEBUG[i] = null;
                }
#endif
            }

            internalStateDirty |= dirtyState;
        }
Example #27
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="bs"></param>
        public void SetSendData( byte[] bs )
        {
            //System.Diagnostics.Debug.Assert( _state == StateFlag.Idly );

            this._sendData = bs;
            this._sendTime = DateTime.Now;
            this._state = StateFlag.Sended ;
        }
Example #28
0
        internal void ApplyRenderStateChanges(int vertexCount)
        {
#if DEBUG
            ValidateRenderState();
#endif
            if (this.bufferVertexCount != vertexCount)
            {
                this.bufferVertexCountChangeIndex++;
                this.bufferVertexCount = vertexCount;
            }


            if (internalStateDirty != StateFlag.None)
            {
                visibleState.state.ResetState(internalStateDirty, ref internalState, graphics, cameraInvertsCullMode);
                internalStateDirty = StateFlag.None;
            }

            visibleState.state.ApplyState(ref internalState, graphics, cameraInvertsCullMode
#if DEBUG
                                          , this
#endif
                                          );

            if (boundShader != null &&
                (boundShaderStateDirty ||
                 (boundShaderUsesVertexCount) ||
                 (boundShaderUsesWorldMatrix && boundShaderWorldIndex != ms_World.index) ||
                 (boundShaderUsesProjectionMatrix && boundShaderProjectionIndex != ms_Projection.index) ||
                 (boundShaderUsesViewMatrix && boundShaderViewIndex != ms_View.index) ||
                 (boundShader.HasChanged)))
            {
#if DEBUG
                System.Threading.Interlocked.Increment(ref application.currentFrame.ShaderRebindCount);
#endif
                boundShader.Bind(this);
            }


            if (vertexShaderToBind != boundVertexShader)
            {
                graphics.VertexShader = vertexShaderToBind;
                boundVertexShader     = vertexShaderToBind;
            }

            if (pixelShaderToBind != boundPixelShader)
            {
                graphics.PixelShader = pixelShaderToBind;
                boundPixelShader     = pixelShaderToBind;
            }

            if (pixelShaderConstantsToBind != null)
            {
                graphics.SetPixelShaderConstant(0, pixelShaderConstantsToBind);
                pixelShaderConstantsToBind = null;
            }
            if (pixelShaderBooleanConstantsToBind != null)
            {
                graphics.SetPixelShaderConstant(0, pixelShaderBooleanConstantsToBind);
                pixelShaderBooleanConstantsToBind = null;
            }

            if (vertexShaderConstantsToBind != null)
            {
                graphics.SetVertexShaderConstant(0, vertexShaderConstantsToBind);
                vertexShaderConstantsToBind = null;
#if XBOX360
                //must reassign the vertex shader on the xbox whenever the shader constants have changed...
                boundVertexShader = null;
#endif
            }
            if (vertexShaderBooleanConstantsToBind != null)
            {
                graphics.SetVertexShaderConstant(0, vertexShaderBooleanConstantsToBind);
                vertexShaderBooleanConstantsToBind = null;
#if XBOX360
                boundVertexShader = null;
#endif
            }
        }
Example #29
0
 /// <summary>
 /// 
 /// </summary>
 public void Reset()
 {
     this._state = StateFlag.Idly;
     this._sendTime = DateTime.MinValue;
     this._receiveTime = DateTime.MinValue;
     this._sendData = null;
     this._receiveData = null;
 }
Example #30
0
 public virtual bool CheckStateFlag(StateFlag flag)
 {
     return this.StateFlag == flag;
 }
Example #31
0
        private static bool GetLastState(int vehicle, StateFlag flag)
        {
            var state = (StateFlag)API.DecorGetInt(vehicle, StateFlagsDecor);

            return((state & flag) == flag);
        }
Example #32
0
 public virtual void SetStateFlag(StateFlag flag)
 {
     this.StateFlag = flag;
 }
 public virtual void Exit()
 {
     mStateFlag = StateFlag.AfterExit;
 }
		internal void DirtyInternalRenderState(StateFlag dirtyState)
		{
			this.shaderSystem.DirtyInternalRenderState(dirtyState);
		}
Example #35
0
        /// <summary>
        /// <para>Gets the graphics device. WARNING: Use with caution. A matching call to <see cref="EndGetGraphicsDevice()"/> must be made when direct graphics device access is complete</para>
        /// <para><paramref name="dirtyDeviceState"/> must be set correctly. Use <see cref="StateFlag.None"/> when using the device to create a resource. Use the appropriate combination of <see cref="StateFlag"/> flags when (for example) binding an XNA Effect object that changes render state.</para>
        /// <para>If using the <see cref="GraphicsDevice"/> to change render state, prefer using <see cref="DrawState.RenderState"/> where states are implemented.</para>
        /// </summary>
        /// <param name="dirtyDeviceState">Set to the values of <see cref="StateFlag"/> that reflect the render states you plan to manually change, or you are using an XNA object that changes render state itself</param>
        /// <remarks><para>Currently <see cref="EndGetGraphicsDevice()"/> has no effect, and calls will not be validated.</para>
        /// <para>Graphics device access is setup in such a way to allow future updates to perform multithreaded rendering. It is expected that during a Begin/End GetGraphicsDevice block, all such optimisations will need to be disabled.</para></remarks>
        /// <returns></returns>
        public Microsoft.Xna.Framework.Graphics.GraphicsDevice BeginGetGraphicsDevice(StateFlag dirtyDeviceState)
        {
#if DEBUG
            System.Threading.Interlocked.Increment(ref application.currentFrame.BeginGetGraphicsDeviceCount);
#endif
            //may do state tracking reset in the future, if optimizations require it, hence internal method above
            if (dirtyDeviceState != StateFlag.None)
            {
                if (protectedState)
                {
                    throw new ArgumentException("StateFlag.None is the only supported parameter in the current context.");
                }
                DirtyInternalRenderState(dirtyDeviceState);
            }
            return(graphics);
        }