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,19 @@
using Interfaces;
using UnityEngine;
namespace Weapons
{
public class AutoWeapon : Weapon, IWeapon
{
[SerializeField] private GameObject projectilePrefab;
[SerializeField] private Transform firePoint;
public override void Fire()
{
var projectile = Instantiate(projectilePrefab, firePoint.position, firePoint.rotation);
projectile.TryGetComponent<IDamageInflectorSetup>(out var inflector);
inflector?.Setup(character);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fd9cdb55272f45ab9c60a948a56e01f5
timeCreated: 1752259218

View File

@@ -0,0 +1,27 @@
using System;
using Data;
using Interfaces;
using Systems;
using UnityEngine;
namespace Weapons
{
public class MeleeAttack : Weapon, IWeapon
{
[SerializeField] private float range = 1f;
[SerializeField] private LayerMask targetMask;
public override void Fire()
{
var hits = Physics2D.OverlapCircleAll(transform.position, range, targetMask);
foreach (var hit in hits)
{
hit.TryGetComponent<Health>(out var health);
if (hit.gameObject == character.gameObject) continue;
var damage = character.attributes.Damage * character.attributes.MeleeDamage;
health.TakeDamage(damage);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e4ff53f671604189b15fac28115b2b70
timeCreated: 1752259665

View File

@@ -0,0 +1,47 @@
using System;
using Data;
using Interfaces;
using KBCore.Refs;
using Systems;
using UnityEngine;
namespace Weapons
{
public class Projectile : MonoBehaviour, IDamageInflector, IDamageInflectorSetup
{
[Self, SerializeField] private Rigidbody2D rb;
[SerializeField] private float speed = 10f;
[SerializeField] private float lifeTime = 5f;
public float Damage { get; private set; }
public GameObject Owner { get; private set; }
public DamageType Type => DamageType.Ranged;
public void Setup(Character attacker)
{
Damage = attacker.attributes.Damage * attacker.attributes.RangedDamage;
Owner = attacker.gameObject;
}
private void Start()
{
Destroy(gameObject, lifeTime);
}
private void FixedUpdate()
{
var direction = transform.up.normalized;
var movement = direction * (speed * Time.fixedDeltaTime);
rb.MovePosition(rb.position + (Vector2)movement);
}
private void OnTriggerEnter2D(Collider2D other)
{
other.TryGetComponent<Health>(out var health);
if (other.gameObject == Owner) return;
health.TakeDamage(Damage);
Destroy(gameObject);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2d5fcee922b049d1b9db7b49711ce562
timeCreated: 1752259511

View File

@@ -0,0 +1,27 @@
using System;
using Data;
using Interfaces;
using UnityEngine;
namespace Weapons
{
public abstract class Weapon : MonoBehaviour, IWeapon
{
private float timer;
[SerializeField] private float cooldown = 1f;
[SerializeField] protected Character character;
private void Update()
{
timer -= Time.deltaTime;
if (!(timer <= 0f)) return;
Fire();
timer = 1f / character.attributes.AttackSpeed;
}
public abstract void Fire();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a504bad3918744d7bbbf3065678bb96a
timeCreated: 1752259779