Exemplo n.º 1
0
        public MyEnvironmentItems()
        {
            m_instanceFlags = MyInstanceFlagsEnum.ShowLod1 | MyInstanceFlagsEnum.CastShadows | MyInstanceFlagsEnum.EnableColorMask;
            m_definition = null;

            this.Render = new MyRenderComponentEnvironmentItems(this);
            AddDebugRenderComponent(new MyEnviromentItemsDebugDraw(this));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Spawn Environment Items instance (e.g. forest) object which can be then used for spawning individual items (e.g. trees).
        /// </summary>
        public static MyEnvironmentItemsSpawnData BeginSpawn(MyEnvironmentItemsDefinition itemsDefinition)
        {
            var builder = MyObjectBuilderSerializer.CreateNewObject(itemsDefinition.Id.TypeId, itemsDefinition.Id.SubtypeName) as MyObjectBuilder_EnvironmentItems;
            builder.PersistentFlags |= MyPersistentEntityFlags2.Enabled | MyPersistentEntityFlags2.InScene | MyPersistentEntityFlags2.CastShadows;
            var envItems = MyEntities.CreateFromObjectBuilderAndAdd(builder) as MyEnvironmentItems;

            MyEnvironmentItemsSpawnData spawnData = new MyEnvironmentItemsSpawnData();
            spawnData.EnvironmentItems = envItems;
            return spawnData;
        }
        /// <summary>
        /// Spawn Environment Items instance (e.g. forest) object which can be then used for spawning individual items (e.g. trees).
        /// </summary>
        public static MyEnvironmentItemsSpawnData BeginSpawn(MyEnvironmentItemsDefinition itemsDefinition, bool addToScene = true, long withEntityId = 0)
        {
            var builder = MyObjectBuilderSerializer.CreateNewObject(itemsDefinition.Id.TypeId, itemsDefinition.Id.SubtypeName) as MyObjectBuilder_EnvironmentItems;
            builder.EntityId = withEntityId;
            builder.PersistentFlags |= MyPersistentEntityFlags2.Enabled | (addToScene ? MyPersistentEntityFlags2.InScene : 0)| MyPersistentEntityFlags2.CastShadows;

            MyEnvironmentItems envItems;
            
            if(addToScene)
                envItems = MyEntities.CreateFromObjectBuilderAndAdd(builder) as MyEnvironmentItems;
            else
                envItems = MyEntities.CreateFromObjectBuilder(builder) as MyEnvironmentItems;


            MyEnvironmentItemsSpawnData spawnData = new MyEnvironmentItemsSpawnData();
            spawnData.EnvironmentItems = envItems;
            return spawnData;
        }