added: full logic and ability for downing and picking up allies

This commit is contained in:
Chris
2025-10-20 16:36:23 -04:00
parent 021e664320
commit 0bb10a8f46
10 changed files with 489 additions and 64 deletions

View File

@@ -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}");
}

View File

@@ -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() {

View File

@@ -6,3 +6,4 @@ public interface IInteractable{
public void CancelInteract();
public void OnObserverDetected(EnvironmentObserver observer);
}