protected override void OnCreate()
        {
            this.physicsWorld = World.DefaultGameObjectInjectionWorld.GetOrCreateSystem <BuildPhysicsWorld>();
            this.endSimulationEntityCommandBufferSystem = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();

            this.magicAttackEntityQuery = this.GetEntityQuery(this.EntityManager.GetMagicAttackAnimationIdentifier());
        }
 protected override void OnCreate()
 {
     base.OnCreate();
     buildPhysicsWorld = World.GetOrCreateSystem <BuildPhysicsWorld>();
     stepPhysicsWorld  = World.GetOrCreateSystem <StepPhysicsWorld>();
     Enabled           = true;
 }
 protected override void OnCreate()
 {
     base.OnCreate();
     buildPhysicsWorld = World.GetOrCreateSystem <BuildPhysicsWorld>();
     stepPhysicsWorld  = World.GetOrCreateSystem <StepPhysicsWorld>();
     bufferSystem      = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
 }
    // raycast caring about both where and what was hit
    private bool Raycast(float3 fromPosition, float3 toPosition, ref Unity.Physics.RaycastHit hit, ref Entity e)
    {
        BuildPhysicsWorld buildPhysicsWorld = World.DefaultGameObjectInjectionWorld.GetExistingSystem <Unity.Physics.Systems.BuildPhysicsWorld>(); //Get the build physics world
        CollisionWorld    collisionWorld    = buildPhysicsWorld.PhysicsWorld.CollisionWorld;                                                       //get the collision world

        RaycastInput raycastInput = new RaycastInput {
            Start  = fromPosition,
            End    = toPosition,
            Filter = new CollisionFilter {
                BelongsTo    = ~0u, // belongs to all layers
                CollidesWith = ~0u, // collides with all layers
                GroupIndex   = 0,   // a new group
            }
        };

        if (collisionWorld.CastRay(raycastInput, out hit)) // use the collision world to cast a ray
        // hit something
        {
            e = buildPhysicsWorld.PhysicsWorld.Bodies[hit.RigidBodyIndex].Entity;
            return(true);
        }
        else
        {
            return(false);
        }
    }
 protected override void OnCreate()
 {
     es_ecb     = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
     es_ecb_Job = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
     bpw        = World.DefaultGameObjectInjectionWorld.GetExistingSystem <BuildPhysicsWorld>();
     spw        = World.DefaultGameObjectInjectionWorld.GetExistingSystem <StepPhysicsWorld>();
 }
    protected override void OnCreate()
    {
        base.OnCreate();
        buildPhysicsWorld = World.GetExistingSystem <BuildPhysicsWorld>();

        Enabled = false;
    }
Ejemplo n.º 7
0
    private Entity Raycast(float3 fromPosition, float3 toPosition)
    {
        BuildPhysicsWorld buildPhysicsWorld = World.DefaultGameObjectInjectionWorld.GetExistingSystem <BuildPhysicsWorld>();
        CollisionWorld    collisionWorld    = buildPhysicsWorld.PhysicsWorld.CollisionWorld;

        RaycastInput raycastInput = new RaycastInput {
            Start  = fromPosition,
            End    = toPosition,
            Filter = new CollisionFilter {
                BelongsTo    = ~0u,
                CollidesWith = ~0u,
                GroupIndex   = 0,
            }
        };

        Unity.Physics.RaycastHit raycastHit = new Unity.Physics.RaycastHit();

        if (collisionWorld.CastRay(raycastInput, out raycastHit))
        {
            // Hit
            Entity hitEntity = buildPhysicsWorld.PhysicsWorld.Bodies[raycastHit.RigidBodyIndex].Entity;
            return(hitEntity);
        }
        else
        {
            return(Entity.Null);
        }
    }
Ejemplo n.º 8
0
 protected override void OnCreate()
 {
     m_EndSimulationSystem     = World.Active.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
     m_BuildPhysicsWorldSystem = World.Active.GetOrCreateSystem <BuildPhysicsWorld>();
     m_StepPhysicsWorld        = World.Active.GetOrCreateSystem <StepPhysicsWorld>();
     m_ExportPhysicsWorld      = World.Active.GetOrCreateSystem <ExportPhysicsWorld>();
 }
    protected override void OnCreate()
    {
        m_BuildPhysicsWorldSystem = World.GetOrCreateSystem <BuildPhysicsWorld>();
        m_StepPhysicsWorldSystem  = World.GetOrCreateSystem <StepPhysicsWorld>();

        m_endSimEcbSystem = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
    }
Ejemplo n.º 10
0
    public Entity Raycast(float3 startPos, float3 endPos)
    {
        //首先获取物理世界
        BuildPhysicsWorld physicsWorld = World.DefaultGameObjectInjectionWorld.GetExistingSystem <BuildPhysicsWorld>();
        //然后获取碰撞世界
        CollisionWorld collisionWorld = physicsWorld.PhysicsWorld.CollisionWorld;

        RaycastInput raycastInput = new RaycastInput()
        {
            Start = startPos,
            End   = endPos,
            //声明碰撞过滤器,用来过滤某些层级下的物体是否进行射线检测
            Filter = CollisionFilter.Default,
            //Filter = new CollisionFilter()
            //{
            //    BelongsTo = ~0u,
            //    CollidesWith = ~0u,
            //    GroupIndex = 0,
            //}
        };

        //发射射线去检测Entity实体
        if (collisionWorld.CastRay(raycastInput, out raycastHit))
        {
            isGo = true;
            //拿到我们射线击中的entity
            Entity entity = physicsWorld.PhysicsWorld.Bodies[raycastHit.RigidBodyIndex].Entity;
            return(entity);
        }
        else
        {
            Debug.Log("Notthing Found");
            return(Entity.Null);
        }
    }
    private bool Raycast(float3 from, float3 to, out float3 point, out Entity entity)
    {
        BuildPhysicsWorld physicsWorld   = World.GetOrCreateSystem <BuildPhysicsWorld>();
        CollisionWorld    collisionWorld = physicsWorld.PhysicsWorld.CollisionWorld;

        RaycastInput raycastInput = new RaycastInput
        {
            Start  = from,
            End    = to,
            Filter = new CollisionFilter
            {
                BelongsTo    = ~0u,
                CollidesWith = ~0u,
                GroupIndex   = 0
            }
        };

        var hit = new Unity.Physics.RaycastHit();

        if (collisionWorld.CastRay(raycastInput, out hit))
        {
            point  = hit.Position;
            entity = hit.Entity;
            return(true);
        }

        point  = hit.Position;
        entity = hit.Entity;
        return(false);
    }
Ejemplo n.º 12
0
    protected override void OnCreate()
    {
        RequireSingletonForUpdate <NavMesh>();
        RequireSingletonForUpdate <Config>();

        physicsWorldSystem = World.GetOrCreateSystem <BuildPhysicsWorld>();
    }
 protected override void OnCreate()
 {
     m_physicsWorld = World.GetOrCreateSystem <BuildPhysicsWorld>();
     m_physicsStep  = World.GetOrCreateSystem <StepPhysicsWorld>();
     m_endSimulationEntityCommandBufferSystem = World.DefaultGameObjectInjectionWorld
                                                .GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
 }
 protected override void OnCreate()
 {
     conversionSystem = World.GetExistingSystem <GameObjectConversionSystem>();
     PhysicsColliderFollowEntityQuery = GetEntityQuery(typeof(PhysicsColliderFollowEntityData), typeof(PhysicsCollider));
     mBuildPhysicsWorld = World.GetExistingSystem <BuildPhysicsWorld>();
     mStepPhysicsWorld  = World.GetExistingSystem <StepPhysicsWorld>();
 }
Ejemplo n.º 15
0
 protected override void OnCreate()
 {
     base.OnCreate();
     RequireSingletonForUpdate <PlayerTag>();
     _buildPhysicsWorldSystem = World.GetOrCreateSystem <BuildPhysicsWorld>();
     _stepPhysicsWorldSystem  = World.GetOrCreateSystem <StepPhysicsWorld>();
 }
Ejemplo n.º 16
0
 protected override void OnCreate()
 {
     _UnitQuery         = GetEntityQuery(typeof(UnitData));
     _SelectionSystem   = World.GetOrCreateSystem <SelectionSystem>();
     _ECBSystem         = World.GetOrCreateSystem <EndInitializationEntityCommandBufferSystem>();
     _BuildPhysicsWorld = World.GetOrCreateSystem <BuildPhysicsWorld>();
 }
Ejemplo n.º 17
0
        protected override void OnStartRunning()
        {
            allEntities        = EntityManager.GetAllEntities(Allocator.Persistent);
            entities           = new NativeArray <Entity>(Spawner.SwarmCount, Allocator.Persistent);
            translationMapData = new NativeHashMap <Entity, Translation>(Spawner.SwarmCount, Allocator.Persistent);
            velocityMapData    = new NativeHashMap <Entity, VelocityComponent>(Spawner.SwarmCount, Allocator.Persistent);

            collisionFilter = new CollisionFilter
            {
                BelongsTo    = ~(1u << 8),
                CollidesWith = ~(1u << 8),
                GroupIndex   = 0
            };
            buildPhysicsWorld = World.DefaultGameObjectInjectionWorld.GetExistingSystem <BuildPhysicsWorld>();

            var index = 0;

            for (int i = 0; i < allEntities.Length; i++)
            {
                if (EntityManager.HasComponent <VelocityComponent>(allEntities[i]))
                {
                    entities[index] = allEntities[i];

                    velocityComponent = EntityManager.GetComponentData <VelocityComponent>(allEntities[i]);
                    velocityComponent.timerCalcVelocity = UnityEngine.Random.value * tick;
                    velocityComponent.velocity          = UnityEngine.Random.onUnitSphere * maxSpeed;
                    EntityManager.SetComponentData(allEntities[i], velocityComponent);

                    index++;
                }
            }
        }
Ejemplo n.º 18
0
        protected override void OnCreate()
        {
            base.OnCreate();

            _buildPhysicsWorldSystem = World.GetOrCreateSystem <BuildPhysicsWorld>();
            _stepPhysicsWorldSystem  = World.GetOrCreateSystem <StepPhysicsWorld>();
        }
Ejemplo n.º 19
0
        protected override void OnCreate( )
        {
            buildPhysicsWorld     = World.GetOrCreateSystem <BuildPhysicsWorld> ();
            endFramePhysicsSystem = World.GetExistingSystem <EndFramePhysicsSystem> ();

            base.OnCreate( );
        }
Ejemplo n.º 20
0
 void Start()
 {
     hits  = new NativeList <DistanceHit>(Allocator.Persistent);
     world = World.Active;
     mgr   = world.EntityManager;
     physicsWorldSystem = mgr.World.GetOrCreateSystem <Unity.Physics.Systems.BuildPhysicsWorld>();
 }
        protected override void OnCreate( )
        {
            becb = World.GetOrCreateSystem <BeginSimulationEntityCommandBufferSystem> ();

            buildPhysicsWorld = World.GetOrCreateSystem <BuildPhysicsWorld> ();

            group_pathPlanners = EntityManager.CreateEntityQuery
                                 (
                ComponentType.ReadOnly <IsAliveTag> (),
                ComponentType.Exclude <CanFindPathTag> (),

                ComponentType.ReadWrite <PathPlannerComponent> ()
                                 );

            EntityArchetype entityArchetype = EntityManager.CreateArchetype
                                              (
                typeof(IsAliveTag),
                typeof(PathPlannerComponent),
                typeof(PathNodesBuffer),

                typeof(Prefab)
                                              );

            // Example
            {
                Entity pathPlannerPrefabEntity = EntityManager.CreateEntity(entityArchetype);
                EntityManager.SetName(pathPlannerPrefabEntity, "PathPlannar");
                NativeArray <Entity> na_pathPLannerEntities = EntityManager.Instantiate(pathPlannerPrefabEntity, 100, Allocator.Temp);
                na_pathPLannerEntities.Dispose();

                EntityManager.SetName(pathPlannerPrefabEntity, "PathPlannarPrefab");
            }
        }
Ejemplo n.º 22
0
        protected override void OnCreate()
        {
            _buildPhysicsWorldSystem = World.GetOrCreateSystem <BuildPhysicsWorld>();
            EventQueue = World.GetOrCreateSystem <EventBubblerSystem>().EventQueue;

            base.OnCreate();
        }
Ejemplo n.º 23
0
        public static Entity Raycast(Vector3 mousePosition, out RaycastHit hit, BuildPhysicsWorld buildPhysicsWorldSystem)
        {
            UnityEngine.Ray inputRay = Camera.main.ScreenPointToRay(mousePosition);

            float3 RayFrom = inputRay.origin;
            float3 RayTo   = inputRay.origin + inputRay.direction * 500f;

            var collisionWorld = buildPhysicsWorldSystem.PhysicsWorld.CollisionWorld;

            RaycastInput input = new RaycastInput()
            {
                Start  = RayFrom,
                End    = RayTo,
                Filter = CollisionFilter.Default
            };

            bool haveHit = collisionWorld.CastRay(input, out hit);

            if (haveHit)
            {
                Entity e = buildPhysicsWorldSystem.PhysicsWorld.Bodies[hit.RigidBodyIndex].Entity;
                return(e);
            }

            return(Entity.Null);
        }
    protected override void OnUpdate()
    {
        Entities.ForEach((ref PhysicsControllerStruct player, ref Translation trans) =>
        {
            //Ground check
            float3 pos    = trans.Value;
            float3 target = pos;
            target.y     -= 1.15f;

            RaycastInput rInput = new RaycastInput()
            {
                Start  = pos,
                End    = target,
                Filter = new CollisionFilter()
                {
                    BelongsTo    = 1,
                    CollidesWith = 2,
                    GroupIndex   = 1
                }
            };

            BuildPhysicsWorld physWorld   = World.Active.GetExistingSystem <BuildPhysicsWorld>();
            CollisionWorld collisionWorld = physWorld.PhysicsWorld.CollisionWorld;

            //Ground check raycast
            player.isGrounded = collisionWorld.CastRay(rInput, out RaycastHit hit);

            //Rigidbody hit
            player.rbIndex = hit.RigidBodyIndex;
        });
    }
Ejemplo n.º 25
0
 /// Gather the needed references in order to schedule the worker thread.
 protected override void OnCreate()
 {
     buildPhysicsWorld = World.GetOrCreateSystem <BuildPhysicsWorld>();
     stepPhysicsWorld  = World.GetOrCreateSystem <StepPhysicsWorld>();
     jobBufferSystem   = World.GetOrCreateSystem <BeginFixedStepSimulationEntityCommandBufferSystem>();
     player            = GetSingletonEntity <PlayerTag>();
 }
Ejemplo n.º 26
0
 protected override void OnCreate()
 {
     _worldBuildSystem = World.GetOrCreateSystem <BuildPhysicsWorld>();
     _collisions       = new NativeMultiHashMap <Entity, HitboxCollision>(
         /*capacity=*/ MatchConfig.kMaxSupportedPlayers * CharacterFrame.kMaxPlayerHitboxCount,
         Allocator.Persistent);
 }
 protected override void OnCreate()
 {
     base.OnCreate();
     stepPhysicsWorld  = World.GetOrCreateSystem <StepPhysicsWorld>();
     buildPhysicsWorld = World.GetOrCreateSystem <BuildPhysicsWorld>();
     system            = World.DefaultGameObjectInjectionWorld.GetExistingSystem <EndSimulationEntityCommandBufferSystem>();
 }
    protected override void OnCreate()
    {
        m_StepPhysicsWorld  = World.GetOrCreateSystem <StepPhysicsWorld>();
        m_BuildPhysicsWorld = World.GetOrCreateSystem <BuildPhysicsWorld>();

        RequireForUpdate(GetEntityQuery(new ComponentType[] { typeof(ModifyNarrowphaseContacts) }));
    }
 protected override void OnCreate()
 {
     m_BuildPhysicsWorldSystem = World.GetOrCreateSystem <BuildPhysicsWorld>();
     m_StepPhysicsWorldSystem  = World.GetOrCreateSystem <StepPhysicsWorld>();
     m_EndFramePhysicsSystem   = World.GetOrCreateSystem <EndFramePhysicsSystem>();
     m_DebugStreamSystem       = World.GetOrCreateSystem <DebugStream>();
 }
Ejemplo n.º 30
0
 protected override void OnCreate()
 {
     base.OnCreate();
     m_EndFramePhysicsSystem = World.GetOrCreateSystem <EndFramePhysicsSystem>();
     m_BuildPhysicsWorld     = World.GetOrCreateSystem <BuildPhysicsWorld>();
     m_EndSimulationSystem   = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
 }