split Recruit()

This commit is contained in:
in0finite 2021-09-26 20:02:17 +02:00
parent 307552980b
commit 61f18fb3d1
5 changed files with 32 additions and 16 deletions

View file

@ -69,6 +69,10 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
{
}
protected internal virtual void OnRecruit(Ped recruiterPed)
{
}
protected internal virtual void OnDrawGizmosSelected()
{
}

View file

@ -227,6 +227,15 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
}
protected internal override void OnRecruit(Ped recruiterPed)
{
if (this.TargetPed == recruiterPed)
{
// unfollow
this.TargetPed = null;
}
}
bool IsMemberOfOurGroup(Ped ped)
{
if (this.TargetPed == null) // we are not part of any group

View file

@ -35,5 +35,18 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
_pedAI.StartEscaping();
}
protected internal override void OnRecruit(Ped recruiterPed)
{
this.HandleOnRecruit(recruiterPed);
}
public void HandleOnRecruit(Ped recruiterPed)
{
if (!_pedAI.PedestrianType.IsGangMember() && !_pedAI.PedestrianType.IsCriminal())
return;
_pedAI.StartFollowing(recruiterPed);
}
}
}

View file

@ -194,22 +194,7 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
public void Recruit(Ped recruiterPed)
{
if (this.Action == PedAIAction.Following)
{
if (this.TargetPed == recruiterPed)
{
// unfollow
this.TargetPed = null;
return;
}
}
else if (this.Action == PedAIAction.Idle || this.Action == PedAIAction.WalkingAround)
{
if (!this.PedestrianType.IsGangMember() && !this.PedestrianType.IsCriminal())
return;
this.StartFollowing(recruiterPed);
}
this.CurrentState.OnRecruit(recruiterPed);
}
private static PathNode GetNextPathNode(PathNode previousNode, PathNode currentNode)

View file

@ -76,5 +76,10 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
{
_pedAI.StateContainer.GetStateOrThrow<IdleState>().HandleOnMyPedDamaged(dmgInfo, dmgResult);
}
protected internal override void OnRecruit(Ped recruiterPed)
{
_pedAI.StateContainer.GetStateOrThrow<IdleState>().HandleOnRecruit(recruiterPed);
}
}
}