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

Reduce GetBlueprint() calls in weapons #3193

Merged
merged 2 commits into from Nov 19, 2020

Conversation

speed2CZ
Copy link
Member

@speed2CZ speed2CZ commented Nov 5, 2020

Some were pretty obvious, just save the first call in a local variable and reuse.
Then saving some values directly in the weapon table and reusing them.

Some were pretty obvious, just save the first call in a local variable and reuse.
Then saving some values directly in the weapon table and reusing them.
@speed2CZ speed2CZ added the area: sim Area that is affected by the Simulation of the Game label Nov 5, 2020
Copy link
Collaborator

@KionX KionX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error('Error on rackbones ' .. self.unit.UnitId)

Can delete it as it is checked in OnCreate

Copy link
Collaborator

@HUSSAR-mtrela HUSSAR-mtrela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@speed2CZ this is a good implement but there are a few small changes that should be done in this PR.

lua/cybranweapons.lua Show resolved Hide resolved
self.bpRateOfFire = bp.RateOfFire
self.EnergyRequired = bp.EnergyRequired
self.EnergyDrainPerSecond = bp.EnergyDrainPerSecond
self.WeaponUnpacks = bp.WeaponUnpacks
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting these variables are not needed if you make this change in OnCreate function:
self.bp = self:GetBlueprint()
then rest of the code can access above variables and many more directly from blueprint table like this:
self.bp.RateOfFire -- instead of self.bpRateOfFire
self.bp.EnergyRequired -- instead of self.EnergyRequired

Already done in OnCreate
@speed2CZ speed2CZ added this to the 3718 milestone Nov 19, 2020
@speed2CZ speed2CZ merged commit 5936ac3 into FAForever:deploy/fafdevelop Nov 19, 2020
@shalkya shalkya modified the milestones: 3720, 3718 Dec 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: sim Area that is affected by the Simulation of the Game
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants