Restructure for publishing to Steam Workshop

- Add a preview image for Steam Workshop
This commit is contained in:
Nettika 2023-05-02 18:07:05 -07:00
parent 59f6e20a31
commit fbe28923cf
8 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,142 @@
local function adjustFoodNotPicky(item)
-- Cancel out any negative effects
if item:getUnhappyChange() > 0 then
item:setUnhappyChange(item:getUnhappyChangeUnmodified() - item:getUnhappyChange())
end
if item:getBoredomChange() > 0 then
item:setBoredomChange(item:getBoredomChangeUnmodified() - item:getBoredomChange())
end
end
local function adjustFoodVeryPicky(item)
local unhappyChange = item:getUnhappyChangeUnmodified()
local boredomChange = item:getBoredomChangeUnmodified()
-- Increase existng negative effects by 50%
if item:getUnhappyChange() > 0 then
unhappyChange = unhappyChange + item:getUnhappyChange() * 0.5
end
if item:getBoredomChange() > 0 then
boredomChange = boredomChange + item:getBoredomChange() * 0.5
end
-- Microwaved food is dull
if item:isCookedInMicrowave() then
boredomChange = boredomChange + 10
end
-- Uncooked food which ought to be cooked is disgusting
if item:isCookable() and not item:isCooked() then
unhappyChange = unhappyChange + 10
end
-- Canned food is disgusting
if item:getEatType() == "can" then
unhappyChange = unhappyChange + 10
end
-- Adjust food groups
local foodGroupAdjustments = {
["Candy"] = 15,
["SoftDrink"] = 10,
["Sugar"] = 10,
["Wine"] = -10,
}
if foodGroupAdjustments[item:getFoodType()] then
unhappyChange = unhappyChange + foodGroupAdjustments[item:getFoodType()]
end
-- Adjust specific foods
local foodAdjustments = {
["BakingSoda"] = 20,
["Butter"] = 10,
["Candycane"] = 5,
["Cereal"] = 10,
["ChickenFried"] = 10,
["ChocoCakes"] = 15,
["CocoaPowder"] = 10,
["CookiesSugar"] = 5,
["Corndog"] = 10,
["Cornflour"] = 20,
["Crisps"] = 5,
["Crisps2"] = 5,
["Crisps3"] = 5,
["Crisps4"] = 5,
["FishFried"] = 10,
["GravyMix"] = 20,
["Gum"] = 10,
["HiHis"] = 15,
["Icecream"] = 10,
["JuiceBox"] = 10,
["Lollipop"] = 15,
["Macandcheese"] = 20,
["MintCandy"] = 15,
["OystersFried"] = 10,
["PancakeMix"] = 20,
["Plonkies"] = 15,
["Popcorn"] = 5,
["Processedcheese"] = 5,
["QuaggaCakes"] = 15,
["RefriedBeans"] = 5,
["Smore"] = 10,
["SnoGlobes"] = 15,
["TofuFried"] = 10,
}
if foodAdjustments[item:getType()] then
unhappyChange = unhappyChange + foodAdjustments[item:getType()]
end
item:setUnhappyChange(unhappyChange)
item:setBoredomChange(boredomChange)
end
local base_tooltip_render = ISToolTipInv.render
function ISToolTipInv:render()
local origUnhappyChange
local origBoredomChange
if self.item:IsFood() then
origUnhappyChange = self.item:getUnhappyChangeUnmodified()
origBoredomChange = self.item:getBoredomChangeUnmodified()
-- Adjust food effects based on traits
local traits = getPlayer():getTraits()
if traits:contains("NotAPickyEater") then
adjustFoodNotPicky(self.item)
elseif traits:contains("RefinedPalate") then
adjustFoodVeryPicky(self.item)
end
end
-- Call original function
base_tooltip_render(self)
if self.item:IsFood() then
-- Reset food effects
self.item:setUnhappyChange(origUnhappyChange)
self.item:setBoredomChange(origBoredomChange)
end
end
local base_perform = ISEatFoodAction.perform
function ISEatFoodAction:perform()
local origUnhappyChange = self.item:getUnhappyChangeUnmodified()
local origBoredomChange = self.item:getBoredomChangeUnmodified()
-- Adjust food effects based on traits
local traits = getPlayer():getTraits()
if traits:contains("NotAPickyEater") then
adjustFoodNotPicky(self.item)
elseif traits:contains("RefiendPalate") then
adjustFoodVeryPicky(self.item)
end
-- Call original function
base_perform(self)
-- Reset food effects
self.item:setUnhappyChange(origUnhappyChange)
self.item:setBoredomChange(origBoredomChange)
end