Refactor: NPC perception rules out of AiHandler, split NpcAiService / NpcHelperService

Abierto
#492 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
csharp, unity
Área
game-dev

Línea de trabajo

Start with the design skill and the review findings A3 and A4 from split/09-perceptions; then trace perception handling across AiHandler, NpcAiService, and NpcHelperService. Map the proposed service responsibilities and Reflex registration before implementation. Done means the responsibilities are moved as described with no behavior change; the performance notes are optional.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

improvement

Follow-up from the review of split/09-perceptions (architecture-reviewer findings A3 + A4).

Problem

  • AiHandler (adapter, ~720 lines) decides AI rules: loop rate, daily-state check, CallStateEnd, looking away
    (ForgetHeroAfterLookingAway changes AttitudeTemp), PERC_MOVENPC, PERC_ASSESSBODY. None of it is testable
    without a scene, and following one perception means reading AiHandler, NpcAiService and NpcHelperService.
  • NpcAiService (~1,100 lines) and NpcHelperService (~620 lines) each took on a new responsibility: passive
    perception broadcast/delivery, the body search, sight lines through alpha-tested polygons, Wld_DetectItem.

Proposal

  • NpcPerceptionService (new): passive perception broadcast + delivery, ExecutePassivePerception,
    FindClosestSensedBody, and the body of ExecuteActivePerceptions (incl. PERC_MOVENPC, PERC_ASSESSBODY,
    looking away).
  • NpcSightDomain (new, owned by NpcHelperService): CanSee/CanSense, IsSightBlocked, see-through caches.
  • NpcAiService keeps the state lifecycle and also gets CallStateEnd, the loop-rate and daily-state checks.
  • AiHandler keeps only the Unity part: _npcPerceptionService.TickPerceptions(NpcData) and the state calls.
  • Wld_DetectItem and the item distances could move to a Wld_*/item service.

Plan with the design skill first (new service + Reflex registration), then implement. No behaviour change.

Related performance notes from the same review (can be done during the move):

  • FindClosestSensedBody walks the whole NpcCache with a raycast per candidate on every perception tick.
  • Wld_DetectItem walks the whole VobCache per call.
Lenguaje dominante
C#
Estrellas
33
Forks
1
Merge medio
1 d 21 h
PR fusionados (30 d)
56

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Gothic-Unity-Project/Gothic-Unity

Todos los issues de Gothic-Unity-Project/Gothic-Unity

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.