Exemplo n.º 1
0
        private void Client_ReceiveHitCall(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            Vec3      hitPosition      = reader.ReadVec3();
            string    hitShapeBodyName = reader.ReadString();
            string    hitShapeName     = reader.ReadString();
            Vec3      hitNormal        = reader.ReadVec3();
            MapObject hitMapObject     = Entities.Instance.GetByNetworkUIN(reader.ReadVariableUInt32()) as MapObject;

            if (!reader.Complete())
            {
                return;
            }

            Position = hitPosition;
            Shape hitShape = null;

            if (PhysicsModel != null)
            {
                Body body = PhysicsModel.GetBody(hitShapeBodyName);
                if (body != null)
                {
                    hitShape = body.GetShape(hitShapeName);
                }
            }
            OnHit(hitShape, hitNormal, hitMapObject);
        }
        private bool ReceiveMessage_TransferMessageToServer(NetworkNode.ConnectedNode sender,
            MessageType messageType, ReceiveDataReader reader, ref string error)
        {
            string message = reader.ReadString();
            string data = reader.ReadString();
            if (!reader.Complete())
                return false;

            if (ReceiveMessage != null)
                ReceiveMessage(this, sender, message, data);

            return true;
        }
        bool ReceiveMessage_TransferMessageToClient( NetworkNode.ConnectedNode sender,
            MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage)
        {
            string message = reader.ReadString();
            string data = reader.ReadString();
            if( !reader.Complete() )
                return false;

            if( ReceiveMessage != null )
                ReceiveMessage( this, message, data );

            return true;
        }
Exemplo n.º 4
0
        private void Client_ReceiveIntellect(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            uint        networkUIN = reader.ReadVariableUInt32();
            bool        shouldDeleteAfterDetach = reader.ReadBoolean();
            FactionType ft = null;

            if (GameMap.Instance.GameType == GameMap.GameTypes.AssaultKnights)
            {
                string factionName = reader.ReadString();
                if (factionName != string.Empty)
                {
                    ft = (FactionType)EntityTypes.Instance.GetByName(factionName);
                }
            }
            if (!reader.Complete())
            {
                return;
            }

            Intellect i = null;

            if (networkUIN != 0)
            {
                i = (Intellect)Entities.Instance.GetByNetworkUIN(networkUIN);
                if (ft != null)
                {
                    i.Faction = ft;
                }
            }
            SetIntellect(i, shouldDeleteAfterDetach);
        }
Exemplo n.º 5
0
        void Client_ReceiveAddUser(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            uint   identifier     = reader.ReadVariableUInt32();
            string name           = reader.ReadString();
            bool   bot            = reader.ReadBoolean();
            uint   userIdentifier = reader.ReadVariableUInt32();

            if (!reader.Complete())
            {
                return;
            }

            //check for already exists
            {
                Client_Player playerForCheck = Client_GetPlayer(identifier);

                if (playerForCheck != null)
                {
                    Log.Fatal("PlayerManager: Client_ReceiveAddUserToClient: Player " +
                              "with identifier \"{0}\" is already exists.", identifier);
                }
            }

            UserManagementClientNetworkService.UserInfo user = null;
            if (userIdentifier != 0)
            {
                user = GameNetworkClient.Instance.UserManagementService.GetUser(userIdentifier);
            }

            Client_Player player = new Client_Player(identifier, name, bot, user);

            client_players.Add(player);
        }
Exemplo n.º 6
0
        private bool ReceiveMessage_TextToClient(NetworkNode.ConnectedNode sender,
                                                 MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage)
        {
            //get data from message
            uint   fromUserIdentifier = reader.ReadVariableUInt32();
            string text = reader.ReadString();

            if (!reader.Complete())
            {
                return(false);
            }

            //get user by identifier
            UserManagementClientNetworkService.UserInfo fromUser = userManagementService.GetUser(
                fromUserIdentifier);
            if (fromUser == null)
            {
                //error. no such user.
                return(true);
            }

            if (ReceiveText != null)
            {
                ReceiveText(this, fromUser, text);
            }

            return(true);
        }
        private bool ReceiveMessage_WorldCreateBeginToClient(NetworkNode.ConnectedNode sender,
                                                             MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage)
        {
            string worldTypeName        = reader.ReadString();
            string mapVirtualFileName   = reader.ReadString();
            int    worldCheckIdentifier = reader.ReadInt32();

            if (!reader.Complete())
            {
                return(false);
            }

            //send world identifier back to server
            {
                MessageType    messageType2 = GetMessageType("worldIdentifierToServer");
                SendDataWriter writer       = BeginMessage(messageType2);
                writer.Write(worldCheckIdentifier);
                EndMessage();
            }

            bool remoteWorldAlreadyExists = EntitySystemWorld.Instance.RemoteEntityWorlds.Contains(
                serverRemoteEntityWorld);

            if (!remoteWorldAlreadyExists)
            {
                serverRemoteEntityWorld = new RemoteEntityWorld("Server remote entity world");
                networkingInterface.ConnectRemoteEntityWorld(serverRemoteEntityWorld);
            }

            WorldType worldType = EntityTypes.Instance.GetByName(worldTypeName) as WorldType;

            if (worldType == null)
            {
                Log.Fatal("EntitySystemClientNetworkService: " +
                          "ReceiveMessage_WorldCreateBeginToClient: World type \"{0}\" is not exists.",
                          worldTypeName);
            }

            if (WorldCreateBegin != null)
            {
                WorldCreateBegin(this, worldType, mapVirtualFileName);
            }

            return(true);
        }
        private bool ReceiveMessage_SpawnInfoToClient(NetworkNode.ConnectedNode sender,
                                                      MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage)
        {
            string message = reader.ReadString();
            string data    = reader.ReadString();

            if (!reader.Complete())
            {
                return(false);
            }

            if (ReceiveMessage != null)
            {
                ReceiveMessage(this, message, data);
            }

            return(true);
        }
        private bool ReceiveMessage_TransferMessageToServer(NetworkNode.ConnectedNode sender,
                                                            MessageType messageType, ReceiveDataReader reader, ref string error)
        {
            string message = reader.ReadString();
            string data    = reader.ReadString();

            if (!reader.Complete())
            {
                return(false);
            }

            if (ReceiveMessage != null)
            {
                ReceiveMessage(this, sender, message, data);
            }

            return(true);
        }
Exemplo n.º 10
0
        void Client_ReceiveFaction(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            string s = reader.ReadString();

            if (!reader.Complete())
            {
                return;
            }

            text = s;
        }
Exemplo n.º 11
0
        private void Client_ReceiveFaction(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            string s = reader.ReadString();

            if (!reader.Complete())
            {
                return;
            }

            faction = (FactionType)EntityTypes.Instance.GetByName(s);
        }
Exemplo n.º 12
0
        private void Server_ReceiveSpawnRequest(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            string unitTypeName = reader.ReadString();
            string variantText  = reader.ReadString();

            if (!reader.Complete())
            {
                return;
            }

            UnitType ut = (UnitType)EntityTypes.Instance.GetByName(unitTypeName);

            string[] broken = variantText.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

            int[] finalData = new int[broken.Length];

            for (int i = 0; i < broken.Length; i++)
            {
                finalData[i] = int.Parse(broken[i]);
            }

            SpawnNewUnit(ut, finalData);
        }
        bool ReceiveMessage_AddUserToClient(NetworkNode.ConnectedNode sender,
                                            MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage)
        {
            //get data from message
            uint   identifier   = reader.ReadVariableUInt32();
            string name         = reader.ReadString();
            bool   thisUserFlag = reader.ReadBoolean();

            if (!reader.Complete())
            {
                return(false);
            }

            AddUser(identifier, name, thisUserFlag);

            return(true);
        }
Exemplo n.º 14
0
        private void Client_ReceiveSupportedUnits(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            string supportedTypes = reader.ReadString();

            if (!reader.Complete())
            {
                return;
            }

            char[] supportedUnits = supportedTypes.ToCharArray();

            foreach (char c in supportedUnits)
            {
                int i = int.Parse(c.ToString());
                Hangar_Vehicle_Type hvt = (Hangar_Vehicle_Type)i;
                if (!VehicleType.Contains(hvt))
                {
                    VehicleType.Add(hvt);
                }
            }
        }
Exemplo n.º 15
0
        private bool ReceiveMessage_TextToServer(NetworkNode.ConnectedNode sender,
                                                 MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage)
        {
            //get source user
            UserManagementServerNetworkService.UserInfo fromUser = userManagementService.
                                                                   GetUser(sender);

            //get data of message
            string text = reader.ReadString();
            uint   privateToUserIdentifier = reader.ReadVariableUInt32();

            if (!reader.Complete())
            {
                return(false);
            }

            //send text to the clients
            if (privateToUserIdentifier != 0)
            {
                //send text to the specific user

                UserManagementServerNetworkService.UserInfo privateToUser = userManagementService.
                                                                            GetUser(privateToUserIdentifier);
                if (privateToUser != null)
                {
                    SendText(fromUser, text, privateToUser);
                }
                else
                {
                    //no user anymore
                }
            }
            else
            {
                SendText(fromUser, text, null);
            }

            return(true);
        }
Exemplo n.º 16
0
        bool ReceiveMessage_TextToClient( NetworkNode.ConnectedNode sender,
			MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage )
        {
            //get data from message
            uint fromUserIdentifier = reader.ReadVariableUInt32();
            string text = reader.ReadString();
            if( !reader.Complete() )
                return false;

            //get user by identifier
            UserManagementClientNetworkService.UserInfo fromUser = userManagementService.GetUser(
                fromUserIdentifier );
            if( fromUser == null )
            {
                //error. no such user.
                return true;
            }

            if( ReceiveText != null )
                ReceiveText( this, fromUser, text );

            return true;
        }
        private bool ReceiveMessage_TextToServer(NetworkNode.ConnectedNode sender,
            MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage)
        {
            //get source user
            UserManagementServerNetworkService.UserInfo fromUser = userManagementService.
                GetUser(sender);

            //get data of message
            string text = reader.ReadString();
            uint privateToUserIdentifier = reader.ReadVariableUInt32();
            if (!reader.Complete())
                return false;

            //send text to the clients
            if (privateToUserIdentifier != 0)
            {
                //send text to the specific user

                UserManagementServerNetworkService.UserInfo privateToUser = userManagementService.
                    GetUser(privateToUserIdentifier);
                if (privateToUser != null)
                {
                    SendText(fromUser, text, privateToUser);
                }
                else
                {
                    //no user anymore
                }
            }
            else
            {
                SendText(fromUser, text, null);
            }

            return true;
        }
Exemplo n.º 18
0
        void Client_ReceiveFaction(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            string s = reader.ReadString();
            if (!reader.Complete())
                return;

            text = s;
        }
Exemplo n.º 19
0
        private void Client_ReceiveFaction(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            string s = reader.ReadString();
            if (!reader.Complete())
                return;

            faction = (FactionType)EntityTypes.Instance.GetByName(s);
        }
Exemplo n.º 20
0
        private void Client_ReceiveHitCall(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            Vec3 hitPosition = reader.ReadVec3();
            string hitShapeBodyName = reader.ReadString();
            string hitShapeName = reader.ReadString();
            Vec3 hitNormal = reader.ReadVec3();
            MapObject hitMapObject = Entities.Instance.GetByNetworkUIN(reader.ReadVariableUInt32()) as MapObject;
            if (!reader.Complete())
                return;

            Position = hitPosition;
            Shape hitShape = null;
            if (PhysicsModel != null)
            {
                Body body = PhysicsModel.GetBody(hitShapeBodyName);
                if (body != null)
                    hitShape = body.GetShape(hitShapeName);
            }
            OnHit(hitShape, hitNormal, hitMapObject);
        }
Exemplo n.º 21
0
        private void Client_ReceiveIntellect(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            uint networkUIN = reader.ReadVariableUInt32();
            bool shouldDeleteAfterDetach = reader.ReadBoolean();
            FactionType ft = null;

            if (GameMap.Instance.GameType == GameMap.GameTypes.AssaultKnights)
            {
                string factionName = reader.ReadString();
                if (factionName != string.Empty)
                    ft = (FactionType)EntityTypes.Instance.GetByName(factionName);
            }
            if (!reader.Complete())
                return;

            Intellect i = null;
            if (networkUIN != 0)
            {
                i = (Intellect)Entities.Instance.GetByNetworkUIN(networkUIN);
                if (ft != null)
                    i.Faction = ft;
            }
            SetIntellect(i, shouldDeleteAfterDetach);
        }
        bool ReceiveMessage_WorldCreateBeginToClient( NetworkNode.ConnectedNode sender,
			MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage )
        {
            string worldTypeName = reader.ReadString();
            string mapVirtualFileName = reader.ReadString();
            if( !reader.Complete() )
                return false;

            bool remoteWorldAlreadyExists = EntitySystemWorld.Instance.RemoteEntityWorlds.Contains(
                serverRemoteEntityWorld );

            if( !remoteWorldAlreadyExists )
            {
                serverRemoteEntityWorld = new RemoteEntityWorld( "Server remote entity world" );
                networkingInterface.ConnectRemoteEntityWorld( serverRemoteEntityWorld );
            }

            WorldType worldType = EntityTypes.Instance.GetByName( worldTypeName ) as WorldType;
            if( worldType == null )
            {
                Log.Fatal( "EntitySystemClientNetworkService: " +
                    "ReceiveMessage_WorldCreateBeginToClient: World type \"{0}\" is not exists.",
                    worldTypeName );
            }

            if( WorldCreateBegin != null )
                WorldCreateBegin( this, worldType, mapVirtualFileName );

            return true;
        }
Exemplo n.º 23
0
        void Client_ReceiveAddUser( RemoteEntityWorld sender, ReceiveDataReader reader )
        {
            uint identifier = reader.ReadVariableUInt32();
            string name = reader.ReadString();
            bool bot = reader.ReadBoolean();
            uint userIdentifier = reader.ReadVariableUInt32();

            if( !reader.Complete() )
                return;

            //check for already exists
            {
                Client_Player playerForCheck = Client_GetPlayer( identifier );

                if( playerForCheck != null )
                {
                    Log.Fatal( "PlayerManager: Client_ReceiveAddUserToClient: Player " +
                        "with identifier \"{0}\" is already exists.", identifier );
                }
            }

            UserManagementClientNetworkService.UserInfo user = null;
            if( userIdentifier != 0 )
                user = GameNetworkClient.Instance.UserManagementService.GetUser( userIdentifier );

            Client_Player player = new Client_Player( identifier, name, bot, user );
            client_players.Add( player );
        }
        private bool ReceiveMessage_WorldCreateBeginToClient(NetworkNode.ConnectedNode sender,
            MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage)
        {
            string worldTypeName = reader.ReadString();
            string mapVirtualFileName = reader.ReadString();
            int worldCheckIdentifier = reader.ReadInt32();
            if (!reader.Complete())
                return false;

            //send world identifier back to server
            {
                MessageType messageType2 = GetMessageType("worldIdentifierToServer");
                SendDataWriter writer = BeginMessage(messageType2);
                writer.Write(worldCheckIdentifier);
                EndMessage();
            }

            bool remoteWorldAlreadyExists = EntitySystemWorld.Instance.RemoteEntityWorlds.Contains(
                serverRemoteEntityWorld);

            if (!remoteWorldAlreadyExists)
            {
                serverRemoteEntityWorld = new RemoteEntityWorld("Server remote entity world");
                networkingInterface.ConnectRemoteEntityWorld(serverRemoteEntityWorld);
            }

            WorldType worldType = EntityTypes.Instance.GetByName(worldTypeName) as WorldType;
            if (worldType == null)
            {
                Log.Fatal("EntitySystemClientNetworkService: " +
                    "ReceiveMessage_WorldCreateBeginToClient: World type \"{0}\" is not exists.",
                    worldTypeName);
            }

            if (WorldCreateBegin != null)
                WorldCreateBegin(this, worldType, mapVirtualFileName);

            return true;
        }
Exemplo n.º 25
0
        void Client_ReceiveSupportedUnits(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            string supportedTypes = reader.ReadString();
            if (!reader.Complete())
                return;

            char[] supportedUnits = supportedTypes.ToCharArray();

            foreach (char c in supportedUnits)
            {
                int i = int.Parse(c.ToString());
                Hangar_Vehicle_Type hvt = (Hangar_Vehicle_Type)i;
                if (!VehicleType.Contains(hvt))
                    VehicleType.Add(hvt);
            }
        }
Exemplo n.º 26
0
        void Server_ReceiveSpawnRequest(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            string unitTypeName = reader.ReadString();
            string variantText = reader.ReadString();

            if (!reader.Complete())
                return;

            UnitType ut = (UnitType)EntityTypes.Instance.GetByName(unitTypeName);

            string[] broken = variantText.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

            int[] finalData = new int[broken.Length];

            for (int i = 0; i < broken.Length; i++)
                finalData[i] = int.Parse(broken[i]);

            SpawnNewUnit(ut, finalData);
        }
        private bool ReceiveMessage_AddUserToClient(NetworkNode.ConnectedNode sender,
            MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage)
        {
            //get data from message
            uint identifier = reader.ReadVariableUInt32();
            string name = reader.ReadString();
            bool thisUserFlag = reader.ReadBoolean();
            if (!reader.Complete())
                return false;

            AddUser(identifier, name, thisUserFlag);

            return true;
        }
Exemplo n.º 28
0
 void Client_ReceivePropertiesToClient( RemoteEntityWorld sender, ReceiveDataReader reader )
 {
     Size = reader.ReadVec2();
     Position = reader.ReadVec3();
     Segments = reader.ReadVec2i();
     RenderQueueGroup = (RenderQueueGroupID)reader.ReadVariableUInt32();
     ReflectionLevel = (ReflectionLevels)reader.ReadVariableUInt32();
     PhysicsHeight = reader.ReadSingle();
     DeepColor = reader.ReadColorValue();
     ShallowColor = reader.ReadColorValue();
     ReflectionColor = reader.ReadColorValue();
     ReflectionTextureSize = (ReflectionTextureSizes)reader.ReadVariableUInt32();
     FixedPipelineMap = reader.ReadString();
     FixedPipelineMapTiling = reader.ReadSingle();
     FixedPipelineColor = reader.ReadColorValue();
 }