Add new meta files and interfaces for project structure

This commit is contained in:
2025-07-11 21:46:14 +02:00
commit 43c1730ed5
3230 changed files with 1428743 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
using System;
using Data;
using KBCore.Refs;
using UnityEngine;
using UnityEngine.InputSystem;
namespace Systems
{
public class Movement : MonoBehaviour
{
private InputSystem_Actions controls;
private Vector2 movementInput;
[Self, SerializeField] private Character character;
[Self, SerializeField] private Rigidbody2D rb;
private void OnEnable()
{
controls ??= new InputSystem_Actions();
controls.Enable();
controls.Player.Move.performed += OnMovePerformed;
controls.Player.Move.canceled += ctx => movementInput = Vector2.zero;
}
private void OnMovePerformed(InputAction.CallbackContext obj)
{
movementInput = obj.ReadValue<Vector2>();
}
private void OnDisable()
{
controls.Disable();
controls.Player.Move.performed -= OnMovePerformed;
}
private void FixedUpdate()
{
ApplyMovement();
}
private void ApplyMovement()
{
if (!rb) return;
var velocity = new Vector2(movementInput.x, movementInput.y).normalized * character.attributes.MoveSpeed;
rb.linearVelocity = velocity;
}
}
}