예제 #1
0
        protected void InternalAddEntity()
        {
            try
            {
                if (m_nextEntityToUpdate == null)
                {
                    return;
                }

                if (SandboxGameAssemblyWrapper.IsDebugging)
                {
                    Console.WriteLine(m_nextEntityToUpdate.GetType().Name + " '" + m_nextEntityToUpdate.GetType().Name + "': Adding to scene ...");
                }

                //Create the backing object
                Type entityType   = m_nextEntityToUpdate.GetType();
                Type internalType = (Type)BaseEntity.InvokeStaticMethod(entityType, "get_InternalType");
                if (internalType == null)
                {
                    throw new Exception("Could not get internal type of entity");
                }
                m_nextEntityToUpdate.BackingObject = Activator.CreateInstance(internalType);

                //Initialize the backing object
                BaseEntity.InvokeEntityMethod(m_nextEntityToUpdate.BackingObject, "Init", new object[] { m_nextEntityToUpdate.ObjectBuilder });

                //Add the backing object to the main game object manager
                BaseEntity.InvokeStaticMethod(InternalType, ObjectManagerAddEntity, new object[] { m_nextEntityToUpdate.BackingObject, true });

                if (m_nextEntityToUpdate is FloatingObject)
                {
                    InternalBroadcastAddFloatingObject();
                }
                else
                {
                    InternalBroadcastAddEntity();
                }

                if (SandboxGameAssemblyWrapper.IsDebugging)
                {
                    Type type = m_nextEntityToUpdate.GetType();
                    Console.WriteLine(type.Name + " '" + m_nextEntityToUpdate.Name + "': Finished adding to scene");
                }

                m_nextEntityToUpdate = null;
            }
            catch (Exception ex)
            {
                LogManager.APILog.WriteLineAndConsole("Failed to add new entity");
                LogManager.ErrorLog.WriteLine(ex);
            }
        }
예제 #2
0
        public void AddEntity(BaseEntity entity)
        {
            try
            {
                if (SandboxGameAssemblyWrapper.IsDebugging)
                {
                    Console.WriteLine(entity.GetType().Name + " '" + entity.Name + "' is being added ...");
                }

                m_nextEntityToUpdate = entity;

                Action action = InternalAddEntity;
                SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(action);
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog.WriteLine(ex);
            }
        }
예제 #3
0
        public void AddEntity(BaseEntity entity)
        {
            try
            {
                if (m_addEntityQueue.Count >= 25)
                {
                    throw new Exception("AddEntity queue is full. Cannot add more entities yet");
                }

                if (ExtenderOptions.IsDebugging)
                {
                    ApplicationLog.BaseLog.Debug(entity.GetType( ).Name + " '" + entity.Name + "' is being added ...");
                }

                m_addEntityQueue.Enqueue(entity);

                MySandboxGame.Static.Invoke(InternalAddEntity);
            }
            catch (Exception ex)
            {
                ApplicationLog.BaseLog.Error(ex);
            }
        }
예제 #4
0
        public void AddEntity(BaseEntity entity)
        {
            try
            {
                if (m_addEntityQueue.Count >= 5)
                {
                    throw new Exception("AddEntity queue is full. Cannot add more entities yet");
                }

                if (SandboxGameAssemblyWrapper.IsDebugging)
                {
                    Console.WriteLine(entity.GetType().Name + " '" + entity.Name + "' is being added ...");
                }

                m_addEntityQueue.Enqueue(entity);

                Action action = InternalAddEntity;
                SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(action);
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog.WriteLine(ex);
            }
        }
예제 #5
0
        public void AddEntity(BaseEntity entity)
        {
            try
            {
                if (SandboxGameAssemblyWrapper.IsDebugging)
                    Console.WriteLine(entity.GetType().Name + " '" + entity.Name + "' is being added ...");

                m_nextEntityToUpdate = entity;

                Action action = InternalAddEntity;
                SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(action);
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog.WriteLine(ex);
            }
        }
예제 #6
0
        protected void InternalAddEntity()
        {
            try
            {
                if (m_addEntityQueue.Count == 0)
                {
                    return;
                }

                BaseEntity entityToAdd = m_addEntityQueue.Dequeue();

                if (SandboxGameAssemblyWrapper.IsDebugging)
                {
                    Console.WriteLine(entityToAdd.GetType().Name + " '" + entityToAdd.GetType().Name + "': Adding to scene ...");
                }

                //Create the backing object
                Type entityType   = entityToAdd.GetType();
                Type internalType = (Type)BaseEntity.InvokeStaticMethod(entityType, "get_InternalType");
                if (internalType == null)
                {
                    throw new Exception("Could not get internal type of entity");
                }
                entityToAdd.BackingObject = Activator.CreateInstance(internalType);

                //Initialize the backing object
                BaseEntity.InvokeEntityMethod(entityToAdd.BackingObject, "Init", new object[] { entityToAdd.ObjectBuilder });

                //Add the backing object to the main game object manager
                BaseEntity.InvokeStaticMethod(InternalType, ObjectManagerAddEntity, new object[] { entityToAdd.BackingObject, true });

                if (entityToAdd is FloatingObject)
                {
                    try
                    {
                        //Broadcast the new entity to the clients
                        MyObjectBuilder_EntityBase baseEntity = (MyObjectBuilder_EntityBase)BaseEntity.InvokeEntityMethod(entityToAdd.BackingObject, BaseEntity.BaseEntityGetObjectBuilderMethod, new object[] { Type.Missing });
                        //TODO - Do stuff

                        entityToAdd.ObjectBuilder = baseEntity;
                    }
                    catch (Exception ex)
                    {
                        LogManager.APILog.WriteLineAndConsole("Failed to broadcast new floating object");
                        LogManager.ErrorLog.WriteLine(ex);
                    }
                }
                else
                {
                    try
                    {
                        //Broadcast the new entity to the clients
                        MyObjectBuilder_EntityBase baseEntity = (MyObjectBuilder_EntityBase)BaseEntity.InvokeEntityMethod(entityToAdd.BackingObject, BaseEntity.BaseEntityGetObjectBuilderMethod, new object[] { Type.Missing });
                        Type someManager = SandboxGameAssemblyWrapper.Instance.GetAssemblyType(EntityBaseNetManagerNamespace, EntityBaseNetManagerClass);
                        BaseEntity.InvokeStaticMethod(someManager, EntityBaseNetManagerSendEntity, new object[] { baseEntity });

                        entityToAdd.ObjectBuilder = baseEntity;
                    }
                    catch (Exception ex)
                    {
                        LogManager.APILog.WriteLineAndConsole("Failed to broadcast new entity");
                        LogManager.ErrorLog.WriteLine(ex);
                    }
                }

                if (SandboxGameAssemblyWrapper.IsDebugging)
                {
                    Type type = entityToAdd.GetType();
                    Console.WriteLine(type.Name + " '" + entityToAdd.Name + "': Finished adding to scene");
                }
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog.WriteLine(ex);
            }
        }
예제 #7
0
        protected void InternalAddEntity( )
        {
            try
            {
                if (AddEntityQueue.Count == 0)
                {
                    return;
                }

                BaseEntity entityToAdd = AddEntityQueue.Dequeue( );

                if (ExtenderOptions.IsDebugging)
                {
                    ApplicationLog.BaseLog.Debug(String.Format("{0} '{1}': Adding to scene...", entityToAdd.GetType().Name, entityToAdd.DisplayName));
                }

                //Create the backing object
                Type entityType   = entityToAdd.GetType( );
                Type internalType = (Type)BaseEntity.InvokeStaticMethod(entityType, "get_InternalType");
                if (internalType == null)
                {
                    throw new Exception("Could not get internal type of entity");
                }
                entityToAdd.BackingObject = Activator.CreateInstance(internalType);

                //Add the backing object to the main game object manager
                //I don't think this is actually used anywhere?
                MyEntity backingObject = (MyEntity)entityToAdd.BackingObject;

                MyEntity newEntity = MyEntities.CreateFromObjectBuilderAndAdd(entityToAdd.ObjectBuilder);


                if (entityToAdd is FloatingObject)
                {
                    try
                    {
                        //Broadcast the new entity to the clients
                        MyObjectBuilder_EntityBase baseEntity = backingObject.GetObjectBuilder( );
                        //TODO - Do stuff

                        entityToAdd.ObjectBuilder = baseEntity;
                    }
                    catch (Exception ex)
                    {
                        ApplicationLog.BaseLog.Error("Failed to broadcast new floating object");
                        ApplicationLog.BaseLog.Error(ex);
                    }
                }
                else
                {
                    try
                    {
                        //Broadcast the new entity to the clients
                        ApplicationLog.BaseLog.Info("Broadcasted entity to clients.");
                        MyMultiplayer.ReplicateImmediatelly(MyExternalReplicable.FindByObject(newEntity));
                        //the misspelling in this function name is driving me  i n s a n e
                    }
                    catch (Exception ex)
                    {
                        ApplicationLog.BaseLog.Error("Failed to broadcast new entity");
                        ApplicationLog.BaseLog.Error(ex);
                    }
                }

                if (ExtenderOptions.IsDebugging)
                {
                    Type type = entityToAdd.GetType( );
                    ApplicationLog.BaseLog.Debug(String.Format("{0} '{1}': Finished adding to scene", entityToAdd.GetType().Name, entityToAdd.DisplayName));
                }
            }
            catch (Exception ex)
            {
                ApplicationLog.BaseLog.Error(ex);
            }
        }
예제 #8
0
        public void AddEntity(BaseEntity entity)
        {
            try
            {
                if (AddEntityQueue.Count >= 25)
                {
                    throw new Exception("AddEntity queue is full. Cannot add more entities yet");
                }

                if (ExtenderOptions.IsDebugging)
                {
                    ApplicationLog.BaseLog.Debug(String.Format("{0} '{1}': Is being added...", entity.GetType().Name, entity.DisplayName));
                }

                AddEntityQueue.Enqueue(entity);

                MySandboxGame.Static.Invoke(InternalAddEntity);
            }
            catch (Exception ex)
            {
                ApplicationLog.BaseLog.Error(ex);
            }
        }
예제 #9
0
        protected void InternalAddEntity( )
        {
            try
            {
                if (AddEntityQueue.Count == 0)
                {
                    return;
                }

                BaseEntity entityToAdd = AddEntityQueue.Dequeue( );

                if (ExtenderOptions.IsDebugging)
                {
                    ApplicationLog.BaseLog.Debug(entityToAdd.GetType( ).Name + " '" + entityToAdd.GetType( ).Name + "': Adding to scene ...");
                }

                //Create the backing object
                Type entityType   = entityToAdd.GetType( );
                Type internalType = (Type)BaseEntity.InvokeStaticMethod(entityType, "get_InternalType");
                if (internalType == null)
                {
                    throw new Exception("Could not get internal type of entity");
                }
                entityToAdd.BackingObject = Activator.CreateInstance(internalType);

                //Add the backing object to the main game object manager
                MyEntity backingObject = (MyEntity)entityToAdd.BackingObject;
                backingObject.Init(entityToAdd.ObjectBuilder);
                MyEntities.Add(backingObject);

                if (entityToAdd is FloatingObject)
                {
                    try
                    {
                        //Broadcast the new entity to the clients
                        MyObjectBuilder_EntityBase baseEntity = backingObject.GetObjectBuilder( );
                        //TODO - Do stuff

                        entityToAdd.ObjectBuilder = baseEntity;
                    }
                    catch (Exception ex)
                    {
                        ApplicationLog.BaseLog.Error("Failed to broadcast new floating object");
                        ApplicationLog.BaseLog.Error(ex);
                    }
                }
                else
                {
                    try
                    {
                        //Broadcast the new entity to the clients
                        MyObjectBuilder_EntityBase baseEntity = backingObject.GetObjectBuilder( );
                        MySyncCreate.SendEntityCreated(baseEntity);

                        entityToAdd.ObjectBuilder = baseEntity;
                    }
                    catch (Exception ex)
                    {
                        ApplicationLog.BaseLog.Error("Failed to broadcast new entity");
                        ApplicationLog.BaseLog.Error(ex);
                    }
                }

                if (ExtenderOptions.IsDebugging)
                {
                    Type type = entityToAdd.GetType( );
                    ApplicationLog.BaseLog.Debug(type.Name + " '" + entityToAdd.Name + "': Finished adding to scene");
                }
            }
            catch (Exception ex)
            {
                ApplicationLog.BaseLog.Error(ex);
            }
        }
예제 #10
0
		public void AddEntity( BaseEntity entity )
		{
			try
			{
				if ( AddEntityQueue.Count >= 25 )
				{
					throw new Exception( "AddEntity queue is full. Cannot add more entities yet" );
				}

				if ( ExtenderOptions.IsDebugging )
					ApplicationLog.BaseLog.Debug(String.Format("{0} '{1}': Is being added...", entity.GetType().Name, entity.DisplayName));

				AddEntityQueue.Enqueue( entity );

				MySandboxGame.Static.Invoke( InternalAddEntity );
			}
			catch ( Exception ex )
			{
				ApplicationLog.BaseLog.Error( ex );
			}
		}
예제 #11
0
        public void AddEntity( BaseEntity entity )
        {
            try
            {
                if ( m_addEntityQueue.Count >= 25 )
                {
                    throw new Exception( "AddEntity queue is full. Cannot add more entities yet" );
                }

                if ( ExtenderOptions.IsDebugging )
                    ApplicationLog.BaseLog.Debug( entity.GetType( ).Name + " '" + entity.Name + "' is being added ..." );

                m_addEntityQueue.Enqueue( entity );

                MySandboxGame.Static.Invoke( InternalAddEntity );
            }
            catch ( Exception ex )
            {
                ApplicationLog.BaseLog.Error( ex );
            }
        }
		public void AddEntity(BaseEntity entity)
		{
			try
			{
				if (m_addEntityQueue.Count >= 5)
				{
					throw new Exception("AddEntity queue is full. Cannot add more entities yet");
				}

				if (SandboxGameAssemblyWrapper.IsDebugging)
					Console.WriteLine(entity.GetType().Name + " '" + entity.Name + "' is being added ...");

				m_addEntityQueue.Enqueue(entity);

				Action action = InternalAddEntity;
				SandboxGameAssemblyWrapper.Instance.EnqueueMainGameAction(action);
			}
			catch (Exception ex)
			{
				LogManager.ErrorLog.WriteLine(ex);
			}
		}