4.0 KiB
4.0 KiB
| name | description |
|---|---|
| weapon-development | Develop and extend the VampireLike weapon system. Use when creating new weapons, updating weapon state machines, changing target selection/effects/data parsing, or integrating weapon behavior with shop, inventory, and entity flow. |
Weapon Development
Quick Start
- Read full baseline spec:
./references/WeaponDevelopmentSkill.md. - Confirm change scope:
- weapon runtime (
WeaponBase, concrete weapons) - state flow (
Idle,Check_OutRange,Check_InRange,Attack) - target selector (
ITargetSelector,TargetSelectorType) - effect layer (
IWeaponAttackEffect) - data contract (
DRWeapon,WeaponData,ParamsData)
- weapon runtime (
- Keep behavior compatibility with current gameplay loop, shop flow, inventory flow, and UI/event chain.
Source Map
- Weapon base:
../../Assets/GameMain/Scripts/Entity/EntityLogic/Weapon/WeaponBase.cs
- Existing weapons:
../../Assets/GameMain/Scripts/Entity/EntityLogic/Weapon/WeaponKnife/../../Assets/GameMain/Scripts/Entity/EntityLogic/Weapon/WeaponHandgun/../../Assets/GameMain/Scripts/Entity/EntityLogic/Weapon/WeaponSlash/../../Assets/GameMain/Scripts/Entity/EntityLogic/Weapon/WeaponLightning/
- Selectors:
../../Assets/GameMain/Scripts/Entity/EntityLogic/Weapon/TargetSelector/
- Attack effects:
../../Assets/GameMain/Scripts/Entity/EntityLogic/Weapon/AttackEffects/
- Weapon data:
../../Assets/GameMain/Scripts/Entity/EntityData/Weapon/
- Weapon table:
../../Assets/GameMain/DataTables/Weapon.txt
- Data row:
../../Assets/GameMain/Scripts/DataTable/DRWeapon.cs
- Shop integration:
../../Assets/GameMain/Scripts/UI/GameScene/UseCase/ShopFormUseCase.cs
- Entity show flow:
../../Assets/GameMain/Scripts/Entity/EntityExtension.cs
Non-Negotiable Invariants
- Do not duplicate logic already owned by
WeaponBase. - Keep state transitions explicit and non-blocking.
- Keep cooldown accumulation valid even when no target is found.
- Keep attack logic and visual effect logic decoupled.
- Parse weapon-specific parameters into strong-typed
ParamsDataat data initialization time. - Treat
Weapon.txtParamsas a JSON object column; empty params must use{}. - Preserve compatibility with shop/inventory/UI refresh flow.
Change Recipes
Add a New Weapon
- Extend
WeaponTypewithout reordering existing enum values. - Add
WeaponXxxData : WeaponDataandWeaponXxxParamsDatafor weapon-specific parameters. - Parse
ParamsJsonthroughParseParams<TParams>()inside the weapon data constructor. - Add
WeaponXxx : WeaponBaseand implement only weapon-specific behavior. - Build state files under
Weapon/WeaponXxx/with partial class layout. - Register display/data mapping path so
ShowWeaponand shop purchase can instantiate correctly.
Add or Update a Target Selector
- Implement
ITargetSelector. - Update
TargetSelectorType. - Register creation in
WeaponBase.CreateSelector. - Validate target semantics with current-health/runtime-health rules where applicable.
Add or Update Attack Effect
- Implement
IWeaponAttackEffect. - Trigger effect from weapon attack state only.
- Keep damage resolution outside effect code.
Add or Update Weapon Parameters
- Update
Weapon.txtParamsJSON object. - Add or update the corresponding
WeaponXxxParamsDatafields. - Keep key names aligned with
ParamsDataproperty names. - Read values from
ParamsDatain weapon initialization, not by manual string parsing in runtime logic.
Validation Checklist
- Weapon can be shown, attached, and updated without exceptions.
- State machine does not stall across target loss/reacquire.
- Cooldown and range checks match design expectation.
- Damage path and effect path remain decoupled.
ParamsDatamatches table content and default fallback behavior.- UI/shop/inventory interactions stay stable after the change.
- Update
./references/WeaponDevelopmentSkill.mdif contracts or recommended patterns changed.