added: units can now have their movement settings set through rpc

This commit is contained in:
Chris
2025-10-08 22:55:55 -04:00
parent eb7ff08b50
commit 44e3a3ef7a
4 changed files with 119 additions and 38 deletions

View File

@@ -1,6 +1,7 @@
using System;
using Reset.Core;
using Sirenix.OdinInspector;
using Unity.Netcode;
using UnityEngine;
namespace Reset.Units{
@@ -9,6 +10,9 @@ namespace Reset.Units{
[ShowInInspector]
public bool lockonDebug{ get; set; } = true;
public float lockonRaycastVerticalOffset{ get; set; } = 1f;
public float maxHealth{ get; set; }
public float currentHealth{ get; set; }
public Animator testModelAnimator;
@@ -29,11 +33,15 @@ namespace Reset.Units{
public void TakeDamage(DamageSource source){
try {
((IKillable)this).currentHealth -= source.damageDealt;
currentHealth -= source.damageDealt;
if (UnitIsNetworked()){
SetHealthRpc(currentHealth);
}
testModelAnimator.SetTrigger("Hit");
if (((IKillable)this).currentHealth <= 0) {
if (currentHealth <= 0) {
Kill();
}
} catch (Exception e) {
@@ -41,11 +49,14 @@ namespace Reset.Units{
}
}
[Rpc(SendTo.Everyone)]
void SetHealthRpc(float newHealth){
currentHealth = newHealth;
}
public void Kill(){
throw new System.NotImplementedException();
}
public float maxHealth{ get; set; }
public float currentHealth{ get; set; }
}
}