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

More flexible Prev/Next weapon #38

Open
wisien92 opened this issue May 6, 2017 · 0 comments
Open

More flexible Prev/Next weapon #38

wisien92 opened this issue May 6, 2017 · 0 comments

Comments

@wisien92
Copy link

wisien92 commented May 6, 2017

While expanding the code I decided to add more slots for items (Meele firs aid etc.). Prev/Next code striked me as kinda strage, and I replaced it with:

ASWeapon* NextWeapon = Inventory[CurrentWeaponIndex + 1 < Inventory.Num() ? CurrentWeaponIndex + 1 : 0];

ASWeapon* PrevWeapon = Inventory[CurrentWeaponIndex - 1 >= 0 ? CurrentWeaponIndex - 1 : Inventory.Num() - 1];

I think it's easier to understand and you don't need to "touch" it in future (previous code had some issues with eg. 3 items in inventory).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant