protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new PlayerInputJob {
        };

        return(job.Schedule(this, 1, inputDeps));
    }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            NativeArray <PhysicsStep> a = GravityQuery.ToComponentDataArray <PhysicsStep>(Allocator.TempJob);

            if (a.Length > 0)
            {
                gravity = a[0].Gravity;
            }
            PlayerInputJob moveJob = new PlayerInputJob
            {
                Horizontal  = Input.GetAxis("Horizontal"),
                Vertical    = Input.GetAxis("Vertical"),
                spaceDown   = Input.GetKeyDown(KeyCode.Space),
                LShiftDown  = Input.GetKeyDown(KeyCode.LeftShift),
                LCtrlDown   = Input.GetKeyDown(KeyCode.LeftControl),
                Mouse1Down  = Input.GetKeyDown(KeyCode.Mouse1),
                Mouse2Down  = Input.GetKeyDown(KeyCode.Mouse2),
                MouseX      = Input.GetAxis("Mouse X"),
                MouseY      = Input.GetAxis("Mouse Y"),
                deltaTime   = Time.deltaTime,
                attackADown = inputDefinitionsClass.isAttackA(),
                attackBDown = inputDefinitionsClass.isAttackB(),
                attackCDown = inputDefinitionsClass.isAttackC(),
                attackDDown = inputDefinitionsClass.isAttackD(),
                gravity     = gravity
            };

            a.Dispose();
            JobHandle moveHandle = moveJob.Schedule(this, inputDeps);

            return(moveHandle);
        }
Example #3
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var job = new PlayerInputJob {
                Horizontal = Input.GetAxis("Horizontal")
            };

            return(job.Schedule(this, 64, inputDeps));
        }
Example #4
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new PlayerInputJob {
            leftClick  = Input.GetMouseButtonDown(0),
            rightClick = Input.GetMouseButtonDown(1),
        };

        return(job.Schedule(this, inputDeps));
    }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var playerJob = new PlayerInputJob();

            playerJob.shipInput   = GetComponentDataFromEntity <PlayerInputComponentData>();
            playerJob.cmdBuffer   = GetBufferFromEntity <IncomingCommandDataStreamBufferComponent>();
            playerJob.currentTick = serverSimulationSystemGroup.ServerTick;
            return(playerJob.ScheduleSingle(this, inputDeps));
        }
Example #6
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var playerJob = new PlayerInputJob();

            playerJob.left            = 0;
            playerJob.right           = 0;
            playerJob.thrust          = 0;
            playerJob.shoot           = 0;
            playerJob.commandBuffer   = m_Barrier.CreateCommandBuffer().ToConcurrent();
            playerJob.inputFromEntity = GetBufferFromEntity <ShipCommandData>();
            playerJob.inputTargetTick = m_GhostPredict.PredictingTick;

            if (World.GetExistingSystem <ClientPresentationSystemGroup>().Enabled)
            {
                if (Input.GetKey("left"))
                {
                    playerJob.left = 1;
                }
                if (Input.GetKey("right"))
                {
                    playerJob.right = 1;
                }
                if (Input.GetKey("up"))
                {
                    playerJob.thrust = 1;
                }
                //if (InputSamplerSystem.spacePresses > 0)
                if (Input.GetKey("space"))
                {
                    playerJob.shoot = 1;
                }
            }
            else
            {
                // Spawn and generate some random inputs
                var state = (int)Time.ElapsedTime % 3;
                if (state == 0)
                {
                    playerJob.left = 1;
                }
                else
                {
                    playerJob.thrust = 1;
                }
                ++frameCount;
                if (frameCount % 100 == 0)
                {
                    playerJob.shoot = 1;
                    frameCount      = 0;
                }
            }

            var handle = playerJob.ScheduleSingle(this, inputDeps);

            m_Barrier.AddJobHandleForProducer(handle);
            return(handle);
        }
Example #7
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var playerJob = new PlayerInputJob();

            playerJob.left            = 0;
            playerJob.right           = 0;
            playerJob.thrust          = 0;
            playerJob.shoot           = 0;
            playerJob.shipState       = GetComponentDataFromEntity <ShipStateComponentData>();
            playerJob.rpcQueue        = m_RpcQueue;
            playerJob.rpcBuffer       = GetBufferFromEntity <OutgoingRpcDataStreamBufferComponent>();
            playerJob.cmdBuffer       = GetBufferFromEntity <OutgoingCommandDataStreamBufferComponent>();
            playerJob.ackSnapshot     = GetComponentDataFromEntity <NetworkSnapshotAck>();
            playerJob.localTime       = NetworkTimeSystem.TimestampMS;
            playerJob.inputTargetTick = NetworkTimeSystem.predictTargetTick;

            if (World.GetExistingManager <ClientPresentationSystemGroup>().Enabled)
            {
                if (Input.GetKey("left"))
                {
                    playerJob.left = 1;
                }
                if (Input.GetKey("right"))
                {
                    playerJob.right = 1;
                }
                if (Input.GetKey("up"))
                {
                    playerJob.thrust = 1;
                }
                if (InputSamplerSystem.spacePresses > 0)
                {
                    //if (Input.GetKey("space"))
                    playerJob.shoot = 1;
                }
            }
            else
            {
                // Spawn and generate some random inputs
                var state = (int)Time.fixedTime % 3;
                if (state == 0)
                {
                    playerJob.left = 1;
                }
                else
                {
                    playerJob.thrust = 1;
                }
                if (Time.frameCount % 100 == 0)
                {
                    playerJob.shoot = 1;
                }
            }

            return(playerJob.ScheduleSingle(this, inputDeps));
        }
Example #8
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new PlayerInputJob
        {
            Left  = Input.GetKey(KeyCode.LeftArrow),
            Right = Input.GetKey(KeyCode.RightArrow),
        };

        return(job.Schedule(this, 1, inputDeps));
    }
Example #9
0
        //这个是主线程里面做的事
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var job = new PlayerInputJob {
                pFire          = Input.GetButtonDown("Fire1"),
                moveHorizontal = Input.GetAxis("Horizontal"),
                moveVertical   = Input.GetAxis("Vertical"),
            };

            return(job.Schedule(this, inputDeps));
        }
Example #10
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new PlayerInputJob
        {
            dt = Time.deltaTime,
        };

        // This 1 here is the InnerLoop batch. Lower numbers mean bigger jobs.
        return(job.Schedule(this, 1, inputDeps));
    }
Example #11
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        PlayerInputJob job = new PlayerInputJob
        {
            MovementVector = new float2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")),
            IsFiring       = Input.GetKey(KeyCode.Space)
        };

        return(job.Schedule(this, inputDeps));
    }
Example #12
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        // Prepare data for job
        PlayerInputJob job = new PlayerInputJob {
            Horizontal = Input.GetAxisRaw("Horizontal"),
            Vertical   = Input.GetAxisRaw("Vertical")
        };

        return(job.Schedule(this, batchSize, inputDeps));
    }
Example #13
0
    //prepare the data for the Job
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var jobs = new PlayerInputJob
        {
            Horizontal = Input.GetAxis("Horizontal"),
            Vertical   = Input.GetAxis("Vertical")
        };

        //the 1 is the job size, bigger for little jobs
        return(jobs.Schedule(this, 1, inputDeps));
    }
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new PlayerInputJob
        {
            MoveInput  = _moveInput,
            LookInput  = _lookInput,
            ShootInput = _shootInput
        };

        inputDeps = job.Schedule(this, inputDeps);
        barrier.AddJobHandleForProducer(inputDeps);
        return(inputDeps);
    }
Example #15
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var job = new PlayerInputJob
            {
                Ecb                = _barrier.CreateCommandBuffer().ToConcurrent(),
                MoveInput          = _moveInput,
                MouseInput         = _mouseInput,
                LookInput          = _lookInput,
                CustomInputs       = _customInputs,
                CustomSticksInputs = _customSticksInputs
            };

            inputDeps = job.Schedule(this, inputDeps);
            _barrier.AddJobHandleForProducer(inputDeps);
            return(inputDeps);
        }
Example #16
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new PlayerInputJob
        {
            Left  = Input.GetKey(KeyCode.A),
            Right = Input.GetKey(KeyCode.D),
            Up    = Input.GetKey(KeyCode.W),
            //Down = Input.GetKeyDown(KeyCode.S),

            //UpLeft = Input.GetKeyDown(KeyCode.Q),
            //UpRight = Input.GetKeyDown(KeyCode.E),
            //DownLeft = Input.GetKeyDown(KeyCode.Z),
            //DownRight = Input.GetKeyDown(KeyCode.X),
        };

        return(job.Schedule(this, 1, inputDeps));
    }
Example #17
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var mousePos = Input.mousePosition;
        var ray      = Camera.main.ScreenPointToRay(mousePos);

        if (Physics.Raycast(ray, out RaycastHit hit))
        {
            mousePos = new float3(hit.point.x, 0, hit.point.z);
        }
        var job = new PlayerInputJob
        {
            RightClick    = Input.GetMouseButtonDown(1),
            LeftClick     = Input.GetMouseButtonDown(0),
            MousePosition = mousePos
        };

        return(job.Schedule(this, inputDeps));
    }
Example #18
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var playerJob = new PlayerInputJob();

        playerJob.shoot = 0;

        playerJob.commandBuffer   = m_Barrier.CreateCommandBuffer().ToConcurrent();
        playerJob.inputFromEntity = GetBufferFromEntity <TestCommandData>();
        playerJob.inputTargetTick = m_GhostPredict.PredictingTick;

        if (Input.GetKeyDown("g"))
        {
            Debug.Log("g pressed");
            playerJob.shoot = 1;
        }

        var handle = playerJob.ScheduleSingle(this, inputDeps);

        m_Barrier.AddJobHandleForProducer(handle);
        return(handle);
    }
Example #19
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var job = new PlayerInputJob
            {
                Left          = Input.GetKeyDown(KeyCode.A),
                Right         = Input.GetKeyDown(KeyCode.D),
                Up            = Input.GetKeyDown(KeyCode.W),
                Down          = Input.GetKeyDown(KeyCode.S),
                UpLeft        = Input.GetKeyDown(KeyCode.Q),
                UpRight       = Input.GetKeyDown(KeyCode.E),
                DownLeft      = Input.GetKeyDown(KeyCode.Z),
                DownRight     = Input.GetKeyDown(KeyCode.X),
                Fire          = Input.GetKeyDown(KeyCode.G),
                MousePosition =
                {
                    x = Input.mousePosition.x,
                    y = Input.mousePosition.y
                }
            };

            return(job.Schedule(this, inputDeps));
        }
Example #20
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new PlayerInputJob
        {
            Horizontal = Input.GetAxisRaw("Horizontal"),
            Vertical   = Input.GetAxisRaw("Vertical")


                         //Left = Input.GetKeyDown(KeyCode.A),
                         //Right = Input.GetKeyDown(KeyCode.D),
                         //Up = Input.GetKeyDown(KeyCode.W),
                         //Down = Input.GetKeyDown(KeyCode.S),

                         //UpLeft = Input.GetKeyDown(KeyCode.Q),
                         //UpRight = Input.GetKeyDown(KeyCode.E),
                         //DownLeft = Input.GetKeyDown(KeyCode.Z),
                         //DownRight = Input.GetKeyDown(KeyCode.X),
        };

        // This 1 here is the InnerLoop batch. Lower numbers mean bigger jobs.
        return(job.Schedule(this, 1, inputDeps));
    }
Example #21
0
        } // PlayerInputJob

        /// <summary>
        /// Each frame, this input system will sample player input, save it to a PlayerInputJob
        /// data structure, and schedule it to be processed later by the BeginSimulationEntityCommandBufferSystem
        /// </summary>
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var playerJob = new PlayerInputJob();

            playerJob.left   = 0;
            playerJob.right  = 0;
            playerJob.thrust = 0;
            playerJob.shoot  = 0;

            // More boilerplately stuff I honestly haven't been able to wrap my head around.
            playerJob.commandBuffer   = m_Barrier.CreateCommandBuffer().ToConcurrent();
            playerJob.inputFromEntity = GetBufferFromEntity <ShipCommandData>();
            playerJob.inputTargetTick = m_GhostPredict.PredictingTick;

            // Sample keyboard inputs only if the presentation group is active,
            // aka only take input if we're rendering (not tabbed out or anything)
            if (World.GetExistingSystem <ClientPresentationSystemGroup>().Enabled)
            {
                if (Input.GetKey("left"))
                {
                    playerJob.left = 1;
                }
                if (Input.GetKey("right"))
                {
                    playerJob.right = 1;
                }
                if (Input.GetKey("up"))
                {
                    playerJob.thrust = 1;
                }
                //if (InputSamplerSystem.spacePresses > 0) // This is commented out in the sample project! See comments on the InputSamplerSystem.
                if (Input.GetKey("space"))
                {
                    playerJob.shoot = 1;
                }
            }

            // FOR THIS SAMPLE GAME (never would we do this in our own game), random inputs are
            // generated for clients that are tabbed out. This is again just for demonstration
            // purposes so there's more happening when you demo it.
            else
            {
                // Spawn and generate some random inputs
                var state = (int)Time.ElapsedTime % 3;
                if (state == 0)
                {
                    playerJob.left = 1;
                }
                else
                {
                    playerJob.thrust = 1;
                }
                ++frameCount;
                if (frameCount % 100 == 0)
                {
                    playerJob.shoot = 1;
                    frameCount      = 0;
                }
            }

            // ... input has been sampled!

            var handle = playerJob.ScheduleSingle(this, inputDeps);

            m_Barrier.AddJobHandleForProducer(handle);
            return(handle);
        }