added: units can now have their movement settings set through rpc
This commit is contained in:
@@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user