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

Đang mở
#492 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp, unity
Lĩnh vực
game-dev

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
C#
Star
33
Fork
1
Merge trung bình
1 ngày 21 giờ
Pull request đã merge (30 ngày)
56

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Gothic-Unity-Project/Gothic-Unity

Tất cả issue của Gothic-Unity-Project/Gothic-Unity

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.