This commit is contained in:
2026-06-19 20:12:36 +09:00
parent d748a1b151
commit 06dc4b5ff1
5 changed files with 79 additions and 411 deletions
+73 -52
View File
@@ -54,15 +54,33 @@ local function tint_handle(item, tier, tl)
end
end
function tint_layer(p, t)
if p and p.layers then
for _, v in pairs(p.layers) do
if not v.draw_as_shadow then
v.tint = mod_tint[t]
function tint_layer(al, t)
for _, l in pairs(al) do
if not l.draw_as_shadow then
l.tint = mod_tint[t]
end
end
end
function tint(i, p, t)
if not i then
return
end
if p then
for _, c in pairs(p) do
if i[c] and i[c].layers then
tint_layer(i[c].layers, t)
end
if c == 'picture' then
table.insert(i[c].layers, {icon = '__base__/graphics/icons/signal/signal_' .. t .. '.png', icon_size = 64, scale = 0.25, shift = {12, 12}})
end
end
table.insert(p.layers, {icon = '__base__/graphics/icons/signal/signal_' .. t .. '.png', icon_size = 64, scale = 0.25, shift = {12, 12}})
else
tint_layer(i.layers, t)
table.insert(i.layers, {icon = '__base__/graphics/icons/signal/signal_' .. t .. '.png', icon_size = 64, scale = 0.25, shift = {12, 12}})
end
end
@@ -72,9 +90,8 @@ function main_entity(source, tier)
item.minable.result = item.name
item.max_health = item.max_health * (tier - source.min + 2)
item.next_upgrade = ((tier < source.max) and source.name .. '-' .. (tier + 1)) or nil
item.production = item.production and (((source.tech == 'compound-energy' and source.type == 'solar-panel') and (tonumber(string.match(item.production, '[%d%.]+')) * (settings.startup['PHI-MB-ENERGY-SOLAR-RATIO'].value ^ (tier - source.min + 1)) .. (string.match(item.production, '%a+') or ''))) or (tonumber(string.match(item.production, '[%d%.]+')) * (2 ^ (tier - source.min + 1)) .. (string.match(item.production, '%a+') or ''))) or nil
for _, v in pairs({'energy_usage', 'heating_energy', 'crane_energy_usage', 'energy_per_shot'}) do
for _, v in pairs({'energy_usage', 'heating_energy'}) do
if not (source.tech == 'compound-energy' and (source.type == 'solar-panel' or source.type == 'accumulator')) and item[v] then
item[v] = (tonumber(string.match(item[v], '[%d%.]+')) * (2 ^ (tier - source.min + 1))) .. (string.match(item[v], '%a+') or '')
end
@@ -102,12 +119,31 @@ function main_entity(source, tier)
table.insert(item.surface_conditions, {property = 'gravity', min = 0.01})
end
if (source.type == 'accumulator') then
if (source.type == 'solar-panel') then
item.production = tonumber(string.match(item.production, '[%d%.]+')) * (settings.startup['PHI-MB-ENERGY-SOLAR-RATIO'].value ^ (tier - source.min + 1)) .. (string.match(item.production, '%a+') or '')
if item['picture'] and item['picture'].layers then
for _, l in pairs(item['picture'].layers) do
if not l.draw_as_shadow then
l.tint = mod_tint[tier]
end
end
end
elseif (source.type == 'accumulator') then
if item['chargable_graphics'] then
tint(item['chargable_graphics'], {'picture', 'charge_animation', 'discharge_animation'}, tier)
end
for _, v in pairs({'buffer_capacity', 'input_flow_limit', 'output_flow_limit'}) do
item.energy_source[v] = (item.energy_source[v] and (tonumber(string.match(item.energy_source[v], '[%d%.]+')) * (settings.startup['PHI-MB-ENERGY-SOLAR-RATIO'].value ^ (tier - source.min + 1)) .. string.match(item.energy_source[v], '%a+'))) or nil
end
elseif (source.type == 'boiler') then
if item['picture'] then
tint(item['picture'], {'north', 'east', 'south', 'west'}, tier)
end
item.energy_consumption = tostring(tonumber(string.match(item.energy_consumption, '[%d%.]+')) * (2 * (tier - source.min + 1))) .. string.match(item.energy_consumption, '%a+')
item.target_temperature = 15 + ((item.target_temperature - 15) * (2 * (tier - source.min + 1)))
@@ -118,6 +154,12 @@ function main_entity(source, tier)
end
elseif (source.type == 'generator') then
for _, c in pairs({'horizontal_animation', 'vertical_animation'}) do
if item[c] then
tint(item[c], nil, tier)
end
end
item.max_power_output = (item.max_power_output and (tonumber(string.match(item.max_power_output, '[%d%.]+')) * (2 * (tier - source.min + 1))) .. string.match(item.max_power_output, '%a+')) or nil
item.maximum_temperature = (item.maximum_temperature and 15 + ((item.maximum_temperature - 15) * (2 * (tier - source.min + 1)))) or nil
@@ -136,58 +178,37 @@ function main_entity(source, tier)
item.max_fluid_usage = item.max_fluid_usage * (2 * (tier - source.min + 1))
elseif (source.type == 'heat-pipe') then
for _, c in pairs({'connection_sprites', 'heat_glow_sprites'}) do
if item[c] then
tint(item[c], {'single', 'straight_vertical', 'straight_horizontal', 'corner_right_up', 'corner_left_up', 'corner_right_down', 'corner_left_down', 't_up', 't_down', 't_right', 't_left', 'cross', 'ending_up', 'ending_down', 'ending_right', 'ending_left'}, tier)
end
end
item.heat_buffer.max_temperature = item.heat_buffer.max_temperature * (2 * (tier - source.min + 1))
item.heat_buffer.max_transfer = tostring(tonumber(string.match(item.heat_buffer.max_transfer, '[%d%.]+')) * (2 * (tier - source.min + 1))) .. string.match(item.heat_buffer.max_transfer, '%a+')
tint_handle(item, tier, {'connection_sprites', 'heat_glow_sprites'})
end
-- picture: solar-panel
for _, v in pairs({'picture'}) do
if item[v] then
tint_layer(item[v], tier)
end
--[[
nuclear-reactor
fusion-reactor
fusion-generator
heating-tower
reactor
tint(item, {'picture'}, tier)
if item['heat_buffer'] then
tint(item['heat_buffer'], {'heat_picture'}, tier)
end
-- chargable_graphics: accumulator
if item['chargable_graphics'] then
for _, v in pairs({'picture', 'charge_animation', 'discharge_animation'}) do
if item['chargable_graphics'][v] then
tint_layer(item['chargable_graphics'][v], tier)
for _, c in pairs({'horizontal_animation', 'vertical_animation'}) do
if item[c] then
tint(item[c], nil, tier)
end
end
end
]]
tint_handle(item, tier, {'picture', 'pictures', 'animation', 'structure', 'integration_patch', 'horizontal_animation', 'vertical_animation'})
for _, v in pairs({'graphics_set', 'graphics_set_flipped'}) do
if item[v] then
tint_handle(item[v], tier, {'animation', 'idle_animation', 'frozen_patch'})
if item[v].working_visualisations then
tint_handle(item[v].working_visualisations, tier, {'north_animation', 'east_animation', 'south_animation', 'west_animation', 'animation'})
end
end
end
if item.idle_animation and item.idle_animation.layers then
local i = 1
while i < #item.idle_animation.layers do
if item.idle_animation.layers[i] then
item.idle_animation.layers[i].tint = mod_tint[tier]
end
i = i + 2
if not item.idle_animation.layers[i] then
break
end
end
end
if item.base_picture and item.base_picture.sheets then
item.base_picture.sheets[1].tint = mod_tint[tier]
end
item.localised_name = (tier > 1 and {'phi-cl.combine', {'?', {'entity-name.' .. source.ref_name}, {'name.' .. source.ref_name}}, tostring(tier)}) or {'?', {'entity-name.' .. source.ref_name}, {'name.' .. source.ref_name}}
item.localised_description = {'?', {'entity-description.' .. source.ref_name}, {'description.' .. source.ref_name}}