5.2 KiB
5.2 KiB
| name | description |
|---|---|
| simulation-development | Maintain and extend VampireLike SimulationWorld (P2 baseline). Use for Simulation data contracts, lifecycle sync, Job/Burst pipeline, collision settlement, and rollback-safe runtime switches. |
Simulation Development
Quick Start
- Read the design spec first:
./references/SimulationDevelopmentSkill.md. - If performance conclusions change, sync evidence to
../../docs/P2 Job System + Burst 落地.md. - Classify change scope before coding:
SimData/JobDatacontracts- lifecycle sync (
SimulationWorld.EntitySync) - Job/Burst execution pipeline (
SimulationWorld.EnemyJobs,SimulationWorld.ProjectileJobs) - collision query/settlement semantics
- presentation write-back (
SimulationWorld.Presentation)
- Decide rollback behavior up front:
UseSimulationMovementoff pathUseJobSimulationoff path
- Add/adjust both EditMode and PlayMode regression tests.
Source Map
- Simulation core:
../../Assets/GameMain/Scripts/Simulation/SimulationWorld.cs - Job data channel:
../../Assets/GameMain/Scripts/Simulation/SimulationWorld.JobDataChannel.cs - Enemy jobs:
../../Assets/GameMain/Scripts/Simulation/SimulationWorld.EnemyJobs.cs - Projectile jobs:
../../Assets/GameMain/Scripts/Simulation/SimulationWorld.ProjectileJobs.cs - Lifecycle sync:
../../Assets/GameMain/Scripts/Simulation/SimulationWorld.EntitySync.cs - Presentation sync:
../../Assets/GameMain/Scripts/Simulation/SimulationWorld.Presentation.cs - Target selection index:
../../Assets/GameMain/Scripts/Simulation/SimulationWorld.TargetSelectionSpatialIndex.cs - Tick context:
../../Assets/GameMain/Scripts/Simulation/SimulationTickContext.cs - Index binding:
../../Assets/GameMain/Scripts/Simulation/EntityBinding.cs - Battle entry:
../../Assets/GameMain/Scripts/Procedure/Game/GameStateBattle.cs - Battle state gate:
../../Assets/GameMain/Scripts/Procedure/Game/ProcedureGame.cs - Damage/collision utility:
../../Assets/GameMain/Scripts/Utility/AIUtility.cs - Global component init:
../../Assets/GameMain/Scripts/Base/GameEntry.Custom.cs - Enemy old path gate:
../../Assets/GameMain/Scripts/Entity/EntityLogic/Enemy/MeleeEnemy.cs../../Assets/GameMain/Scripts/Entity/EntityLogic/Enemy/RemoteEnemy.cs
- Regression tests:
../../Assets/Tests/Simulation/EditMode/SimulationWorldTickTests.cs../../Assets/Tests/Simulation/PlayMode/SimulationWorldPlayModeTests.cs
Non-Negotiable Invariants
- Maintain
EntityId <-> SimulationIndexconsistency. - Use swap-back removal (
move last -> remove last -> remap index). - Keep lifecycle registration/removal inside
EntitySyncevent flow; do not double-write containers from gameplay code. - Keep logic/presentation boundary:
- Simulation computes logical outputs.
- Presentation writes back
Transform.
- Keep A/B rollback path (
UseSimulationMovement/UseJobSimulation). SetUseSimulationMovementandSetUseJobSimulationmust not hot-switch duringBattle.- Keep area query snapshot semantics (
SourceWasActiveAtQueryTime) intact. - Keep dodge semantics using
Value(additive), notPercent. - Avoid new managed allocations in Tick hot paths.
Change Recipes
Add or Change SimData Fields
- Update target structs in
Simulation/SimData/and Job channel structs. - Populate defaults in
Create*InitialSimData/ lifecycle registration path. - Apply runtime updates in simulation stages.
- Consume visual fields in
Presentationonly. - Ensure backward compatibility when
UseSimulationMovementis off.
Extend Job/Burst Pipeline
- Keep deterministic stage ownership (Build/Schedule/Complete/Commit).
- Preserve state semantics; avoid UI/audio/effect side effects in simulation loops.
- Keep
ProfilerMarkercoverage for new or changed stages. - Keep hot paths data-driven (no direct
Transformreads/writes).
Modify Collision / Area Query Behavior
- Treat broad phase candidate generation and main-thread settlement as separate steps.
- Preserve
MaxTargetssemantics across player + enemy candidates. - If adding query metadata, flow it through:
- request buffer -> collision query input -> candidate -> settlement.
- Keep area-source snapshot behavior and avoid runtime-state race regressions.
Add or Adjust Runtime Switches
- Define exact effective timing (
Battleor out-of-Battle) before implementation. - For high-risk switches, enforce out-of-battle-only changes.
- Provide clear warning logs for ignored runtime switch attempts.
Validation Checklist
UseSimulationMovement = falseandtrueboth run correctly.UseJobSimulation = falseandtrueboth run correctly under simulation mode.- No duplicate registration or stale index after entity hide/destroy.
- Battle loop remains stable (
Battle -> LevelUp -> Shop -> Battle). - No new per-frame GC spikes in hot paths.
- Main flow has no new Error/Exception logs.
- Keep these regression tests green in both EditMode and PlayMode:
TickProjectiles_LimitsCandidatesToMaxTargets_IncludingPlayerCandidateSetUseSimulationAndJob_AreIgnored_WhenBattleStateIsActiveEnqueueAreaQuery_CapturesInactiveSourceSnapshot_WhenSourceEntityUnavailable
- Update
./references/SimulationDevelopmentSkill.mdwhen contracts, boundaries, or rules change.