public static void Postfix(ref bool __result, SwimInSchool __instance, IEcoTarget target) { if (__instance.gameObject == target.GetGameObject()) { __result = false; } }
void SetCurrentTarget(IEcoTarget newTarget) { currentTarget = newTarget; if (newTarget != null && newTarget.GetGameObject() != null) { swimBehaviour.SwimTo(currentTarget.GetPosition(), swimVelocity); } }
private bool IsValidTarget(IEcoTarget target) { if (Random.value > 0.75f) { return(false); } if (target == null || target.GetGameObject() == null) { return(false); } return(Vector3.Distance(transform.position, target.GetPosition()) < 35f); }
public static void Postfix(AggressiveWhenSeeTarget __instance, ref GameObject __result) { int maxSearchRings = __instance.maxSearchRings; // Not the exploding fish, those are actually more dangerous hiding in ambush if (CraftData.GetTechType(__instance.gameObject) == TechType.Crash) { DeathRun.crashFishSemaphore = true; } else if (Config.DEATHRUN.Equals(DeathRun.config.creatureAggression) || Config.EXORBITANT.Equals(DeathRun.config.creatureAggression)) { if (DayNightCycle.main.timePassedAsFloat >= DeathRun.FULL_AGGRESSION) { maxSearchRings *= 3; //BR// Triple aggression search after 40 minutes } else if (DayNightCycle.main.timePassedAsFloat >= DeathRun.MORE_AGGRESSION) { maxSearchRings *= 2; //BR// Double aggression search after 20 minutes } } else if (Config.HARD.Equals(DeathRun.config.creatureAggression)) { if (DayNightCycle.main.timePassedAsFloat > DeathRun.MORE_AGGRESSION) { maxSearchRings += 1; //BR// One extra aggression ring after 20 minutes } } if (Ocean.main.GetDepthOf(Player.main.gameObject) <= 5) { if (maxSearchRings > __instance.maxSearchRings + 1) { maxSearchRings = __instance.maxSearchRings + 1; } } IEcoTarget ecoTarget = EcoRegionManager.main.FindNearestTarget(__instance.targetType, __instance.transform.position, __instance.isTargetValidFilter, maxSearchRings); if (ecoTarget == null) { __result = null; } else { __result = ecoTarget.GetGameObject(); } DeathRun.crashFishSemaphore = false; }
private void UpdateShinyTarget() { GameObject gameObject = null; if (EcoRegionManager.main != null) { IEcoTarget ecoTarget = EcoRegionManager.main.FindNearestTarget(EcoTargetType.Shiny, base.transform.position, this.isTargetValidFilter, 1); if (ecoTarget != null) { gameObject = ecoTarget.GetGameObject(); //Debug.DrawLine(base.transform.position, ecoTarget.GetPosition(), Color.red, 2f); } else { gameObject = null; } } if (gameObject) { Vector3 direction = gameObject.transform.position - base.transform.position; float num = direction.magnitude - 0.5f; if (num > 0f && Physics.Raycast(base.transform.position, direction, num, Voxeland.GetTerrainLayerMask())) { gameObject = null; } } if (this.shinyTarget != gameObject && gameObject != null && gameObject.GetComponent <Rigidbody>() != null && gameObject.GetComponent <Pickupable>() != null) { if (this.shinyTarget != null) { if ((gameObject.transform.position - base.transform.position).magnitude > (this.shinyTarget.transform.position - base.transform.position).magnitude) { this.DropShinyTarget(); this.shinyTarget = gameObject; return; } } else { this.shinyTarget = gameObject; } } }
bool TrySearchForFood(out IEcoTarget result) { result = null; IEcoTarget specialEdible = EcoRegionManager.main.FindNearestTarget(QPatch.clownPincherSpecialEdible, transform.position, targetFilter, 1); if (specialEdible != null && specialEdible.GetGameObject() != null) { result = specialEdible; return(true); } IEcoTarget deadMeat = EcoRegionManager.main.FindNearestTarget(EcoTargetType.DeadMeat, transform.position, targetFilter, 1); if (deadMeat != null && deadMeat.GetGameObject() != null) { result = deadMeat; return(true); } return(false); }
public override float Evaluate(Creature creature) { if (frozen) { return(0f); } IEcoTarget closestTarget = EcoRegionManager.main.FindNearestTarget(targetType, transform.position, null, 1); if (closestTarget != null && closestTarget.GetGameObject() != null) { if (Vector3.Distance(closestTarget.GetPosition(), transform.position) < maxReactDistance) { performingAction = true; timeStopAction = Time.time + actionLength; if (lastScare) { lastScare.lastScarePosition = closestTarget.GetPosition(); } } } if (performingAction) { if (Time.time > timeStopAction) { performingAction = false; } } if (performingAction) { return(evaluatePriority); } else { return(0f); } }
public static bool Prefix(MoveTowardsTarget __instance) { float aggressionMultiplier; int aggressionRadius; if (CraftData.GetTechType(__instance.gameObject) == TechType.Crash) { return(true); // Explody ambush fish just runs normal method } if (Player.main.precursorOutOfWater || !Player.main.IsUnderwater() || PrecursorMoonPoolTrigger.inMoonpool || (Ocean.main.GetDepthOf(Player.main.gameObject) < 5)) { return(true); } Vehicle veh = Player.main.currentMountedVehicle; if (veh != null) { if (veh.precursorOutOfWater) { return(true); } } //BR// Adjust aggression levels if (Config.DEATHRUN.Equals(DeathRun.config.creatureAggression) || Config.EXORBITANT.Equals(DeathRun.config.creatureAggression)) { if (DayNightCycle.main.timePassedAsFloat > DeathRun.FULL_AGGRESSION) { aggressionMultiplier = 4; aggressionRadius = 6; } else if (DayNightCycle.main.timePassedAsFloat > DeathRun.MORE_AGGRESSION) { aggressionMultiplier = 2; aggressionRadius = 3; } else { return(true); } } else if (Config.HARD.Equals(DeathRun.config.creatureAggression) && (DayNightCycle.main.timePassedAsFloat > DeathRun.MORE_AGGRESSION)) { aggressionMultiplier = 2; aggressionRadius = 3; } else { return(true); // Just run normal method } ProfilingUtils.BeginSample("UpdateCurrentTarget"); if (EcoRegionManager.main != null && (Mathf.Approximately(__instance.requiredAggression, 0f) || __instance.creature.Aggression.Value * aggressionMultiplier >= __instance.requiredAggression)) { IEcoTarget ecoTarget = EcoRegionManager.main.FindNearestTarget(__instance.targetType, __instance.transform.position, __instance.isTargetValidFilter, aggressionRadius); if (ecoTarget != null) { __instance.currentTarget = ecoTarget; } else { __instance.currentTarget = null; } } ProfilingUtils.EndSample(null); return(false); }
public static void PostFix(EcoRegion __instance, EcoTargetType type, Vector3 wsPos, EcoRegion.TargetFilter isTargetValid, ref float bestDist, ref IEcoTarget best) { if (DeathRun.crashFishSemaphore) { return; } ProfilingUtils.BeginSample("EcoRegion.FindNearestTarget"); __instance.timeStamp = Time.time; System.Collections.Generic.HashSet <IEcoTarget> hashSet; if (!__instance.ecoTargets.TryGetValue((int)type, out hashSet)) { ProfilingUtils.EndSample(null); return; } float num = float.MaxValue; foreach (IEcoTarget ecoTarget in hashSet) { if (ecoTarget != null && !ecoTarget.Equals(null)) { float sqrMagnitude = (wsPos - ecoTarget.GetPosition()).sqrMagnitude; if (((ecoTarget.GetGameObject() == Player.main.gameObject) && !Player.main.IsInside() && Player.main.IsUnderwater() && !Player.main.precursorOutOfWater) || (ecoTarget.GetGameObject().GetComponent <Vehicle>() && (ecoTarget.GetGameObject().GetComponent <Vehicle>() == Player.main.currentMountedVehicle)) && !Player.main.currentMountedVehicle.precursorOutOfWater) { bool feeding = false; if (ecoTarget.GetGameObject() == Player.main.gameObject) { Pickupable held = Inventory.main.GetHeld(); if (held != null && (held.GetTechType() == TechType.Peeper)) { feeding = true; } } float depth = Ocean.main.GetDepthOf(ecoTarget.GetGameObject()); if ((depth > 5) && !feeding) { if (Config.DEATHRUN.Equals(DeathRun.config.creatureAggression) || Config.EXORBITANT.Equals(DeathRun.config.creatureAggression)) { if (DayNightCycle.main.timePassedAsFloat >= DeathRun.FULL_AGGRESSION) { sqrMagnitude = 1; //BR// Player appears very close! (i.e. attractive target) } else if (DayNightCycle.main.timePassedAsFloat >= DeathRun.MORE_AGGRESSION) { sqrMagnitude /= 4; } else { sqrMagnitude /= 2; } } else if (Config.HARD.Equals(DeathRun.config.creatureAggression)) { if (DayNightCycle.main.timePassedAsFloat >= DeathRun.FULL_AGGRESSION) { sqrMagnitude /= 3; //BR// Player appears closer! (i.e. attractive target) } else if (DayNightCycle.main.timePassedAsFloat >= DeathRun.MORE_AGGRESSION) { sqrMagnitude /= 2; } } } } if (sqrMagnitude < num && (isTargetValid == null || isTargetValid(ecoTarget))) { best = ecoTarget; num = sqrMagnitude; } } } if (best != null) { bestDist = Mathf.Sqrt(num); } ProfilingUtils.EndSample(null); }
public static bool PreFix(EcoTargetType type, Vector3 wsPos, EcoRegion.TargetFilter isTargetValid, ref float bestDist, ref IEcoTarget best) { // Explody fish runs regular code - everybody else runs postfix return(DeathRun.crashFishSemaphore); }
private bool IsTargetValid(IEcoTarget target) { return(target.GetGameObject().GetComponentInParent <Player>() == null && (target.GetPosition() - this.creature.leashPosition).sqrMagnitude > 64f); }