added: full logic and ability for downing and picking up allies
This commit is contained in:
@@ -24,7 +24,7 @@ namespace Reset.Core {
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute(){
|
||||
try {
|
||||
agent.SetTrigger("trigger");
|
||||
agent.SetTrigger(trigger.value);
|
||||
} catch (Exception e) {
|
||||
Debug.LogError($"Did not set Network Animator trigger <i>{trigger.name}</i> on <b>{(agent == null ? null : agent.name)}</b>: {e.Message}");
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
|
||||
@@ -6,3 +6,4 @@ public interface IInteractable{
|
||||
public void CancelInteract();
|
||||
public void OnObserverDetected(EnvironmentObserver observer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user