using System; using System.Collections; using Drawing; using Reset; using Reset.Core; using Reset.Core.Tools; using Reset.Units; using UnityEngine; using Sirenix.OdinInspector; using Sirenix.Serialization; using Unity.Netcode; namespace Reset.Units{ public class Player : Unit, IKillable{ [HideInInspector] public PlayerControls controls; float IKillable.maxHealth{ get; set; } float IKillable.currentHealth{ get; set; } void Awake(){ controls = GetComponent(); } public void Attach(){ name = "Player"; name += IsLocalPlayer ? ", Local" : ", Network"; if (IsLocalPlayer || !UnitIsNetworked()) { // PlayerManager.Player = gameObject; Debug.Log($"Player is set to {PlayerManager.Player.name}"); PlayerManager.RequestNewController(); GetComponent().AttachCamera(gameObject); } } public override void UnitStart(){ base.UnitStart(); Attach(); ((IKillable)this).IKillableInitialize(); } protected override void Update(){ base.Update(); GetComponent().DrawHealthDebug(); Debug.Log(PlayerManager.Player); } public void TakeDamage(DamageSource[] sources){ foreach (DamageSource source in sources) { TakeDamage(source); } } public void TakeDamage(DamageSource source){ ((IKillable)this).currentHealth -= source.damageDealt; if (((IKillable)this).currentHealth <= 0) { Kill(); } } public void Kill(){ throw new NotImplementedException(); } } }