Abstract, called when asking a developer whether there's anything that can be done to improve their working conditions through dialogue.
traits:registerNew({
id = "bookworm",
display = _T("BOOKWORM", "Bookworm"),
quad = "trait_bookworm",
selectableForPlayer = false,
discoveryLevel = 4,
experienceGainMultiplier = 1.1,
driveLossMultiplier = 1.1,
description = _T("BOOKWORM_DESCRIPTION", "Books provide a greater boost in experience gained, but loses drive faster than usual if placed in a room with no books or empty bookshelves."),
onEvent = function(self, target, event)
self:evaluateRoom(target, target:getRoom())
end,
fillSuggestionList = function(self, employee, list, dialogueObject)
local mult = employee:getSpecificDriveLossSpeedMultiplier(self.id)
if mult and mult ~= 1 then
table.insert(list, "developer_no_bookshelves_suggestion")
end
end,
evaluateRoom = function(self, target, roomObject)
local driveLossSpeedModifier = 1
if roomObject then
local found = false
local objects = roomObject:getObjectsOfType("bookshelf")
if objects then
for key, object in ipairs(objects) do
if #object:getStoredBooks() > 0 then
found = true
break
end
end
end
if not found then
driveLossSpeedModifier = self.driveLossMultiplier
end
end
target:setDriveLossSpeedMultiplier(self.id, driveLossSpeedModifier)
if driveLossSpeedModifier == 1 then
target:getAvatar():removeStatusIcon("no_books")
else
target:getAvatar():addStatusIcon("no_books")
end
end,
formatDescriptionText = function(self, descBox, employee, wrapWidth, font)
descBox:addSpaceToNextText(iconSpacing)
descBox:addText(_format(_T("BOOKWORM_AFFECTOR_1", "MULT% more experience from books"), "MULT", math.round((self.experienceGainMultiplier - 1) * 100, 1)), font, game.UI_COLORS.LIGHT_BLUE, 0, wrapWidth, "increase", 22, 22)
descBox:addText(_format(_T("BOOKWORM_AFFECTOR_2", "MULT% faster Drive loss when in room with no books"), "MULT", math.round((self.driveLossMultiplier - 1) * 100, 1)), font, game.UI_COLORS.RED, 0, wrapWidth, "decrease_red", 22, 22)
end,
onRoomChanged = function(self, target, roomObject)
self:evaluateRoom(target, roomObject)
end,
assignTrait = function(self, target)
target:setBookExperienceGainModifier(self.id, self.experienceGainMultiplier)
end})