Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[-----------------------------------------------------------------------\\--
- :: PRIVATE ::
- --\\-----------------------------------------------------------------------]]--
- local tonumber, pairs, ipairs
- = tonumber, pairs, ipairs
- local translate, get_nearest_anomaly
- = game.translate_string, anomaly_holder.get_nearest_anomaly
- local insert, remove, rand
- = table.insert, table.remove, math.random
- local map, min, find, check, vec2tbl, tbl2vec
- = xs_utils.map, xs_utils.min, xs_utils.find, xs_utils.check, xs_utils.vec2tbl, xs_utils.tbl2vec
- local getScheduleManager, getSaveManager
- = xs_timers.getScheduleManager, xs_save.getSaveManager
- local TM_TIMER_PREFIX = "xs_at_" -- at for artifact transmutation
- -- use "treasure" instead or add a level_map to "artifact_indicator".
- local TM_MAPSPOT_TYPE = xs_game.IS_SOC and "artefact_location" or "artifact_indicator"
- -- TODO: make a custom PPE something like teleport but much faster/shorter.
- local TM_VFX_PPE = "teleport.ppe"
- local TM_VFX_UID = 2006
- -- TODO: add a sound to accompany the visual effect.
- local TM_SFX_SND = nil
- local m_tm
- -- TODO: Get rid of the next line, use something more general instead!
- local log = xs_game.IS_SOC and _G.log or _G.error_log
- --[[-----------------------------------------------------------------------\\--
- :: PUBLIC ::
- --\\-----------------------------------------------------------------------]]--
- __FILE__ = "xs_transmutation"
- -- TODO: add feature to have multiple result sections?
- class "TransmutationManager" (XsObj)
- --[[-------------------------------------------------------------------\\--
- :: Constructor/Destructor
- --\\-------------------------------------------------------------------]]--
- function TransmutationManager:__init() super("TransmutationManager")
- -- recipe infos
- self.recipes = {
- -- [1] = {
- -- READ-FROM-LTX:
- -- anomaly = string: a sub-string identifying the required anomaly section,
- -- source = string: the artifact source section,
- -- recipe = string: the info section required to attempt a trans.,
- -- result = string: the artifact to be spawned on a successful trans.,
- -- chance = table: the success and failure rates,
- -- delay = number: the time (in hours) until a trans. is finished,
- -- OPTIONAL:
- -- failure_artifact = string: if specified overturns the default failure-artifact,
- -- experiment_malus = number: if specified overturns the default experimentation malus,
- -- COMPUTED:
- -- id = number: a unique-id one per transmutation-set; valid range 1-math.huge,
- -- parent = number: the id of the parent of this transmutation,
- -- complex = boolean: true if there are multiple sources,
- -- }
- }
- -- active/pending transmutations (this table is persisted!)
- self.pending = {
- -- [1] = {
- -- id = number: timer or artifact id,
- -- sid = number: recipe source id (self.recipes[#].id),
- -- gvid = number: spawn game vertex id,
- -- lvid = number: spawn level vertex id,
- -- pos = table: spawn position,
- -- }
- }
- -- lookup table of source artifact sections; for faster execution
- self.sources = {}
- -- table to store temporary data when attempting a complex transmutation
- self.complex = nil
- -- {
- -- id = number: recipe.id,
- -- anomaly = game_object: anomaly,
- -- artifacts = table: list of artifacts inside the anomaly,
- -- numleft = number: how many more artifacts need to be thrown into the anomaly,
- -- recipes = table: list of self.recipes entries
- -- }
- local sprintf
- = string.format
- local trim, split, count, retain
- = xs_utils.trim, xs_utils.split, xs_utils.count, xs_utils.retain
- local max, clamp
- = xs_utils.max, xs_utils.clamp
- local trim2number = function (v, k)
- return tonumber(trim(v))
- end
- local INIS_TRANSMUTATIONS = "transmutation"
- local INIP_SECTIONS = "sections"
- local INIP_SECTIONPREFIX = "section_prefix"
- local INIP_TIMESPAN = "timespan"
- local INIP_PREFIX = "prefix"
- local INIP_FAILURE_ARTIFACT = "failure_artifact"
- local INIP_EXPERIMENT_MALUS = "experiment_malus"
- local INIP_ANOMALY = "anomaly"
- local INIP_SOURCE = "source"
- local INIP_INFO = "recipe"
- local INIP_RESULT = "result"
- local INIP_CHANCE = "chance"
- local INIP_DELAY = "delay"
- local path = [[scripts\xs_transmutation.ltx]]
- local ini = ini_file(path)
- check(ini:section_exist(INIS_TRANSMUTATIONS),
- "[TransmutationManager]: Missing section '%s'.",
- INIS_TRANSMUTATIONS)
- -- timespan
- local timespan = map(split(',', ini:r_string(INIS_TRANSMUTATIONS, INIP_TIMESPAN)), trim2number, ipairs)
- check(#timespan == 2,
- "[TransmutationManager]: Invalid property '%s' in section '%s'.",
- INIP_TIMESPAN, INIS_TRANSMUTATIONS)
- self.timespan = {
- min = min(timespan, nil, ipairs),
- max = max(timespan, nil, ipairs)
- }
- -- sections
- local sections = {}
- if xs_game.IS_SOC then
- sections = map(split(',', ini:r_string(INIS_TRANSMUTATIONS, INIP_SECTIONS) or '', trim))
- else
- local prefix = ini:r_string(INIS_TRANSMUTATIONS, INIP_SECTIONPREFIX)
- check(prefix:len() > 0,
- "[TransmutationManager]: Invalid property '%s' in section '%s'.",
- INIP_PREFIX, INIS_TRANSMUTATIONS)
- sections = retain(
- xs_fs.listSections(xs_fs.gamePath('$game_config$', path)),
- function (v, k)
- return v:find(prefix, 1, true) == 1
- end,
- ipairs)
- end
- -- Note: Log instead of crash here?
- check(#sections > 0,
- "[TransmutationManager]: No transmutation sections defined.")
- -- failure_artifact
- -- The default artifact spawned in case of an failed transmutation attempt.
- self.failure_artifact = ini:r_string(INIS_TRANSMUTATIONS, INIP_FAILURE_ARTIFACT)
- check(self.failure_artifact:len() > 0,
- "[TransmutationManager]: Invalid property '%s' in section '%s'.",
- INIP_FAILURE_ARTIFACT, INIS_TRANSMUTATIONS)
- -- experiment_malus
- -- The malus applied in case of performing an unknown transmutation.
- -- To disable this feature set the value to 1.0.
- self.experiment_malus = clamp(ini:r_float(INIS_TRANSMUTATIONS, INIP_EXPERIMENT_MALUS), 0.0, 1.0)
- -- now on to the real meat
- local id = 0
- for _, section in pairs(sections) do
- repeat
- id = id + 1
- if not ini:section_exist(section) then
- log(sprintf(
- "[TransmutationManager]: Section '%s' not found.",
- section))
- break
- end
- -- required properties
- local anomaly = ini:r_string(section, INIP_ANOMALY)
- local source = map(split(',', ini:r_string(section, INIP_SOURCE)), trim, ipairs)
- local recipe = ini:r_string(section, INIP_INFO)
- local result = ini:r_string(section, INIP_RESULT)
- local chance = map(split(',', ini:r_string(section, INIP_CHANCE)), trim2number, ipairs)
- local delay = ini:r_s32(section, INIP_DELAY)
- -- TODO: give a better (read accurate) error.
- if not anomaly or
- not source or
- not recipe or
- not result or
- not chance or
- not delay then
- log(sprintf(
- "[TransmutationManager]: Invalid transmutation section '%s'.",
- section))
- break
- end
- -- optional, can be nil
- local failure_artifact, experiment_malus
- if ini:line_exist(section, INIP_FAILURE_ARTIFACT) then
- failure_artifact = ini:r_string(section, INIP_FAILURE_ARTIFACT)
- check(failure_artifact:len() > 0,
- "[TransmutationManager]: Invalid property '%s' in section '%s'.",
- INIP_EXPERIMENT_MALUS, section)
- end
- if ini:line_exist(section, INIP_EXPERIMENT_MALUS) then
- experiment_malus = clamp(ini:r_float(section, INIP_EXPERIMENT_MALUS), 0.0, 1.0)
- -- no need if its the same as the base value; conserve resources man.
- if experiment_malus == self.experiment_malus then
- experiment_malus = nil
- end
- end
- -- check for duplicate results
- local index = find(self.recipes, result, function (v, k) return v.result end, ipairs)
- if index then
- log(sprintf(
- "[TransmutationManager]: Duplicate transmutation %s '%s' in section '%s'.",
- INIP_RESULT, result, section))
- break
- end
- -- check for duplicate sources
- index = find(self.recipes, source, function (v, k) return v.source end, ipairs)
- if index then
- log(sprintf(
- "[TransmutationManager]: Duplicate transmutation %s '%s' in section '%s'.",
- INIP_SOURCE, source, section))
- break
- end
- if #source == 1 then
- source = source[1]
- end
- if type(source) == "table" then
- for _, source in ipairs(source) do
- insert(self.recipes, {
- -- computed properties
- id = id,
- parent = 0,
- complex = true,
- -- parsed properties
- anomaly = anomaly,
- recipe = recipe,
- result = result,
- chance = chance,
- delay = delay,
- source = source,
- -- optional properties (its a table, so nil's wont be stored)
- failure_artifact = failure_artifact,
- experiment_malus = experiment_malus,
- })
- self.sources[source] = true
- end
- else
- insert(self.recipes, {
- -- computed properties
- id = id,
- parent = 0,
- complex = false,
- -- parsed properties
- anomaly = anomaly,
- recipe = recipe,
- result = result,
- chance = chance,
- delay = delay,
- source = source,
- -- optional properties
- failure_artifact = failure_artifact,
- experiment_malus = experiment_malus,
- })
- self.sources[source] = true
- end
- until true
- end
- -- assign parent id's -- Who's your daddy, hmm?
- for _, child in ipairs(self.recipes) do
- -- complex recipes don't have a single parent... this doesn't map well.
- if child.complex then
- child.parent = 0
- else
- local parent = self:getRecipeByResult(child.source)
- child.parent = parent and parent.id or 0
- end
- end
- self.cc_getRecipeBySource = xs_cache.ComputeCache()
- getSaveManager():Attach(self)
- local hm, ev = getHookMechanics()
- hm:Bind(ev.ItemTake, _G.db.actor, self, _G.isArtifact)
- hm:Bind(ev.ItemDrop, _G.db.actor, self, _G.isArtifact)
- end
- --[[-------------------------------------------------------------------\\--
- :: Methods: Overloads
- --\\-------------------------------------------------------------------]]--
- function TransmutationManager:__tostring()
- if #self.pending == 0 then
- string.format("%s [%08X] (#0)\n", self.__cls, self.__uid)
- end
- local buffer = xs_text.StringBuilder()
- buffer:AppendFormat("%s [%08X] (#%d)\n", self.__cls, self.__uid, #self.pending)
- for i, t in ipairs(self.pending) do
- buffer:AppendLine("[", i, "] = id: ", t.id, ", sid: ", t.sid, "")
- end
- return buffer:ToString()
- end
- --[[-------------------------------------------------------------------\\--
- :: Methods: Private
- --\\-------------------------------------------------------------------]]--
- function TransmutationManager:getNearsetAnomaly(origin)
- local status, id, pos, cls, dist, rad, sect = get_nearest_anomaly(db.actor)
- if status then
- return {
- id = id,
- position = position,
- class = cls,
- distance = dist,
- radius = rad,
- section = sect
- }
- else
- return nil
- end
- end
- function TransmutationManager:createTimerName(id)
- return TM_TIMER_PREFIX .. tostring(id)
- end
- function TransmutationManager:getTransmutationIndexByID(id)
- return find(self.pending, id, function (v, k) return v.id end, ipairs) or -1
- end
- function TransmutationManager:getRecipeProperty(recipe, property, default)
- return recipe[property] or self[property] or default
- end
- function TransmutationManager:getRecipeByResult(section)
- for _, recipe in ipairs(self.recipes) do
- if recipe.result == section then
- return recipe
- end
- end
- return nil
- end
- function TransmutationManager:getRecipeBySource(section)
- local cc = self.cc_getRecipeBySource
- if cc:IsInvalid(section) then
- cc:Update(section)
- cc:SetResult(nil)
- for _, recipe in ipairs(self.recipes) do
- if recipe.source == section then
- cc:SetResult(recipe)
- break
- end
- end
- end
- return cc:GetResult()
- end
- function TransmutationManager:getFinalArtifact(recipe)
- local chance = recipe.chance
- local result = rand(0, 100)
- if recipe.recipe and db.actor:dont_has_info(0, recipe.recipe) then
- local malus = self:getRecipeProperty(recipe, INIP_EXPERIMENT_MALUS)
- map(chance, function (v, k) return math.floor(v * malus) end, ipairs)
- end
- -- 2012-07-02 17:39: ~Xetrill: Every time I look at this code, I think this needs refactoring,
- -- too complicated for what it should (it's untested) accomplish.
- -- success or failure?
- if result >= chance[0] then
- -- success!
- return recipe.result
- else
- -- failure?
- if result < (chance[1] or 100 - chance[0]) then
- -- no-change or downgrade?
- if recipe.parent > 0 and result < (chance[2] or rand(5, 20)) then
- if recipe.complex then
- local artifacts = {}
- local recipes = self:getAllRecipesByID(recipe.id)
- local chance = math.max(5, math.ceil(chance[0] / #recipes) - math.ceil(#recipes * 1.5))
- for _, recipe in ipairs(recipes) do
- if rand(0, 100) > chance then
- insert(recipe.source)
- end
- end
- return artifacts
- else
- -- *phew* no-change
- return recipe.source
- end
- else
- -- *mah* downgrade
- return self.recipes[recipe.parent].source
- end
- else
- -- *aww shit* destruction!
- return self:getRecipeProperty(recipe, INIP_FAILURE_ARTIFACT)
- end
- end
- end
- function TransmutationManager:getGameVertexID(artifact, anomaly)
- local id
- id = level.object_by_id(anomaly:id()):game_vertex_id()
- if id ~= 65535 then
- return id
- end
- id = artifact:game_vertex_id()
- if id ~= 65535 then
- return id
- end
- id = db.actor:game_vertex_id()
- if id ~= 65535 then
- return id
- end
- return -1
- end
- function TransmutationManager:getLevelVertexID(artifact, anomaly)
- return db.actor and db.actor:level_vertex_id() or -1
- end
- -- 2012-07-02 17:37: ~Xetrill: I wrote that before I knew whether it was needed and also
- -- I didn't know by how much 'scrambling' would be good.
- -- (I still don't know.)
- -- 2012-07-16 18:21: ~Xetrill: And now there aren't any vectors anymore, just good ol' tables
- function TransmutationManager:scrambleVector(v)
- -- local x, y, z = v.x, v.y, v.z
- -- v:set(self:scrambleNumber(x, 2), self:scrambleNumber(y, 2), self:scrambleNumber(z, 1))
- v.x = self:scrambleNumber(x, 2.0)
- v.y = self:scrambleNumber(y, 2.0)
- v.z = self:scrambleNumber(z, 1.0)
- return v
- end
- function TransmutationManager:scrambleNumber(n, range)
- return n + rand(0, range)
- end
- function TransmutationManager:getAllRecipesByID(id)
- local recipes = {}
- for _, recipe in ipairs(self.recipes) do
- if recipe.id == id then
- insert(recipes, recipe)
- end
- end
- return recipes
- end
- function TransmutationManager:canBeginTransmutation(artifact, section, anomaly)
- if anomaly.radius - anomaly.distance < 0 then
- return false
- end
- local h = level.get_time_hours()
- if h > self.timespan.min or h < self.timespan.max then
- return false
- end
- local recipe = self:getRecipeBySource(section)
- if anomaly:section():find(recipe.anomaly, 1, true) == nil then
- return false
- end
- if self.experiment_malus >= 1.0 and db.actor:dont_has_info(0, recipe.recipe) then
- return false
- end
- if not recipe.complex then
- self.complex = nil
- return true
- end
- -- from here on its all about complex transmutations.
- if self.complex ~= nil and self.complex.id == recipe.id then
- -- CONTINUE a complex transmutation
- local duplicate = false
- for _, previousArtifact in ipairs(self.complex.artifacts) do
- if previousArtifact:section() == section then
- duplicate = true
- break
- end
- end
- if duplicate then
- return false
- end
- insert(self.complex.artifacts, artifact)
- self.complex.numleft = #self.complex.recipes - #self.complex.artifacts
- return self.complex.numleft == 0
- else
- self.complex = nil
- end
- if self.complex == nil then
- -- begin a NEW complex transmutation
- local recipes = self:getAllRecipesByID(recipe.id)
- self.complex = {
- id = recipe.id,
- anomaly = anomaly,
- artifacts = { artifact },
- numleft = #recipes - 1,
- recipes = recipes,
- }
- end
- return false
- end
- function TransmutationManager:beginTransmutation(artifact, anomaly)
- local section = artifact:section()
- local recipe = self:getRecipeBySource(section)
- local id = artifact:id()
- local gvid = self:getGameVertexID(artifact, anomaly)
- local lvid = self:getLevelVertexID(artifact, anomaly)
- local timeout = time_global() + recipe.delay * 60
- if gvid < 0 or lvid < 0 then
- log("[TransmutationManager:beginTransmutation]: Could not get a proper game-vertex-id or level-vertex-id.")
- return
- end
- insert(self.pending, {
- id = id,
- sid = recipe.id,
- lvid = lvid,
- gvid = gvid,
- pos = vec2tbl(artifact:position()),
- })
- level.add_pp_effector(TM_VFX_PPE, TM_VFX_UID, false)
- if TM_SFX_SND ~= nil then
- local sfx
- if xs_game.IS_SOC then
- sfx = xr_sound.get_safe_sound_object(TM_SFX_SND)
- else
- sfx = sound_object(TM_SFX_SND)
- end
- sfx:play_no_feedback(db.actor, sound_object.s3d, 0, artifact:position(), 1.0)
- end
- if self.complex ~= nil then
- for _, artifact in ipairs(self.complex.artifacts) do
- alife():release(artifact, true)
- end
- self.complex = nil
- else
- alife():release(artifact, true)
- end
- getScheduleManager():Add(
- self:createTimerName(id),
- timeout,
- xs_utils.createCallback(__FILE__, "finishTransmutationCallback"))
- end
- function TransmutationManager:finishTransmutation(id)
- local index = self:getTransmutationIndexByID(id)
- if index < 0 then
- -- TODO: to crash or not to crash? IMO, in release no crash, until then ...
- abort("[TransmutationManager:finishTransmutation]: Invalid transmutation id #%s.",
- tostring(id))
- end
- local trans = self.pending[index]
- local result = self:getFinalArtifact(trans)
- local sim, aid = alife(), db.actor:id()
- local artifacts = {}
- if type(result) == "table" then
- for i, result in ipairs(result) do
- insert(artifacts, sim:create(
- result,
- tlb2vec(trans.pos),
- trans.lvid,
- trans.gvid,
- aid))
- end
- else
- insert(artifacts, sim:create(
- result,
- tlb2vec(trans.pos),
- trans.lvid,
- trans.gvid,
- aid))
- end
- local name = translate(system_ini():r_string(result, "inv_name"))
- local id = artifacts[1]:id()
- if not level.map_has_object_spot(id, TM_MAPSPOT_TYPE) then
- level.map_add_object_spot(
- id,
- TM_MAPSPOT_TYPE,
- translate("xs_tm_mapspot_caption_format"):format(name))
- end
- xs_game.SendMessage(
- not xs_game.IS_SOC and translate("xs_tm_notification_header") or nil,
- translate("xs_tm_notification_format"):format(name),
- "ui_iconsTotal_recover_item",
- nil, nil, nil)
- end
- --[[-------------------------------------------------------------------\\--
- :: Methods: Public
- --\\-------------------------------------------------------------------]]--
- function TransmutationManager:OnSave(sm)
- getSaveManager():Update(self.__cls, self.pending)
- end
- function TransmutationManager:OnLoad(sm)
- self.pending = getSaveManager():Request(self.__cls) or {}
- end
- function TransmutationManager:OnDropItem(artifact)
- local section = artifact:section()
- if not self.sources[section] then
- return false
- end
- local anomaly = self:getNearsetAnomaly(artifact)
- if not anomaly then
- return false
- end
- if not self:canBeginTransmutation(artifact, section, anomaly) then
- return false
- end
- self:beginTransmutation(
- artifact,
- level.object_by_id(anomaly.id)
- -- alife():object(anomaly.id)
- -- db.storage[anomaly.id].object
- )
- return true
- end
- function TransmutationManager:OnTakeItem(artifact)
- local id = artifact:id()
- local index = self:getTransmutationIndexByID(id)
- if index < 0 then
- log("[TransmutationManager:OnTakeItem]: Invalid transmutation id #%.0f.", id)
- return false
- end
- if self.experiment_malus ~= 1.0 then
- local actor = db.actor
- local recipe = self.recipes[self.pending[index].sid]
- if recipe and
- recipe.recipe and
- recipe.result == artifact:section() and
- actor:dont_has_info(0, recipe.recipe)
- then
- -- 2012-07-02 17:24: ~Xetrill: this could be improved by giving specialized infos, ones
- -- that show a message like "I discoved how to create artifact X by ...".
- actor:give_info_portion(recipe.recipe)
- local name = translate(system_ini():r_string(artifact:section(), "inv_name"))
- xs_game.SendMessage(
- not xs_game.IS_SOC and translate("xs_tm_discovered_recipe_header") or nil,
- translate("xs_tm_discovered_recipe_format"):format(name),
- "ui_iconsTotal_found_thing",
- nil, nil, nil)
- end
- end
- remove(self.pending, index)
- if level.map_has_object_spot(id, TM_MAPSPOT_TYPE) then
- level.map_remove_object_spot(id, TM_MAPSPOT_TYPE)
- end
- return true
- end
- function TransmutationManager:Dump(print)
- print = print or _G.print
- local l = 0
- local vec2str = function (v)
- string.format("(x: %f, y: %f, z: %f)", v.x, v.y, v.z)
- end
- local text = xs_text.StringBuilder()
- text:AppendRepeat("-", 80):AppendLine()
- :AppendLine(self.__cls, " {"):IncreaseIndent()
- -- self recipes
- l = #self.recipes
- if l == 0 then
- text:AppendLine("recipes {},")
- else
- text:AppendLine("recipes {"):IncreaseIndent()
- for i, v in ipairs(self.recipes) do
- text:AppendLine("[", i, "] = {"):IncreaseIndent()
- :AppendLine("id* = ", v.id, ",")
- :AppendLine("parent* = ", v.parent, ",")
- :AppendLine("complex* = ", v.complex, ",")
- :AppendLine("anomaly = ", v.anomaly, ",")
- :AppendLine("recipe = ", v.recipe, ",")
- :AppendLine("result = ", v.result, ",")
- :AppendLine("chance = ", table.concat(v.chance, ", "), ",")
- :AppendLine("delay = ", v.delay, ",")
- :AppendIndent():Append("source = ", v.source)
- :AppendIfOr(v.failure_artifact ~= nil or v.experiment_malus ~= nil, ",\n", "\n")
- if v.failure_artifact ~= nil then
- text:AppendIndent():Append("*failure_artifact = ", v.failure_artifact)
- :AppendIfOr(v.experiment_malus ~= nil, ",\n", "\n")
- end
- if v.experiment_malus ~= nil then
- text:AppendLine("*experiment_malus = ", v.experiment_malus)
- end
- text:DecreaseIndent():AppendIndent():Append("}"):AppendIfOr(i < l, ",\n", "\n")
- text:Apply(print):Clear()
- end
- text:DecreaseIndent():AppendLine("},")
- end
- text:Apply(print):Clear()
- -- self.pending
- l = #self.pending
- if l == 0 then
- text:AppendLine("pending {},")
- else
- text:AppendLine("pending {"):IncreaseIndent()
- for i, v in ipairs(self.pending) do
- text:AppendLine("[", i, "] = {"):IncreaseIndent()
- text:AppendLine("id = ", v.id, ",")
- :AppendLine("sid = ", v.sid, ",")
- :AppendLine("gvid = ", v.gvid, ",")
- :AppendLine("lvid = ", v.lvid, ",")
- :AppendLine("pos = ", v.pos, ",")
- text:DecreaseIndent():AppendIndent():Append("}"):AppendIf(i < l, ","):AppendLine()
- text:Apply(print):Clear()
- end
- text:DecreaseIndent():AppendLine("},")
- end
- text:Apply(print):Clear()
- -- self.timespan
- text:AppendLine("timespan {"):IncreaseIndent()
- :AppendLine("min = ", self.timespan.min, ",")
- :AppendLine("max = ", self.timespan.max)
- :DecreaseIndent():AppendIndent():AppendIfOr(self.complex ~= nil, "},\n", "}\n")
- -- self.complex
- if self.complex ~= nil then
- text:AppendLine("complex {"):IncreaseIndent()
- :AppendLine("id = ", self.complex.id, ",")
- :AppendLine("anomaly = (game_object, id: ", self.complex.anomaly:id(), "),")
- :AppendLine("artifacts = ", concat(self.complex.artifacts, ", "), ",")
- :AppendLine("numleft = ", self.complex.numleft, ",")
- :AppendLine("recipes = (table, #: ", #self.complex.recipes, ")")
- :DecreaseIndent():AppendLine("}")
- end
- text:DecreaseIndent():AppendLine("}")
- :Apply(print):Clear()
- end
- function getTransmutationManager()
- if m_tm == nil then
- m_tm = TransmutationManager()
- end
- return m_tm
- end
- function finishTransmutationCallback(name)
- local id = xs_utils.extractNo(name, TM_TIMER_PREFIX:len())
- getTransmutationManager():finishTransmutation(id)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement