Skip to content

Commit

Permalink
Fix props with no reclaim values (#4777)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas committed Mar 4, 2023
1 parent 226548e commit b96b97c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lua/sim/Prop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,23 @@ Prop = Class(moho.prop_methods) {
---@return number energy to reclaim
---@return number mass to reclaim
GetReclaimCosts = function(self, reclaimer)
local maxValue = self.MaxMassReclaim
if self.MaxEnergyReclaim > maxValue then
maxValue = self.MaxEnergyReclaim
local maxMass = self.MaxMassReclaim or 0
local maxEnergy = self.MaxEnergyReclaim or 0
local timeReclaim = self.TimeReclaim or 0
local maxValue = maxMass
if maxEnergy > maxValue then
maxValue = maxEnergy
end

local time = self.TimeReclaim * (maxValue / reclaimer:GetBuildRate())
local time = (timeReclaim or 0) * (maxValue / reclaimer:GetBuildRate())
time = time / 10

-- prevent division by 0 when the prop has no value
if time < 0 then
time = 0.0001
end

return time, self.MaxEnergyReclaim, self.MaxMassReclaim
return time, maxEnergy, maxMass
end,

--- Split this prop into multiple sub-props, placing one at each of our bone locations.
Expand Down

0 comments on commit b96b97c

Please sign in to comment.