public bool Seduce(RabbitAI mate) { if (!m_DesiredMate || (m_DesiredMate.Apperance <= mate.Apperance && !m_DesiredMate.IsInterestedIn(this))) { m_DesiredMate = mate; } return(m_DesiredMate == mate); }
protected override void Mate() { if (EvaluateNeeds()) { var exists = m_ActionsInterests.FindIndex(x => (BaseAIOrder.BaseActions)x.Action == BaseAIOrder.BaseActions.Mate); if (exists < 0) { if (IsMale) { m_MatingState = RabbitMatingState.MaleLooking; } else { m_MatingState = RabbitMatingState.FemaleLooking; } m_ActionsInterests.Add(m_ActionCurrent); } m_DesiredMate = null; m_CurrentTarget = null; m_ActionCurrent = null; return; } if (IsSatisfied) { m_DesiredMate = null; m_CurrentTarget = null; m_ActionCurrent = null; return; } if (m_DesiredMate) { if (!m_DesiredMate.IsSatisfied) { var dist = Vector3.Distance(transform.position, m_DesiredMate.transform.position); if (dist < m_Personality.NeedDetection / 2f) { if (m_DesiredMate.Seduce(this)) { if (dist < .5f) { m_DesiredMate.MakeBaby(this); MakeBaby(m_DesiredMate); m_DesiredMate = null; m_CurrentTarget = null; m_ActionCurrent = null; return; } } else { m_DesiredMate = null; m_CurrentTarget = null; return; } } else { if (m_CurrentTarget == null) { SetNavmeshTarget(m_DesiredMate.transform); } } } else { m_DesiredMate = null; m_CurrentTarget = null; } } else if (m_CurrentTarget == null) { int amount = Physics.OverlapSphereNonAlloc(transform.position, m_Personality.NeedDetection, m_NonAllocResults, 1 << gameObject.layer); var DesiredState = m_MatingState == RabbitMatingState.MaleLooking ? RabbitMatingState.FemaleLooking : RabbitMatingState.MaleLooking; int index = -1; float max = 0; RabbitAI mateCandidate = null; for (int i = 0; i < amount; i++) { mateCandidate = m_NonAllocResults[i].GetComponent <RabbitAI>(); if (!mateCandidate || mateCandidate.MatingState != DesiredState) { continue; } var matevalue = mateCandidate.Apperance + (mateCandidate.IsInterestedIn(this) ? .4f : 0f) + (mateCandidate.IsAvailable ? .2f : 0f); if (matevalue >= max) { max = matevalue; index = i; } } if (index < 0) { WanderRandomDirection(m_Personality.NeedDetection); return; } m_DesiredMate = mateCandidate; SetNavmeshTarget(m_NonAllocResults[index].transform); } }