Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add attack strength indicator under crossbar when recharging (the small sword icon) #204

Open
stackotter opened this issue Jun 8, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@stackotter
Copy link
Owner

Not strictly necessary for game play, but it'd be nice to have and I reckon it'd definitely make things feel more polished. This should make a relatively friendly first issue so I've included an overview of the steps below,

  1. Create a new PlayerAttackStrength component in Sources/Core/Sources/ECS/Components. This component should just store a ticksSinceLastReset property which stores the tick number in which the player last did an action that reset their attack strength (e.g. switching hot bar slots, left clicking an entity or nothing, cancelling breaking a block in survival; not sure if there are any others)
  2. Add an instance of that component as a property in Sources/Core/Sources/Player/Player.swift (and remember to add the component to the createEntity call in Player.add(to:))
  3. Update PlayerInputSystem and PlayerBlockBreakingSystem to reset ticksSinceLastReset whenever an action is performed that should reset the player's attack strength. Remember to increment this values every tick as well (do it before anything resets it so that the reset value doesn't immediately get incremented).
  4. Add two new icons to Sources/Core/Sources/GUI/GUISprite.swift; attackStrengthIndicatorForeground and attackStrengthIndicatorBackground. To get the positions and sizes, open ~/Library/Application Support/dev.stackotter.delta-client/assets/minecraft/textures/gui/icons.png in Preview and measure by making selections.
  5. Add a currentAttackStrengthMultiplier(for item: Item, factor: Float) -> Float function which computes Float(ticksSinceLastReset + factor) / Float(item.properties?.toolProperties?.speed ?? 4)
  6. Update Sources/Core/Sources/GUI/InGameGUI.swift to display the attack strength indicator under the crosshair (you should be able to make use of InGameGUI.continuousMeter)

If you need any help feel free to ask on the Discord server!

@stackotter stackotter added enhancement New feature or request good first issue Good for newcomers labels Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant