Archived on 2026-10-24. The Godot rewrite is cancelled. Migration decisions and work checklists below are withdrawn. Original claims, code examples, file paths, and completion statements have not all been revalidated. Use the current documentation and issue register for maintenance decisions.
Player System¶
Purpose¶
The player system controls character setup, movement, input, target tracking, weapons, damage/shields/death, stats, item collection, companions, and HUD-facing state.
Current Unity Implementation¶
Main scripts:
| Path | Script | Role |
|---|---|---|
Assets/Script/Game/Entities/Player/Core/Player.cs |
Player |
Player core: character application, movement, target list, damage, death, regen, effects. |
Assets/Script/Game/Entities/Player/Stats/PlayerModifier.cs |
PlayerModifier |
Base/shop/upgrade/temp stat calculation. |
Assets/Script/Game/Entities/Player/Weapons/PlayerWeapon.cs |
PlayerWeapon |
Aim, reload, firing, damage calculation, ability attack modifiers. |
Assets/Script/Game/Entities/Player/Combat/PlayerAttack.cs |
PlayerAttack |
Projectile/hitbox behavior. |
Assets/Script/Game/Entities/Player/Collectibles/PlayerCollectItem.cs |
PlayerCollectItem |
Magnet/collection list and item reward handling. |
Assets/Script/Game/Entities/Player/Presentation/StatusPanel.cs |
StatusPanel |
Player HUD stats, HP/stamina, reload/cooldown display. |
Assets/Script/Game/Entities/Player/Core/AbilityHolder.cs |
AbilityHolder |
Player ability state and behavior. |
Assets/Script/Shared/ScriptableObjects/Character.cs |
Character |
Character base data. |
Assets/Script/Game/GameSystem/Player/PlayerManager.cs |
PlayerManager |
Run XP/level and player array. |
Key Data¶
Character fields used by player setup:
id,charName,weapon,animator,icon,ability.- Base stats: health, stamina, stamina regen, dash stamina/speed/duration, crit damage/chance, movement speed, skill amp, damage taken, attack range, vampiric power/chance.
- Audio/UI/progression: footstep, portrait, tags, difficulty, unlock data, price.
Player key fields:
playerNumber.- Components:
modifier,abilityHolder,collectItem,weapons,abilityPanel. - Current resources:
CurrentHealthinherited fromEntity,currentStamina,potionAmount. - Targeting:
nearestEnemies,IsFindEnemy,LastHorizontalInput. - State:
IsInvulnerable,Speed, potion/stamina max flags.
PlayerModifier key stat groups:
- Base stats copied from character/weapon.
- Final stats recalculated from base + shop + upgrades + temporary ability modifiers.
- Bonus stats from upgrades.
- Shop stats from
GameSession.Instance.modifiers. - Ability-specific modifiers:
tacticalFireMultiplier,runandGunMultiplier,bloodThirstPower,meditateValue,stellarShieldSAMP, etc.
Runtime Flow¶
Character Setup¶
GameInitialization.PreparePlayer()activates selected player objects.Player.ApplyCharacter()instantiates selectedCharacter.weaponunder the weapon parent.- Weapon calls
SetWeaponInStartAfterSpawned. - Footstep sound and animator are assigned from the character asset.
PlayerModifier.SetupPlayer()copies base stats from character and weapon and reads shop modifiers fromGameSession.AbilityHolder.PlayerSettingsAbilityFirstTime()adds the character ability and initializes ability-specific starting objects.
Movement and Targeting¶
- Every
Player.Update()callsMovement, resource regen, feedback/effects, invulnerability timer, CC timer, and target update. InputManagement()reads joystick first, then keyboard axes.- Movement is normalized and applied to
Rigidbody2D.linearVelocityunless dashing. - Dash direction is prepared in
abilityHolder.dashForce. - Enemy target list is event-driven:
GameEvents.AddTargetadds hitpoints for spawned enemies.GameEvents.RemoveTargetremoves dead/despawned enemies.UpdateEnemyLocations()updates effective distance for every tracked hitpoint and sorts by distance.GetTargetByPriority()returns a hitpoint by priority or a cursor fallback outside the camera.
Weapon and Attack¶
PlayerWeapon.Update()updates UI, aims weapon at selected target, ticks reload/attack timers, and checks readiness.- Ready checks require:
- not dashing,
- not paused,
- target exists,
- target in range,
- not blocked by character exclusive weapon rules,
- ammo and reload are valid,
- attack speed timer expired.
FireWeapon()triggers animation/audio, runs ability hooks, spawns attack, and applies multishot.AttackModify()writes damage, crit result, player reference, spell amp, and many ability flags ontoPlayerAttack.PlayerAttack.OnTriggerEnter2D()applies damage and secondary effects.
Damage and Death¶
Player.TakeDamage() is very large. It handles:
- ProtoBarrier reflection and shield threshold.
- Emergency Barrier block/explosion.
- Stellar Shield block/explosion.
- Tidal Veil stack break.
- Reload Shield absorption.
- Damage reduction floor.
- Unique Constitution stamina conversion.
- Emergency shield prevention of lethal damage.
- Actual HP loss unless Last Stand is active.
- Thorn/ET armor reflection.
- Survival Fitness stamina.
- Adrenaline Rush, Rebuke, BloodThirst, FinalForm, FirstAid, FleeBoots, PanicFrenzy, ETArmor, Judgement, Jet Propulsion, Enrage, EmergencyShield triggers.
- Last Stand replacement death state.
- Invulnerability duration based on damage size.
- Death disables player and asks
GameManager.CheckGame().
Item Collection¶
ItemsfireCollectibleSpawned/CollectibleDisabled.PlayerCollectItemmaintains a list of collectibles.- Every frame, it checks distance to each collectible and calls
IsCollectingwhen within magnet radius. Items.Update()moves toward its target and triggers collection when close.PlayerCollectItem.ItemTrigger()handles reward by item type:- chest/boss chest enqueue reward,
- coin grants XP/soul and counters,
- potions restore HP/stamina or apply temporary ability flags/effects,
- gem grants random stat.
Dependencies¶
Playerdepends onGameManager,GameSession,GameEvents,InputManager,AbilityFunction,PoolManager,AudioResources,Game.Audio.PlayerModifierdepends onGameManager,GameSession,AbilityFunction, player weapon data, shop modifiers.PlayerWeapondepends onPlayer,PlayerModifier,AbilityHolder,PoolManager,AbilityFunction,GameManager.PlayerCollectItemdepends onItems,GameManager,AbilityFunction,GameEvents,Difficulty.
Problems / Risks¶
Playeris too broad: movement, targeting, damage, shields, resources, and feedback.Player.TakeDamage()contains many ability effects that should belong to damage/ability components.- Target sorting every frame can become expensive if there are many enemies and hitpoints.
ResetEnemyLocation()usesGameObject.FindGameObjectsWithTag.PlayerCollectItem.Update()checks every collectible every frame for each player.PlayerModifier.Update()recalculates final stats every frame.PlayerWeapon.AttackModify()is another large ability switch implemented as manyCheckAbilitybranches.PlayerAttackcarries many boolean effect flags, which makes combinations fragile.
Migration Notes for Godot¶
Preserve:
- One/two player support.
- Character base stats and weapon setup.
- Target-priority behavior.
- Dash/stamina/invulnerability rules.
- Stat formulas where player-facing balance depends on them.
- Item magnet and reward behavior.
- Shield/damage order, especially because it affects survivability.
Redesign:
Player
- owns high-level state and child components
PlayerMovement
- input and movement velocity
PlayerStats
- base stats, modifiers, final stat calculation
HealthComponent
- damage pipeline and death
TargetSensor
- event-driven enemy/hitpoint registry and priority lookup
WeaponController
- fire/reload/aim
AbilityRunner
- listens to player/weapon/damage events
CollectibleCollector
- magnet and pickup behavior
Do not copy:
- Damage ability effects embedded directly in
Player.TakeDamage. - Per-frame stat recalculation without dirty flags.
- Per-frame target sorting if a spatial query or throttled sorting can preserve behavior.
Open Questions¶
- Exact stat formula compatibility requirements for the rebuild.
- Whether target priority should consider enemy hitpoint size exactly as Unity does.
- Which player abilities are character-default versus upgrades.
- Unknown / needs manual confirmation.