Esempio n. 1
0
        public BaseEntity(MyObjectBuilder_EntityBase baseEntity, Object backingObject)
            : base(baseEntity, backingObject)
        {
            if (baseEntity != null)
            {
                m_entityId = baseEntity.EntityId;
                if (baseEntity.PositionAndOrientation != null)
                {
                    m_positionOrientation = baseEntity.PositionAndOrientation.GetValueOrDefault();
                }
                else
                {
                    m_positionOrientation = new MyPositionAndOrientation();
                    m_positionOrientation.Position = UtilityFunctions.GenerateRandomBorderPosition(new Vector3(-500000, -500000, -500000), new Vector3(500000, 500000, 500000));
                    m_positionOrientation.Forward = new Vector3(0, 0, 1);
                    m_positionOrientation.Up = new Vector3(0, 1, 0);
                }
            }
            else
            {
                m_entityId = 0;
                m_positionOrientation = new MyPositionAndOrientation();
                m_positionOrientation.Position = UtilityFunctions.GenerateRandomBorderPosition(new Vector3(-500000, -500000, -500000), new Vector3(500000, 500000, 500000));
                m_positionOrientation.Forward = new Vector3(0, 0, 1);
                m_positionOrientation.Up = new Vector3(0, 1, 0);
            }

            m_networkManager = new BaseEntityNetworkManager(this, GetEntityNetworkManager(BackingObject));

            m_linearVelocity = new Vector3(0, 0, 0);
            m_angularVelocity = new Vector3(0, 0, 0);
            m_maxLinearVelocity = (float)104.7;

            Action action = InternalRegisterEntityMovedEvent;
            SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(action);
        }
Esempio n. 2
0
		public BaseEntity( MyObjectBuilder_EntityBase baseEntity, Object backingObject )
			: base( baseEntity, backingObject )
		{
			if ( baseEntity != null )
			{
				m_entityId = baseEntity.EntityId;
				if ( baseEntity.PositionAndOrientation != null )
				{
					m_positionOrientation = baseEntity.PositionAndOrientation.GetValueOrDefault( );
				}
				else
				{
					m_positionOrientation = new MyPositionAndOrientation( );
					m_positionOrientation.Position = UtilityFunctions.GenerateRandomBorderPosition( new Vector3( -500000, -500000, -500000 ), new Vector3( 500000, 500000, 500000 ) );
					m_positionOrientation.Forward = new Vector3( 0, 0, 1 );
					m_positionOrientation.Up = new Vector3( 0, 1, 0 );
				}
			}
			else
			{
				m_entityId = 0;
				m_positionOrientation = new MyPositionAndOrientation( );
				m_positionOrientation.Position = UtilityFunctions.GenerateRandomBorderPosition( new Vector3( -500000, -500000, -500000 ), new Vector3( 500000, 500000, 500000 ) );
				m_positionOrientation.Forward = new Vector3( 0, 0, 1 );
				m_positionOrientation.Up = new Vector3( 0, 1, 0 );
			}

			m_networkManager = new BaseEntityNetworkManager( this, GetEntityNetworkManager( BackingObject ) );

			m_linearVelocity = new Vector3( 0, 0, 0 );
			m_angularVelocity = new Vector3( 0, 0, 0 );
			m_maxLinearVelocity = (float)104.7;

			if ( EntityId != 0 )
			{
				GameEntityManager.AddEntity( EntityId, this );
			}

			MySandboxGame.Static.Invoke( InternalRegisterEntityMovedEvent );
		}