public static void BasicWildLifeAI_DoNetwork(BasicWildLifeAI hook, WildlifeManager.LocalData localData) { object[] args = new object[] { hook, localData }; Method.Invoke("RustExtended.RustHook.BasicWildLifeAI_DoNetwork", args); }
public static bool BasicWildLifeAI_ManagedUpdate(BasicWildLifeAI hook, ulong millis, WildlifeManager.LocalData localData) { object[] args = new object[] { hook, millis, localData }; return(Method.Invoke("RustExtended.RustHook.BasicWildLifeAI_ManagedUpdate", args).AsBoolean); }
private void IOnAIMovement(BasicWildLifeAI ai, BaseAIMovement movement) { var nmMovement = movement as NavMeshMovement; if (!nmMovement) return; if (nmMovement._agent.pathStatus == NavMeshPathStatus.PathInvalid && ai.GetComponent<TakeDamage>().alive) { TakeDamage.KillSelf(ai.GetComponent<IDBase>()); Interface.Oxide.LogInfo($"{ai} was destroyed for having an invalid NavMeshPath"); } }
private int method_0() { int num = 0; BasicWildLifeAI[] array = UnityEngine.Object.FindObjectsOfType <BasicWildLifeAI>(); BasicWildLifeAI[] array2 = array; for (int i = 0; i < array2.Length; i++) { BasicWildLifeAI basicWildLifeAI = array2[i]; TakeDamage component = basicWildLifeAI.GetComponent <TakeDamage>(); if (!(component == null) && component.alive) { NavMeshMovement component2 = basicWildLifeAI.GetComponent <NavMeshMovement>(); if (component2 == null || component2._agent == null || component2._agent.pathStatus == NavMeshPathStatus.PathInvalid) { int num2 = WildlifeManager.Data.lifeInstances.IndexOf(basicWildLifeAI); if (num2 != -1 && num2 < WildlifeManager.Data.lifeInstanceCount) { if (component2 != null) { Helper.Log(string.Concat(new object[] { "WildLifeAI: Creature '", Helper.NiceName(basicWildLifeAI.gameObject.name), " at ", basicWildLifeAI.gameObject.transform.position, "' has been removed because creature without mesh agent." }), false); } else { Helper.Log(string.Concat(new object[] { "WildLifeAI: Creature '", Helper.NiceName(basicWildLifeAI.gameObject.name), " at ", basicWildLifeAI.gameObject.transform.position, "' has been removed because mesh agent have invalid path." }), false); } WildlifeManager.Data.lifeInstances.RemoveAt(num2); WildlifeManager.Data.lifeInstanceCount--; WildlifeManager.Data.thinkIterator = 0; NetCull.Destroy(basicWildLifeAI.gameObject); num++; } } } } return(num); }
public static void AnimalMovement(BaseAIMovement m, BasicWildLifeAI ai, ulong simMillis) { var movement = m as NavMeshMovement; if (!movement) { return; } bool IsAlive = ai.GetComponent <TakeDamage>().alive; if (movement._agent.pathStatus == NavMeshPathStatus.PathInvalid && IsAlive) { TakeDamage.KillSelf(ai.GetComponent <IDBase>()); Logger.LogDebug("[NavMesh] AI destroyed for having invalid path."); } }
public virtual void InitializeMovement(BasicWildLifeAI ai) { }
public virtual void DoMove(BasicWildLifeAI ai, ulong simMillis) { }
public static void OnAIKilled(BasicWildLifeAI BWAI, DamageEvent damage) { BWAI.ExitCurrentState(); BWAI.EnterState_Dead(); Facepunch.NetworkView networkView = BWAI.networkView; NetCull.RemoveRPCsByName(networkView, "GetNetworkUpdate"); object[] args = new object[] { BWAI._myTransform.position, damage.attacker.networkViewID }; networkView.RPC("ClientDeath", uLink.RPCMode.Others, args); if (beingDestroyed.Contains(damage.victim.idMain.gameObject)) NetCull.Destroy(damage.victim.idMain.gameObject); else BWAI.Invoke("DelayedDestroy", 90f); WildlifeManager.RemoveWildlifeInstance(BWAI); }
public static void BasicHurt(DamageEvent damage, BasicWildLifeAI BWAI) { try { bool b = false; try { if (damage.attacker.idMain is Character) { if (isPlayer(damage.attacker.idMain)) { b = hiddenList.Contains(damage.attacker.client.userID.ToString()); } } } catch { } if (((BWAI._state != 2) && (BWAI._state != 7)) && (damage.attacker.character != null) & !b) { BWAI.ExitCurrentState(); BWAI.EnterState_Flee(BWAI.transform.position + new Vector3(UnityEngine.Random.Range((float)-1f, (float)1f), 0f, UnityEngine.Random.Range((float)-1f, (float)1f))); } } catch (Exception ex) { Vars.conLog.Error("BH: " + ex.ToString()); } }
public static void BasicHearFootstep(Vector3 origin, BasicWildLifeAI BWAI) { try { bool b = false; try { foreach (PlayerClient pc in AllPlayerClients) { Character outChar; Character.FindByUser(pc.userID, out outChar); if (outChar != null && outChar.transform != null && outChar.transform.position != null && origin != null) { if (Vector3.Distance(outChar.transform.position, origin) < 1) { b = hiddenList.Contains(pc.userID.ToString()); } } } } catch (Exception ex2) { conLog.Error("BHFS #2: " + ex2.ToString()); } if (((BWAI._state != 2) && (BWAI._state != 7)) && BWAI.afraidOfFootsteps && !b) { BWAI.ExitCurrentState(); BWAI.EnterState_Flee(origin); } } catch (Exception ex) { Vars.conLog.Error("BHFS #1: " + ex.ToString()); } }