forked from squidy5/cargo_ships
-
Notifications
You must be signed in to change notification settings - Fork 11
/
data-final-fixes.lua
109 lines (92 loc) · 4.33 KB
/
data-final-fixes.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
require("__cargo-ships__/constants")
local collision_mask_util = require("__core__/lualib/collision-mask-util")
data:extend{
{
type = "collision-layer",
name = "waterway",
},
{
type = "collision-layer",
name = "pump",
},
}
-- Prevent waterways being placed on land, but without colliding with ground-tile directly, so that ships don't collide
for _, tile in pairs(data.raw.tile) do
if tile.collision_mask.layers["ground_tile"] then
tile.collision_mask.layers["waterway"] = true
end
end
data.raw["straight-rail"]["straight-waterway"].collision_mask.layers["waterway"] = true
data.raw["half-diagonal-rail"]["half-diagonal-waterway"].collision_mask.layers["waterway"] = true
data.raw["curved-rail-a"]["curved-waterway-a"].collision_mask.layers["waterway"] = true
data.raw["curved-rail-b"]["curved-waterway-b"].collision_mask.layers["waterway"] = true
data.raw["legacy-straight-rail"]["legacy-straight-waterway"].collision_mask.layers["waterway"] = true
data.raw["legacy-curved-rail"]["legacy-curved-waterway"].collision_mask.layers["waterway"] = true
data.raw["rail-signal"]["buoy"].collision_mask.layers["waterway"] = true
data.raw["rail-chain-signal"]["chain_buoy"].collision_mask.layers["waterway"] = true
data.raw["rail-chain-signal"]["invisible-chain-signal"].collision_mask.layers["waterway"] = true
data.raw.tile["landfill"].check_collision_with_entities = true
-- Change drawing of fish to be underneath bridges
-- TODO 2.0 check if needed
--data.raw.fish["fish"].collision_mask = {"ground-tile", "colliding-with-tiles-only"}
--data.raw.fish["fish"].pictures[1].draw_as_shadow = true
--data.raw.fish["fish"].pictures[2].draw_as_shadow = true
--data.raw.fish["fish"].selection_priority = 48
-- Change inserters to not catch fish when waiting for ships
if settings.startup["no_catching_fish"].value then
for _, inserter in pairs(data.raw.inserter) do
inserter.use_easter_egg = false
end
end
-- Krastorio2 fuel compatibility
if mods["Krastorio2"] and settings.startup['kr-rebalance-vehicles&fuels'].value then
data.raw.locomotive["cargo_ship_engine"].energy_source.fuel_categories = { "chemical", "vehicle-fuel" }
log("Updated cargo_ship_engine to use chemical fuel and Krastorio2 vehicle-fuel")
data.raw.locomotive["boat_engine"].energy_source.fuel_categories = { "vehicle-fuel" }
log("Updated boat_engine to use only Krastorio2 vehicle-fuel")
end
-- Ensure player collides with pump
local pump = data.raw["pump"]["pump"]
local pump_collision_mask = collision_mask_util.get_mask(pump)
pump_collision_mask.layers["pump"] = true
pump.collision_mask = pump_collision_mask
for _, character in pairs(data.raw.character) do
local collision_mask = collision_mask_util.get_mask(character)
if collision_mask.layers["player"] then
collision_mask.layers["pump"] = true
character.collision_mask = collision_mask
end
end
-- Compatibility for pump upgrade mods
for _, other_pump in pairs(data.raw.pump) do
if other_pump.fast_replaceable_group == pump.fast_replaceable_group then
other_pump.collision_mask = table.deepcopy(pump.collision_mask)
end
end
-----------------------------
---- DEEP OIL GENERATION ----
-----------------------------
if data.raw.resource["offshore-oil"] then
-- Add new "water_resource" collision layer to all the tiles that have "ground_tile"
for name, tile in pairs(data.raw.tile) do
local collision_mask = tile.collision_mask
if collision_mask.layers["ground_tile"] then
log("Adding collision layer 'water_resource' to tile '"..name.."'")
collision_mask.layers["water_resource"] = true
end
end
-- Add new "water_resource" collision layer to all non-deep water tiles if "Offshore oil on Deep Water only" is enabled
if settings.startup["no_shallow_oil"].value then
for _, name in pairs({"water", "water-green", "water-shallow", "water-mud"}) do
if data.raw.tile[name] then
local collision_mask = data.raw.tile[name].collision_mask
log("Adding collision layer 'water_resource' to tile '"..name.."'")
collision_mask.layers["water_resource"] = true
end
end
end
-- Make sure the oil rig can mine deep oil:
data.raw["mining-drill"]["oil_rig"].resource_categories = {data.raw.resource["offshore-oil"].category}
-- Make sure the oil rig can burn crude-oil
data.raw.fluid["crude-oil"].fuel_value = data.raw.fluid["crude-oil"].fuel_value or "100MJ"
end