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 void Client_ReceivePosition(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            Vec3 value = reader.ReadVec3();

            if (!reader.Complete())
            {
                return;
            }
            Position = value;
        }
Exemplo n.º 3
0
        void Client_ReceiveTurnToPosition(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            Vec3 turnToPosition = reader.ReadVec3();

            if (!reader.Complete())
            {
                return;
            }
            SetMomentaryTurnToPosition(turnToPosition);
        }
Exemplo n.º 4
0
        private void Client_ReceiveGroundRelativeVelocity(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            Vec3 value = reader.ReadVec3();

            if (!reader.Complete())
            {
                return;
            }
            groundRelativeVelocity = value;
        }
Exemplo n.º 5
0
        void Client_ReceiveWeaponVerticalAngle(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            Vec3 value = reader.ReadVec3();

            if (!reader.Complete())
            {
                return;
            }
            groundRelativeVelocity = value;
        }
        void Server_ReceiveTurnToPosition(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            //check to ensure that other players can not send messages to another player
            if (!Server_CheckRemoteEntityWorldAssociatedWithThisIntellect(sender))
            {
                return;
            }

            Vec3 value = reader.ReadVec3();

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

            UpdateTurnToPositionForUnits(value);
        }
Exemplo n.º 7
0
        void Client_ReceivePositions( RemoteEntityWorld sender, ReceiveDataReader reader )
        {
            //clear snanshots cache if entity is not created
            if( !IsPostCreated )
                client_receivePositionsSnapshots.Clear();

            //check for invalid snapshot cache
            if( client_receivePositionsSnapshots.Count != 0 )
            {
                Client_ReceivePositionsSnapshot lastSnapshot = client_receivePositionsSnapshots[
                    client_receivePositionsSnapshots.Count - 1 ];
                if( lastSnapshot.bodies != null )
                {
                    //remove snapshot cache
                    client_receivePositionsSnapshots.Clear();
                }
            }

            Client_ReceivePositionsSnapshot snapshot = new Client_ReceivePositionsSnapshot();
            snapshot.networkTickNumber = EntitySystemWorld.Instance.NetworkTickCounter;

            //read position
            if( reader.ReadBoolean() )
            {
                snapshot.position = reader.ReadVec3();
            }
            else
            {
                //get position from previous snapshot
                if( client_receivePositionsSnapshots.Count != 0 )
                {
                    snapshot.position = client_receivePositionsSnapshots[
                        client_receivePositionsSnapshots.Count - 1 ].position;
                }
            }

            //read rotation
            if( reader.ReadBoolean() )
            {
                snapshot.rotation = reader.ReadQuat( 16 );
            }
            else
            {
                //get rotation from previous snapshot
                if( client_receivePositionsSnapshots.Count != 0 )
                {
                    snapshot.rotation = client_receivePositionsSnapshots[
                        client_receivePositionsSnapshots.Count - 1 ].rotation;
                }
            }

            //read scale
            if( reader.ReadBoolean() )
            {
                snapshot.scale = reader.ReadVec3();
            }
            else
            {
                //get position from previous snapshot
                if( client_receivePositionsSnapshots.Count != 0 )
                {
                    snapshot.scale = client_receivePositionsSnapshots[
                        client_receivePositionsSnapshots.Count - 1 ].scale;
                }
            }

            if( !reader.Complete() )
                return;

            client_receivePositionsSnapshots.Add( snapshot );

            Client_UpdatePositionsBySnapshots( false );
        }
Exemplo n.º 8
0
        void Client_ReceiveBodiesPositions( RemoteEntityWorld sender, ReceiveDataReader reader )
        {
            //clear snapshots cache if entity is not created
            if( !IsPostCreated )
                client_receivePositionsSnapshots.Clear();

            //check for invalid snapshot cache
            if( client_receivePositionsSnapshots.Count != 0 )
            {
                Client_ReceivePositionsSnapshot lastSnapshot = client_receivePositionsSnapshots[
                    client_receivePositionsSnapshots.Count - 1 ];
                if( lastSnapshot.bodies == null )
                {
                    //remove snapshot cache
                    client_receivePositionsSnapshots.Clear();
                }
            }

            int count = (int)reader.ReadVariableUInt32();

            Client_ReceivePositionsSnapshot snapshot = new Client_ReceivePositionsSnapshot();
            snapshot.networkTickNumber = EntitySystemWorld.Instance.NetworkTickCounter;

            snapshot.bodies = new Client_ReceivePositionsSnapshot.BodyItem[ count ];

            //receive bodies positions and rotations
            for( int n = 0; n < count; n++ )
            {
                Client_ReceivePositionsSnapshot.BodyItem bodyItem = new
                    Client_ReceivePositionsSnapshot.BodyItem();

                //read position
                if( reader.ReadBoolean() )
                {
                    bodyItem.position = reader.ReadVec3();
                }
                else
                {
                    //get position from previous snapshot
                    if( client_receivePositionsSnapshots.Count != 0 )
                    {
                        bodyItem.position = client_receivePositionsSnapshots[
                            client_receivePositionsSnapshots.Count - 1 ].bodies[ n ].position;
                    }
                }

                //read rotation
                if( reader.ReadBoolean() )
                {
                    bodyItem.rotation = reader.ReadQuat( 16 );
                }
                else
                {
                    //get rotation from previous snapshot
                    if( client_receivePositionsSnapshots.Count != 0 )
                    {
                        bodyItem.rotation = client_receivePositionsSnapshots[
                            client_receivePositionsSnapshots.Count - 1 ].bodies[ n ].rotation;
                    }
                }

                snapshot.bodies[ n ] = bodyItem;
            }

            if( !reader.Complete() )
                return;

            client_receivePositionsSnapshots.Add( snapshot );

            if( IsPostCreated )
                Client_UpdatePositionsBySnapshots( false );
        }
Exemplo n.º 9
0
 void Client_ReceivePosition( RemoteEntityWorld sender, ReceiveDataReader reader )
 {
     Vec3 value = reader.ReadVec3();
     if( !reader.Complete() )
         return;
     Position = value;
 }
Exemplo n.º 10
0
		void Client_ReceiveGroundRelativeVelocity( RemoteEntityWorld sender, ReceiveDataReader reader )
		{
			Vec3 value = reader.ReadVec3();
			if( !reader.Complete() )
				return;
			groundRelativeVelocity = value;
		}
Exemplo n.º 11
0
 private void Client_ReceiveWeaponVerticalAngle(RemoteEntityWorld sender, ReceiveDataReader reader)
 {
     Vec3 value = reader.ReadVec3();
     if (!reader.Complete())
         return;
     groundRelativeVelocity = value;
 }
Exemplo n.º 12
0
 void Client_ReceiveTurnToPosition( RemoteEntityWorld sender, ReceiveDataReader reader )
 {
     Vec3 turnToPosition = reader.ReadVec3();
     if( !reader.Complete() )
         return;
     SetMomentaryTurnToPosition( turnToPosition );
 }
Exemplo n.º 13
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();
 }
Exemplo n.º 14
0
 void Client_ReceiveCreateSplash( RemoteEntityWorld sender, ReceiveDataReader reader )
 {
     WaterPlaneType.SplashTypes splashType = (WaterPlaneType.SplashTypes)reader.
         ReadVariableUInt32();
     Vec3 pos = reader.ReadVec3();
     if( !reader.Complete() )
         return;
     CreateSplash( splashType, pos );
 }
Exemplo n.º 15
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.º 16
0
        void Server_ReceiveTurnToPosition( RemoteEntityWorld sender, ReceiveDataReader reader )
        {
            //check to ensure that other players can not send messages to another player
            if( !Server_CheckRemoteEntityWorldAssociatedWithThisIntellect( sender ) )
                return;

            Vec3 value = reader.ReadVec3();
            if( !reader.Complete() )
                return;

            UpdateTurnToPositionForUnits( value );
        }