added: full logic and ability for downing and picking up allies
This commit is contained in:
@@ -27,32 +27,29 @@ namespace Reset.Units {
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
protected override void OnExecute(){
|
||||
Unit targetUnit = target.value.GetComponent<Unit>();
|
||||
|
||||
try {
|
||||
if (targetUnit != null) {
|
||||
if (target.value.GetComponent<Unit>().UnitIsNetworked()) {
|
||||
targetUnit.DoGraphEventRpc(eventToSend);
|
||||
} else {
|
||||
targetUnit.GetComponent<GraphOwner>().SendEvent("eventToSend");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debug.LogError($"Failed to send event {eventToSend} to {target}: {e.Message}");
|
||||
}
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate(){
|
||||
try {
|
||||
if (target.value.GetComponent<Unit>().UnitIsNetworked()) {
|
||||
ulong targetID = (target.value.GetComponent<NetworkObject>()).NetworkObjectId;
|
||||
|
||||
|
||||
SendEventRpc(agent.RpcTarget.Single(targetID, RpcTargetUse.Temp));
|
||||
} else {
|
||||
target.value.GetComponent<GraphOwner>().SendEvent("eventToSend");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debug.LogError($"Failed to send event {eventToSend} to {target}: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
[Rpc(SendTo.SpecifiedInParams)]
|
||||
void SendEventRpc(RpcParams rpcParams = default){
|
||||
target.value.GetComponent<GraphOwner>().SendEvent("eventToSend");
|
||||
Debug.Log("");
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user