change: ownership can now be be changed on objects
This commit is contained in:
@@ -32,6 +32,10 @@ namespace Reset.Units{
|
||||
}
|
||||
|
||||
public void TakeDamage(DamageSource source){
|
||||
if (UnitIsNetworked()) {
|
||||
TakeOwnershipRpc((source.source as GameObject).GetComponent<NetworkObject>().OwnerClientId);
|
||||
}
|
||||
|
||||
try {
|
||||
currentHealth -= source.damageDealt;
|
||||
|
||||
|
||||
@@ -13,28 +13,7 @@ namespace Reset.Units{
|
||||
UnitStart();
|
||||
}
|
||||
|
||||
public virtual async void UnitStart(){
|
||||
try {
|
||||
var netWaitResult = await WaitForNetwork();
|
||||
|
||||
if (netWaitResult) {
|
||||
|
||||
}
|
||||
|
||||
// OnlineStart();
|
||||
Debug.Log("Done");
|
||||
} catch {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> WaitForNetwork(){
|
||||
while (!NetworkManager.Singleton.IsConnectedClient) {
|
||||
await Awaitable.NextFrameAsync();
|
||||
}
|
||||
|
||||
return (NetworkManager.Singleton.IsConnectedClient);
|
||||
}
|
||||
public virtual void UnitStart(){ }
|
||||
|
||||
public bool UnitIsNetworked(){
|
||||
return NetworkManager.Singleton.IsConnectedClient || NetworkManager.Singleton.IsHost;
|
||||
@@ -54,8 +33,12 @@ namespace Reset.Units{
|
||||
if (GetComponent<IKillable>() != null) {
|
||||
GetComponent<IKillable>().DrawHealthDebug();
|
||||
}
|
||||
|
||||
UnitUpdate();
|
||||
}
|
||||
|
||||
public virtual void UnitUpdate(){ }
|
||||
|
||||
void UpdateGizmos(){
|
||||
string onlineStatus = "Not Online";
|
||||
Color onlineColor = Color.gray;
|
||||
@@ -73,8 +56,9 @@ namespace Reset.Units{
|
||||
Draw.ingame.Label2D(transform.position + Vector3.up * 2.5f, onlineStatus, onlineColor);
|
||||
}
|
||||
|
||||
protected override void OnNetworkPostSpawn(){
|
||||
// GetComponent<LockOnManager>().AttachCamera(gameObject);
|
||||
[Rpc(SendTo.Owner)]
|
||||
public void TakeOwnershipRpc(ulong clientID){
|
||||
GetComponent<NetworkObject>().ChangeOwnership(clientID);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user