closes #21; closes #17

This commit is contained in:
Rowan 2025-08-02 14:34:29 -04:00
parent d72d44d16e
commit 232e5d4ef2
6 changed files with 75 additions and 5 deletions

View file

@ -544,19 +544,19 @@
"m_Id": "47997da48bb54307bd066561ed772527"
},
{
"m_Id": "756712fba89b49808c6efdb2ddb6ec7a"
"m_Id": "267a20c0dea74203b5b23029fb2e17d1"
},
{
"m_Id": "267a20c0dea74203b5b23029fb2e17d1"
"m_Id": "756712fba89b49808c6efdb2ddb6ec7a"
},
{
"m_Id": "dc227ad12736457ba893aa6ad1ce41c2"
},
{
"m_Id": "1cd72896bd914789b0cc4cc80af0850a"
"m_Id": "00311e469f6f45aba1d2c5b2198478a0"
},
{
"m_Id": "00311e469f6f45aba1d2c5b2198478a0"
"m_Id": "1cd72896bd914789b0cc4cc80af0850a"
},
{
"m_Id": "fa82e18ce46142d894bf50fc0df8a612"
@ -3055,7 +3055,7 @@
},
"m_Name": "Parallax Mapping",
"m_DrawState": {
"m_Expanded": true,
"m_Expanded": false,
"m_Position": {
"serializedVersion": "2",
"x": -1269.0001220703125,

View file

@ -18,5 +18,7 @@ MonoBehaviour:
effect: {fileID: 11400000, guid: 0902dc21238be2bb3ae758e1d5218922, type: 2}
- uiEvent: 1
effect: {fileID: 11400000, guid: fd3397ffea6cbccc5992ef2e70a2ed44, type: 2}
headerId: header
titleId: title
bodyId: body
contentId: content

View file

@ -0,0 +1,35 @@
using KitsuneCafe.System;
using UnityEngine;
namespace KitsuneCafe.Entity
{
public interface IDamaging : IGameObject
{
void ApplyDamage(int amount, IDamageable target);
}
public interface IDamageable : IGameObject
{
void ReceiveDamage(IDamaging source, int amount);
}
public class DamageSource : MonoBehaviour, IDamaging
{
[SerializeField]
private int damage;
public void ApplyDamage(int amount, IDamageable target)
{
target.ReceiveDamage(this, amount);
}
public void ApplyDamage(int amount, GameObject target)
{
if (target.TryGetComponent(out IDamageable damageable))
{
ApplyDamage(amount, damageable);
}
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5ac53e30c2f9ed3d48e3ed86a8aed11b

View file

@ -0,0 +1,29 @@
using System;
using R3;
using UnityEngine;
namespace KitsuneCafe.Entity
{
public class Health : MonoBehaviour, IDamageable
{
[SerializeField]
private SerializableReactiveProperty<int> max;
public int Max => max.CurrentValue;
[SerializeField]
private SerializableReactiveProperty<int> current;
public int Current => current.CurrentValue;
public void Recover(int amount)
{
this.current.Value = Math.Clamp(this.Current + amount, 0, this.Max);
}
public void ReceiveDamage(IDamaging source, int amount)
{
this.current.Value = Math.Clamp(this.Current - amount, 0, this.Max);
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6bf44a57a6a836c249eac8ba9521ce64