Upload from upload_mods.ps1

This commit is contained in:
Nathaniel Cosford
2025-06-04 16:44:53 +09:30
commit f1fbbe67bb
1722 changed files with 165268 additions and 0 deletions

View File

@@ -0,0 +1,134 @@
using GamePath;
using System.Collections.Generic;
using System.Runtime.Remoting.Messaging;
using UnityEngine;
public class EAIFollowPlayer : EAIApproachAndAttackTarget
{
private readonly List<Entity> NearbyEntities = new List<Entity>();
private EntityAlive entityTarget;
private Vector3 entityTargetPos;
private Vector3 entityTargetVel;
public bool isTargetToEat;
private bool isEating;
private float homeTimeout;
private bool hasHome;
private bool isGoingHome;
private int pathCounter;
private float chaseTimeMax;
private int relocateTicks;
private int attackTimeout;
public override bool CanExecute()
{
return true;
}
public override void Start()
{
if (entityTarget != null)
{
this.entityTargetPos = this.entityTarget.position;
this.isTargetToEat = this.entityTarget.IsDead();
}
this.entityTargetVel = Vector3.zero;
this.isEating = false;
this.theEntity.IsEating = false;
this.homeTimeout = (this.theEntity.IsSleeper ? 90f : this.chaseTimeMax);
this.hasHome = (this.homeTimeout > 0f);
this.isGoingHome = false;
if (this.theEntity.ChaseReturnLocation == Vector3.zero)
{
this.theEntity.ChaseReturnLocation = (this.theEntity.IsSleeper ? this.theEntity.SleeperSpawnPosition : this.theEntity.position);
}
this.pathCounter = 0;
this.relocateTicks = 0;
this.attackTimeout = 5;
}
public override void Update()
{
//Log.Out("EAIFollowPlayer-Update START");
// No entity, so no need to do anything.
if (entityTarget == null)
{
Log.Out("EAIFollowPlayer-Update entityTarget == null");
EntityPlayer closestPlayer = null;
float num = 200 * 200;
float num2 = float.MaxValue;
for (int i = this.theEntity.world.Players.list.Count - 1; i >= 0; i--)
{
EntityPlayer entityPlayer = this.theEntity.world.Players.list[i];
if (!entityPlayer.IsDead() && entityPlayer.Spawned)
{
//Log.Out("FOUND PLAYER: " + entityPlayer.EntityName);
float distanceSq = entityPlayer.GetDistanceSq(this.theEntity.position);
if (distanceSq < num2 && distanceSq <= num)
{
num2 = distanceSq;
closestPlayer = entityPlayer;
}
}
}
if (closestPlayer != null)
{
entityTarget = closestPlayer;
}
else
{
return;
}
}
else
{
entityTargetPos = entityTarget.position;
}
// Let the entity keep looking at you, otherwise it may just sping around.
theEntity.SetLookPosition(entityTargetPos);
theEntity.RotateTo(entityTargetPos.x, entityTargetPos.y + 2, entityTargetPos.z, 8f, 8f);
//Log.Out("EAIFollowPlayer-Update entityTargetPos: " + entityTargetPos);
var a = theEntity.position - entityTargetPos;
if (a.sqrMagnitude < 20f)
{
//Log.Out("EAIFollowPlayer-Update Entity is too close. Ending pathing.");
//DisplayLog("Entity is too close. Ending pathing.");
pathCounter = 0;
return;
}
theEntity.moveHelper.CalcIfUnreachablePos();
// if the entity is not calculating a path, check how many nodes are left, and reset the path counter if its too low.
if (!PathFinderThread.Instance.IsCalculatingPath(theEntity.entityId))
{
var path = theEntity.navigator.getPath();
if (path != null && path.NodeCountRemaining() <= 2)
pathCounter = 0;
}
if (--pathCounter <= 0 && !PathFinderThread.Instance.IsCalculatingPath(theEntity.entityId))
{
//DisplayLog(" Path Counter is 0: Finding new path to " + entityTargetPos);
// If its still not calculating a path, find a new path to the leader
pathCounter = 6 + theEntity.rand.RandomRange(10);
PathFinderThread.Instance.FindPath(theEntity, entityTarget.position, theEntity.GetMoveSpeedAggro(), true, this);
}
if (theEntity.Climbing)
{
//Log.Out("EAIFollowPlayer-Update Entity is climbing");
return;
}
// If there's no path, calculate one.
if (theEntity.navigator.noPathAndNotPlanningOne())
{
//DisplayLog("No Path and Not Planning One. Searching for new path to : " + entityTargetPos);
PathFinderThread.Instance.FindPath(theEntity, entityTarget.position, theEntity.GetMoveSpeedAggro(), true, this);
}
}
}