maint: moving around methods to work better with Unit/Player/Enemy classes
This commit is contained in:
@@ -1,4 +1,50 @@
|
||||
using Unity.Netcode;
|
||||
using System.Collections;
|
||||
using Reset;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
|
||||
public class Unit : NetworkBehaviour{
|
||||
public virtual void Start(){
|
||||
UnitStart();
|
||||
}
|
||||
|
||||
public virtual void UnitStart(){
|
||||
OnlineStart();
|
||||
}
|
||||
|
||||
protected void OnlineStart(){
|
||||
if (!NetworkManager.Singleton.IsConnectedClient && !NetworkManager.Singleton.IsHost) {
|
||||
Attach();
|
||||
} else {
|
||||
StartCoroutine(WaitForOnline());
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator WaitForOnline(){
|
||||
while (!NetworkManager.Singleton.didAwake) {
|
||||
Debug.Log("waiting");
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// Debug.Log($"{IsHost}, {IsClient}, {IsLocalPlayer}");
|
||||
if (IsLocalPlayer){
|
||||
GameManager.Player = gameObject;
|
||||
Attach();
|
||||
}
|
||||
}
|
||||
|
||||
public void Attach(){
|
||||
if (GameManager.Player == gameObject){
|
||||
GameManager.RequestNewController();
|
||||
GetComponent<LockOnManager>().AttachCamera(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
void Update(){
|
||||
|
||||
}
|
||||
|
||||
protected override void OnNetworkPostSpawn(){
|
||||
// GetComponent<LockOnManager>().AttachCamera(gameObject);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user