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,34 @@
using System;
using KBCore.Refs;
using UnityEngine;
using UnityEngine.InputSystem;
namespace Systems
{
public class Aiming : MonoBehaviour
{
[SerializeField, Scene] private Camera mainCamera;
private void Reset()
{
if (!mainCamera)
{
mainCamera = Camera.main;
}
}
private void Update()
{
if (!mainCamera) return;
var mousePosition = Mouse.current.position.ReadValue();
var worldPosition = mainCamera.ScreenToWorldPoint(mousePosition);
worldPosition.z = transform.position.z;
var direction = (worldPosition - transform.position).normalized;
var angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0,0, angle);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d8f62cd9ff7b4fcfa29d4c7fca486944
timeCreated: 1752262081

View File

@@ -0,0 +1,36 @@
using Data;
using Interfaces;
using KBCore.Refs;
using UnityEngine;
namespace Systems
{
public class DeathHandler : MonoBehaviour
{
[Self, SerializeField] private Character character;
[Self, SerializeField] private InterfaceRef<IDeathBehavior> deathBehavior;
private void OnEnable()
{
character.attributes.OnHealthChanged += OnHealthChanged;
}
private void OnDisable()
{
character.attributes.OnHealthChanged -= OnHealthChanged;
}
private void OnHealthChanged(float newHealth)
{
if (newHealth <= 0f)
{
Die();
}
}
private void Die()
{
deathBehavior.Value.Die();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5fa2924c6ed8486bbfa95c439bf9e421
timeCreated: 1752260559

View File

@@ -0,0 +1,24 @@
using System;
using Data;
using KBCore.Refs;
using UnityEngine;
namespace Systems
{
public class Health : MonoBehaviour
{
[Self, SerializeField] private Character character;
[SerializeField] private float initialHealth = 100f;
private void Start()
{
character.attributes.SetHealth(initialHealth);
}
public void TakeDamage(float damage)
{
var effectiveDamage = Math.Max(damage - character.attributes.Armor, 1);
character.attributes.ModifyHealth(-effectiveDamage);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9139aea24fd54a5eb0f5fc1556478cb6
timeCreated: 1752257112

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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3c35f16c2a9546a2b4911f4da933efa0
timeCreated: 1752255167

View File

@@ -0,0 +1,14 @@
using Interfaces;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Systems
{
public class PlayerDeathBehavior : MonoBehaviour, IDeathBehavior
{
public void Die()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b46c8a98e30a405eb2d287515609ecda
timeCreated: 1752258510