Example #1
0
        protected override void OnUpdate()
        {
            if (m_firstFrame)
            {
                var archetype = EntityManager.CreateArchetype(typeof(Translation), typeof(Rotation), typeof(Collider), typeof(LocalToWorld));
                EntityManager.CreateEntity(archetype, 50, Allocator.Temp);
                var random = new Random(1123);
                Entities.WithStoreEntityQueryInField(ref m_query).WithAll <LocalToWorld>().ForEach((ref Translation c0, ref Rotation c1, ref Collider c2) =>
                {
                    c0.Value = random.NextFloat3(new float3(-18f), new float3(18f));
                    c1.Value = random.NextQuaternionRotation();
                    c2       = new CapsuleCollider(float3.zero, new float3(2f), 0.6f);
                }).Run();
                m_firstFrame = false;
            }

            CollisionLayerSettings settings = new CollisionLayerSettings
            {
                worldSubdivisionsPerAxis = new int3(1, 4, 4),
                worldAABB = new Aabb(-1000f, 1000f),
            };

            Dependency = Physics.BuildCollisionLayer(m_query, this).WithSettings(settings).ScheduleParallel(out CollisionLayer layer, Allocator.TempJob, Dependency);
            Dependency = PhysicsDebug.DrawFindPairs(layer).ScheduleParallel(Dependency);
            Dependency = layer.Dispose(Dependency);
        }
        protected override void OnUpdate()
        {
            var layer = sceneGlobalEntity.GetCollectionComponent <SpawnPointCollisionLayer>(true).layer;

            CompleteDependency();
            PhysicsDebug.DrawLayer(layer);
            UnityEngine.Debug.Log("SpawnPoints in layer: " + layer.Count);
        }
        protected override void OnUpdate()
        {
            var layer = sceneBlackboardEntity.GetCollectionComponent <WormholeCollisionLayer>(true).layer;

            CompleteDependency();
            PhysicsDebug.DrawLayer(layer).Run();
            UnityEngine.Debug.Log("Wormholes in layer: " + layer.Count);
        }
Example #4
0
 protected override void OnUpdate()
 {
     Entities.WithAll <FactionTag, Faction>()
     .ForEach((Entity factionEntity) =>
     {
         var layer = EntityManager.GetCollectionComponent <FactionShipsCollisionLayer>(factionEntity, true);
         CompleteDependency();
         PhysicsDebug.DrawLayer(layer.layer);
     }).WithoutBurst().Run();
 }
Example #5
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, GraphicsDevice graphicsDevice)
        {
            // TODO: Add your drawing code here
            // TODO: bloom map
            spriteBatch.Begin(SpriteSortMode.BackToFront,
                              BlendState.AlphaBlend,
                              Settings.SAMPLER_STATE,
                              DepthStencilState.Default,
                              RasterizerState.CullNone,
                              Settings.GLOBAL_SHADER,
                              Camera.Main.Transform);
            GameWorld.Current.Map.Draw(spriteBatch);
            spriteBatch.End();

            spriteBatch.Begin(SpriteSortMode.BackToFront,
                              BlendState.AlphaBlend,
                              Settings.SAMPLER_STATE,
                              DepthStencilState.Default,
                              RasterizerState.CullNone,
                              Settings.GLOBAL_SHADER,
                              Camera.Main.Transform);
            GameObjects.Draw(spriteBatch);
            spriteBatch.End();

            // GIZMOS
            spriteBatch.Begin(SpriteSortMode.BackToFront,
                              BlendState.AlphaBlend,
                              Settings.SAMPLER_STATE,
                              DepthStencilState.Default,
                              RasterizerState.CullNone,
                              Settings.GLOBAL_SHADER,
                              Camera.Main.Transform);
            GameObjects.Draw(spriteBatch);
            Gizmo.Draw(spriteBatch, Settings.DEBUG_GRID);

            spriteBatch.End();

            if (Settings.PHYSICS_DEBUG)
            {
                if (physicsDebug == null)
                {
                    physicsDebug = new PhysicsDebug(GameWorld.Current.World);
                    physicsDebug.LoadContent(
                        ProjectPivot.Current.GraphicsDevice,
                        ProjectPivot.Current.Content);
                }
                physicsDebug.Draw();
            }

            drawUI(spriteBatch, gameTime);

            base.Draw(gameTime, spriteBatch, graphicsDevice);
        }
        protected override void OnUpdate()
        {
            CollisionLayerSettings settings = new CollisionLayerSettings
            {
                worldSubdivisionsPerAxis = new int3(2, 2, 2),
                worldAABB = new Aabb {
                    min = new float3(-50f, -50f, -50f), max = new float3(50f, 50f, 50f)
                },
            };

            Dependency = Physics.BuildCollisionLayer(m_query, this).WithSettings(settings).ScheduleParallel(out CollisionLayer layer, Allocator.TempJob, Dependency);
            Dependency = PhysicsDebug.DrawLayer(layer).ScheduleParallel(Dependency);
            Dependency = layer.Dispose(Dependency);
        }