├── .gitattributes
├── .gitignore
├── 1.1
└── Assemblies
│ ├── 0MultiplayerAPI.dll
│ └── ZLevels.dll
├── 1.2
└── Assemblies
│ └── ZLevels.dll
├── 1.3
└── Assemblies
│ ├── 0MultiplayerAPI.dll
│ └── ZLevels.dll
├── About
├── About.xml
├── Preview.png
└── PublishedFileId.txt
├── Changelog.txt
├── Common
├── Defs
│ ├── BiomeDef
│ │ ├── UndergroundBiome.xml
│ │ └── UpperBiome.xml
│ ├── Buildings
│ │ ├── PowerTransferingColumn.xml
│ │ └── Stairs.xml
│ ├── GameConditions
│ │ └── GameConditions_Misc.xml
│ ├── Jobs
│ │ └── Jobs.xml
│ ├── KeybindingDefs
│ │ ├── KeyBindingCategories.xml
│ │ └── KeyBindings.xml
│ ├── MapGenerator
│ │ ├── EmptyMap.xml
│ │ ├── Underground.xml
│ │ └── Upper.xml
│ └── TerrainDef
│ │ ├── OutsideTerrain.xml
│ │ └── RoofTerrain.xml
├── Languages
│ ├── ChineseSimplified
│ │ ├── DefInjected
│ │ │ ├── BiomeDef
│ │ │ │ ├── UndergroundBiome.xml
│ │ │ │ └── UpperBiome.xml
│ │ │ ├── GameConditionDef
│ │ │ │ └── GameConditions_Misc.xml
│ │ │ ├── JobDef
│ │ │ │ └── Stairs.xml
│ │ │ ├── KeyBindingCategoryDef
│ │ │ │ └── KeyBindingCategories.xml
│ │ │ ├── KeyBindingDef
│ │ │ │ └── KeyBindings.xml
│ │ │ ├── TerrainDef
│ │ │ │ ├── OutsideTerrain.xml
│ │ │ │ └── RoofTerrain.xml
│ │ │ ├── ThingDef
│ │ │ │ └── Stairs.xml
│ │ │ └── WorldObjectDef
│ │ │ │ ├── Underground.xml
│ │ │ │ └── Upper.xml
│ │ └── Keyed
│ │ │ └── Keyed.xml
│ ├── ChineseTraditional
│ │ ├── DefInjected
│ │ │ ├── BiomeDef
│ │ │ │ ├── UndergroundBiome.xml
│ │ │ │ └── UpperBiome.xml
│ │ │ ├── GameConditionDef
│ │ │ │ └── GameConditions_Misc.xml
│ │ │ ├── JobDef
│ │ │ │ └── Jobs.xml
│ │ │ ├── KeyBindingCategoryDef
│ │ │ │ └── KeyBindingCategories.xml
│ │ │ ├── KeyBindingDef
│ │ │ │ └── KeyBindings.xml
│ │ │ ├── TerrainDef
│ │ │ │ ├── OutsideTerrain.xml
│ │ │ │ └── RoofTerrain.xml
│ │ │ ├── ThingDef
│ │ │ │ ├── PowerTransferingColumn.xml
│ │ │ │ └── Stairs.xml
│ │ │ └── WorldObjectDef
│ │ │ │ ├── Underground.xml
│ │ │ │ └── Upper.xml
│ │ └── Keyed
│ │ │ └── Keyed.xml
│ ├── English
│ │ └── Keyed
│ │ │ └── Keyed.xml
│ ├── Japanese
│ │ ├── DefInjected
│ │ │ ├── BiomeDef
│ │ │ │ ├── UndergroundBiome.xml
│ │ │ │ └── UpperBiome.xml
│ │ │ ├── GameConditionDef
│ │ │ │ └── GameConditions_Misc.xml
│ │ │ ├── JobDef
│ │ │ │ └── Stairs.xml
│ │ │ ├── KeyBindingCategoryDef
│ │ │ │ └── KeyBindingCategories.xml
│ │ │ ├── KeyBindingDef
│ │ │ │ └── KeyBindings.xml
│ │ │ ├── TerrainDef
│ │ │ │ ├── OutsideTerrain.xml
│ │ │ │ └── RoofTerrain.xml
│ │ │ ├── ThingDef
│ │ │ │ ├── PowerTransferingColumn.xml
│ │ │ │ ├── Stairs.xml
│ │ │ │ └── _Terrain_Extra.xml
│ │ │ └── WorldObjectDef
│ │ │ │ ├── Underground.xml
│ │ │ │ └── Upper.xml
│ │ └── Keyed
│ │ │ └── Keyed.xml
│ └── Russian
│ │ ├── DefInjected
│ │ ├── BiomeDef
│ │ │ ├── UndergroundBiome.xml
│ │ │ └── UpperBiome.xml
│ │ ├── GameConditions
│ │ │ └── GameConditions_Misc.xml
│ │ ├── JobDef
│ │ │ └── Stairs.xml
│ │ ├── KeyBindingCategoryDef
│ │ │ └── KeyBindingCategories.xml
│ │ ├── KeyBindingDef
│ │ │ └── KeyBindings.xml
│ │ ├── TerrainDef
│ │ │ ├── OutsideTerrain.xml
│ │ │ └── RoofTerrain.xml
│ │ ├── ThingDef
│ │ │ ├── PowerTransferingColumn.xml
│ │ │ └── Stairs.xml
│ │ └── WorldObjectDef
│ │ │ ├── Underground.xml
│ │ │ └── Upper.xml
│ │ └── Keyed
│ │ └── Keyed.xml
└── Textures
│ ├── Building
│ ├── LadderUp_north.png
│ ├── LadderUp_northm.png
│ ├── LadderUp_west.png
│ ├── LadderUp_westm.png
│ ├── Ladder_north.png
│ ├── Ladder_northm.png
│ ├── Ladder_west.png
│ └── Ladder_westm.png
│ └── Terrain
│ ├── FogOfWar.png
│ ├── FogOfWar1 (2).png
│ └── FogOfWar_bac.png
├── LoadFolders.xml
└── Source
└── ZLevels
├── Refs
├── 0Harmony.dll
└── Assembly-CSharp_publicized.dll
├── ZLevels.sln
└── ZLevels
├── ActiveArea.cs
├── Buildings
├── Building_StairsDown.cs
└── Building_StairsUp.cs
├── DebugLevel.cs
├── GenSteps
├── GenStep_Animals.cs
├── GenStep_CaveHives.cs
├── GenStep_Caves.cs
├── GenStep_CavesTerrain.cs
├── GenStep_ElevationFertility.cs
├── GenStep_FindLocationUnderground.cs
├── GenStep_Plants.cs
├── GenStep_RockChunks.cs
├── GenStep_RocksFromGrid.cs
├── GenStep_ScatterLumpsMineable.cs
├── GenStep_Terrain.cs
└── GenStep_TerrainUpper.cs
├── HarmonyPatches
├── AnimalPatches.cs
├── ColonistBarPatches.cs
├── CombatPatches.cs
├── FloatMenuPatches.cs
├── JobPatches - Copy.cs
├── JobPatches.cs
├── Logging.cs
├── MapPatches.cs
├── PawnPatches.cs
├── ReachAndReservationPatches.cs
├── ResourceCounterPatch.cs
├── RoofAndFloorPatches.cs
├── SkyfallerPatches.cs
├── TradePatches.cs
├── WealthPatches.cs
└── WeatherPatches.cs
├── JobTracker.cs
├── Jobs
├── JobDriver_GoToLocation.cs
├── JobDriver_GoToMap.cs
├── JobDriver_GoToStairs.cs
├── JobDriver_HaulThingToDest.cs
├── JobDriver_HaulThingToDestAndToCell.cs
├── JobDriver_ZLevels.cs
└── Toils_ZLevels.cs
├── Map
├── BiomeWorker_NeverSpawn.cs
├── BlueprintUtility.cs
├── InfestationData.cs
├── MapComponentZLevel.cs
└── MapParent_ZLevel.cs
├── MapRenderer
├── RenderPatches.cs
├── SectionLayer_LowerFogOfWar.cs
├── SectionLayer_LowerTerrain.cs
└── SectionLayer_LowerThings.cs
├── MultiplayerSupport.cs
├── PowerTransfer
├── Building_PowerTransmitter.cs
├── CompPowerZTransmitter.cs
├── CompProperties_PowerZTransmitter.cs
└── ConnectedPowerNets.cs
├── Properties
└── AssemblyInfo.cs
├── ZLevelData.cs
├── ZLevels.csproj
├── ZLevelsDefOf.cs
├── ZLevelsManager.cs
├── ZLevelsMod.cs
├── ZLevelsSettings.cs
├── ZLogger.cs
├── ZPathfinder.cs
├── ZUtils.cs
└── obj
└── Release
├── ZLevels.csproj.CopyComplete
└── ZLevels.csproj.FileListAbsolute.txt
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | [Xx]64/
19 | [Xx]86/
20 | [Bb]uild/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 |
85 | # Visual Studio profiler
86 | *.psess
87 | *.vsp
88 | *.vspx
89 | *.sap
90 |
91 | # TFS 2012 Local Workspace
92 | $tf/
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 | *.DotSettings.user
101 |
102 | # JustCode is a .NET coding add-in
103 | .JustCode
104 |
105 | # TeamCity is a build add-in
106 | _TeamCity*
107 |
108 | # DotCover is a Code Coverage Tool
109 | *.dotCover
110 |
111 | # NCrunch
112 | _NCrunch_*
113 | .*crunch*.local.xml
114 | nCrunchTemp_*
115 |
116 | # MightyMoose
117 | *.mm.*
118 | AutoTest.Net/
119 |
120 | # Web workbench (sass)
121 | .sass-cache/
122 |
123 | # Installshield output folder
124 | [Ee]xpress/
125 |
126 | # DocProject is a documentation generator add-in
127 | DocProject/buildhelp/
128 | DocProject/Help/*.HxT
129 | DocProject/Help/*.HxC
130 | DocProject/Help/*.hhc
131 | DocProject/Help/*.hhk
132 | DocProject/Help/*.hhp
133 | DocProject/Help/Html2
134 | DocProject/Help/html
135 |
136 | # Click-Once directory
137 | publish/
138 |
139 | # Publish Web Output
140 | *.[Pp]ublish.xml
141 | *.azurePubxml
142 |
143 | # TODO: Un-comment the next line if you do not want to checkin
144 | # your web deploy settings because they may include unencrypted
145 | # passwords
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # NuGet Packages
150 | *.nupkg
151 | # The packages folder can be ignored because of Package Restore
152 | **/packages/*
153 | # except build/, which is used as an MSBuild target.
154 | !**/packages/build/
155 | # Uncomment if necessary however generally it will be regenerated when needed
156 | #!**/packages/repositories.config
157 | # NuGet v3's project.json files produces more ignoreable files
158 | *.nuget.props
159 | *.nuget.targets
160 |
161 | # Microsoft Azure Build Output
162 | csx/
163 | *.build.csdef
164 |
165 | # Microsoft Azure Emulator
166 | ecf/
167 | rcf/
168 |
169 | # Windows Store app package directory
170 | AppPackages/
171 | BundleArtifacts/
172 |
173 | # Visual Studio cache files
174 | # files ending in .cache can be ignored
175 | *.[Cc]ache
176 | # but keep track of directories ending in .cache
177 | !*.[Cc]ache/
178 |
179 | # Others
180 | ClientBin/
181 | [Ss]tyle[Cc]op.*
182 | ~$*
183 | *~
184 | *.dbmdl
185 | *.dbproj.schemaview
186 | *.pfx
187 | *.publishsettings
188 | node_modules/
189 | orleans.codegen.cs
190 |
191 | # RIA/Silverlight projects
192 | Generated_Code/
193 |
194 | # Backup & report files from converting an old project file
195 | # to a newer Visual Studio version. Backup files are not needed,
196 | # because we have git ;-)
197 | _UpgradeReport_Files/
198 | Backup*/
199 | UpgradeLog*.XML
200 | UpgradeLog*.htm
201 |
202 | # SQL Server files
203 | *.mdf
204 | *.ldf
205 |
206 | # Business Intelligence projects
207 | *.rdl.data
208 | *.bim.layout
209 | *.bim_*.settings
210 |
211 | # Microsoft Fakes
212 | FakesAssemblies/
213 |
214 | # GhostDoc plugin setting file
215 | *.GhostDoc.xml
216 |
217 | # Node.js Tools for Visual Studio
218 | .ntvs_analysis.dat
219 |
220 | # Visual Studio 6 build log
221 | *.plg
222 |
223 | # Visual Studio 6 workspace options file
224 | *.opt
225 |
226 | # Visual Studio LightSwitch build output
227 | **/*.HTMLClient/GeneratedArtifacts
228 | **/*.DesktopClient/GeneratedArtifacts
229 | **/*.DesktopClient/ModelManifest.xml
230 | **/*.Server/GeneratedArtifacts
231 | **/*.Server/ModelManifest.xml
232 | _Pvt_Extensions
233 |
234 | # LightSwitch generated files
235 | GeneratedArtifacts/
236 | ModelManifest.xml
237 |
238 | # Paket dependency manager
239 | .paket/paket.exe
240 |
241 | # FAKE - F# Make
242 | .fake/
243 |
244 | # Ignore files in dependency folder
245 | SourceDLLs/
246 |
247 | # Not sure what the purpose of this file is but lets ignore it
248 | Source/ZLevels/ZLevels/obj/Debug/ZLevels.csproj.FileListAbsolute.txt
249 | /Assemblies/ZLevels.dll
250 | Source/ZLevels/ZLevels/ZLevels.csproj
251 | /RimWorld64_Data/Managed
252 | /1.2/Assemblies
253 | /Source/ZLevels/testApp
254 | Source/ZLevels/ZLevels/ZLevels.csproj
255 |
--------------------------------------------------------------------------------
/1.1/Assemblies/0MultiplayerAPI.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/1.1/Assemblies/0MultiplayerAPI.dll
--------------------------------------------------------------------------------
/1.1/Assemblies/ZLevels.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/1.1/Assemblies/ZLevels.dll
--------------------------------------------------------------------------------
/1.2/Assemblies/ZLevels.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/1.2/Assemblies/ZLevels.dll
--------------------------------------------------------------------------------
/1.3/Assemblies/0MultiplayerAPI.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/1.3/Assemblies/0MultiplayerAPI.dll
--------------------------------------------------------------------------------
/1.3/Assemblies/ZLevels.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/1.3/Assemblies/ZLevels.dll
--------------------------------------------------------------------------------
/About/About.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Z-Levels Beta
5 | RamRod
6 | ZLevels1.1
7 |
8 | 1.1
9 | 1.2
10 | 1.3
11 |
12 |
13 | Add the ability to dig underground or build upwards!
14 |
15 | Requires new save.
16 |
17 | When building upwards you have to watch out for the floor collapsing similar to normal roof collapses. Upper floors need supports. When building lower watch out for dropping the montain roof on yourself. The stairs are in the structure tab.
18 |
19 |
20 |
21 | -----
22 |
23 | Known Bugs:Natural hole, this is found in the structures tab and it should be avoided, it is only used for infestations underground. Avoid it.
24 | Please report any bugs.
25 |
26 |
27 | This is a BETA so it might have issues.
28 |
29 | If you enjoy this mod please consider donating.
30 | -----
31 | Patreon: https://www.patreon.com/RamRodMods
32 | Github: https://github.com/Zylleon/MapDesigner/releases/latest
33 | Discord: https://discord.gg/bDj7F8P
34 | ko-fi: https://ko-fi.com/ramrod6198
35 |
36 |
37 |
38 |
39 | brrainz.harmony
40 | Harmony
41 | steam://url/CommunityFilePage/2009463077
42 | https://github.com/pardeike/HarmonyRimWorld/releases/latest
43 |
44 |
45 |
46 | Ludeon.RimWorld
47 | Ludeon.RimWorld.Royalty
48 | brrainz.harmony
49 |
50 |
51 |
--------------------------------------------------------------------------------
/About/Preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/About/Preview.png
--------------------------------------------------------------------------------
/About/PublishedFileId.txt:
--------------------------------------------------------------------------------
1 | 2127428910
--------------------------------------------------------------------------------
/Changelog.txt:
--------------------------------------------------------------------------------
1 | - Added arrest float option to take effect across all level
--------------------------------------------------------------------------------
/Common/Defs/BiomeDef/UndergroundBiome.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ZL_UndegroundBiome
5 | Underground
6 | Nothing but rock, a miner's dream. No life can naturally live down here.
7 | ZLevels.BiomeWorker_NeverSpawn
8 | 3.7
9 | 0.65
10 | 0
11 | 1
12 | World/Biomes/TemperateForest
13 | 0
14 | 20
15 |
16 | Ambient_NightInsects_Standard
17 |
18 | 50
19 |
20 |
21 | Disease_Flu
22 | 100
23 |
24 |
25 | Disease_Plague
26 | 100
27 |
28 |
29 | Disease_Malaria
30 | 100
31 |
32 |
33 | Disease_GutWorms
34 | 50
35 |
36 |
37 | Disease_FibrousMechanites
38 | 30
39 |
40 |
41 | Disease_SensoryMechanites
42 | 30
43 |
44 |
45 | Disease_MuscleParasites
46 | 50
47 |
48 |
49 |
50 | Disease_AnimalFlu
51 | 100
52 |
53 |
54 | Disease_AnimalPlague
55 | 100
56 |
57 |
58 |
59 |
60 | Gravel
61 | 0.6
62 | 1
63 |
64 |
65 |
66 |
67 | 0.015
68 |
69 |
70 | Gravel
71 | 0.80
72 | 0.93
73 |
74 |
75 | Mud
76 | 0.80
77 | 0.93
78 |
79 |
80 | WaterShallow
81 | 0.93
82 | 1.06
83 |
84 |
85 | WaterDeep
86 | 1.06
87 | 999
88 |
89 |
90 |
91 |
92 |
93 | 18
94 | 0
95 | 0
96 | 0
97 | 0
98 | 0
99 | 0
100 | 0
101 |
102 |
103 | 3.0
104 | 3.0
105 | 3.0
106 | 3.0
107 | 0.5
108 |
109 |
110 | 1
111 | 0.3
112 | 0.15
113 |
114 |
115 |
--------------------------------------------------------------------------------
/Common/Defs/BiomeDef/UpperBiome.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ZL_UpperBiome
5 | Upper
6 | Upper.
7 | ZLevels.BiomeWorker_NeverSpawn
8 | 0
9 | 0
10 | 0
11 | 1
12 | World/Biomes/TemperateForest
13 | 0
14 | 20
15 |
16 | Ambient_NightInsects_Standard
17 |
18 | 50
19 |
20 |
21 | Disease_Flu
22 | 100
23 |
24 |
25 | Disease_Plague
26 | 100
27 |
28 |
29 | Disease_Malaria
30 | 100
31 |
32 |
33 | Disease_GutWorms
34 | 50
35 |
36 |
37 | Disease_FibrousMechanites
38 | 30
39 |
40 |
41 | Disease_SensoryMechanites
42 | 30
43 |
44 |
45 | Disease_MuscleParasites
46 | 50
47 |
48 |
49 |
50 | Disease_AnimalFlu
51 | 100
52 |
53 |
54 | Disease_AnimalPlague
55 | 100
56 |
57 |
58 |
59 | 18
60 | 1
61 | 2
62 | 1
63 | 1
64 | 1
65 | 4
66 | 4
67 |
68 |
69 |
--------------------------------------------------------------------------------
/Common/Defs/Buildings/PowerTransferingColumn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ZL_PowerTransmitterColumn
6 | Power transmitter column
7 | A column capable of holding a roof. Transmits power above and below.
8 | Power
9 | Building
10 | PassThroughOnly
11 | 0.25
12 | ZLevels.Building_PowerTransmitter
13 | Normal
14 | 0
15 |
16 | 160
17 | 750
18 | 10
19 | 1.0
20 | 5
21 |
22 |
23 | Metallic
24 |
25 | 60
26 | true
27 | false
28 | false
29 | 0
30 |
31 | true
32 | false
33 |
34 |
35 | (1,1.25)
36 | (0,0,0.2)
37 | Things/Building/Furniture/Column
38 | Graphic_Single
39 |
40 | (0.3, 0.5, 0.3)
41 | (0,0,-0.23)
42 |
43 |
44 | (0.2,0.2,0.6,0.6)
45 |
46 |
47 |
48 |
49 | true
50 | true
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/Common/Defs/Buildings/Stairs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Stairs.
6 | Building
7 | Standable
8 | 0.15
9 |
10 | false
11 | true
12 |
13 | 60
14 | false
15 | Eat
16 | Normal
17 |
18 |
19 |
20 | ZL_StairsUp
21 | stairs up
22 | BuildingOnTop
23 | stairs.
24 | ZLevels.Building_StairsUp
25 |
26 | Building/LadderUp
27 | Graphic_Multi
28 | (3, 3)
29 |
30 |
31 | 375
32 | 1000
33 | 5
34 | 1.0
35 | 3
36 |
37 |
38 | Metallic
39 | Woody
40 |
41 | true
42 | 10
43 | true
44 | true
45 | 0.20
46 | 60
47 | Structure
48 |
49 |
50 |
51 | ZL_StairsDown
52 | stairs down
53 | stairs.
54 | ZLevels.Building_StairsDown
55 | Item
56 |
57 | Building/Ladder
58 | Graphic_Multi
59 | (3, 3)
60 |
61 |
62 | 375
63 | 1000
64 | 5
65 | 1.0
66 | 3
67 |
68 |
69 | Metallic
70 | Woody
71 |
72 | true
73 | 10
74 | true
75 | false
76 | 0.0
77 | 0.0
78 | 10
79 | Structure
80 |
81 |
82 |
83 | ZL_NaturalHole
84 | natural hole
85 | natural hole.
86 | ZLevels.Building_StairsDown
87 | Item
88 |
89 | Building/Ladder
90 | Graphic_Multi
91 | (3, 3)
92 |
93 |
94 | 375
95 | 5
96 | 1.0
97 | 3
98 |
99 | false
100 | false
101 | 0.0
102 | 0.0
103 | 10
104 | None
105 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/Common/Defs/GameConditions/GameConditions_Misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ZL_UndergroundCondition
6 | GameCondition_NoSunlight
7 | underground
8 | You went down to the dungeon.
9 | The eclipse is ending.
10 | One of the moons of this planet has orbited in front of the sun. An eclipse has begun.
11 | NegativeEvent
12 | true
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Common/Defs/Jobs/Jobs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ZL_GoToStairs
6 | ZLevels.JobDriver_GoToStairs
7 | Using TargetA.
8 |
9 |
10 |
11 | ZL_GoToLocation
12 | ZLevels.JobDriver_GoToLocation
13 | Going to TargetA.
14 |
15 |
16 |
17 | ZL_GoToMap
18 | ZLevels.JobDriver_GoToMap
19 | Going to TargetA.
20 |
21 |
22 |
23 | ZL_HaulThingToDest
24 | ZLevels.JobDriver_HaulThingToDest
25 | Carrying TargetA.
26 |
27 |
28 |
29 | ZL_HaulToCell
30 | ZLevels.JobDriver_HaulThingToDestAndToCell
31 | Hauling TargetA.
32 | false
33 | true
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Common/Defs/KeybindingDefs/KeyBindingCategories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ZLevels
6 | ZLevels keybinding
7 | ZLevels hotkeys
8 | true
9 |
10 | Development
11 | Game
12 | SelectionMisc
13 | MainTabs
14 | GameMapCamera
15 | Architect
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Common/Defs/KeybindingDefs/KeyBindings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ZLevels
6 |
7 |
8 |
9 | ZL_switchToUpperMap
10 | Switch to upper map
11 |
12 |
13 |
14 | ZL_switchToLowerMap
15 | Switch to lower map
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Common/Defs/MapGenerator/EmptyMap.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ZL_EmptyMap
6 |
7 | ElevationFertility
8 | TerrainUpper
9 | FindLocationUnderground
10 | Fog
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Common/Defs/MapGenerator/Underground.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ZL_Underground
6 | Underground
7 | Underground layer.
8 | ZLevels.MapParent_ZLevel
9 | World/WorldObjects/JourneyDestination
10 | true
11 | World/WorldObjects/Expanding/JourneyDestination
12 | 50
13 | true
14 | ZL_Underground
15 | false
16 |
17 |
18 |
19 | ZL_Underground
20 |
21 | ElevationFertilityUnderground
22 | CavesUnderground
23 | TerrainUnderground
24 | CavesTerrainUnderground
25 | RockChunksUnderground
26 | PlantsUnderground
27 | AnimalsUnderground
28 | CaveHives
29 | RocksFromGridUnderground
30 | FindLocationUnderground
31 | Fog
32 |
33 |
34 |
35 |
36 | ElevationFertilityUnderground
37 | 10
38 |
39 |
40 |
41 |
42 | CavesUnderground
43 | 11
44 |
45 |
46 |
47 |
48 | RocksFromGridUnderground
49 | 200
50 |
51 |
52 |
53 |
54 | TerrainUnderground
55 | 210
56 |
57 |
58 |
59 |
60 | CavesTerrainUnderground
61 | 211
62 |
63 |
64 |
65 |
66 | RockChunksUnderground
67 | 270
68 |
69 |
70 |
71 |
72 | AnimalsUnderground
73 | 1000
74 |
75 |
76 |
77 |
78 | CaveHivesUnderground
79 | 1100
80 |
81 |
82 |
83 |
84 | PlantsUnderground
85 | 800
86 |
87 |
88 |
89 |
90 | FindLocationUnderground
91 | 600
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/Common/Defs/MapGenerator/Upper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ZL_Upper
6 | Upper
7 | Upper layer.
8 | ZLevels.MapParent_ZLevel
9 | World/WorldObjects/JourneyDestination
10 | true
11 | World/WorldObjects/Expanding/JourneyDestination
12 | 50
13 | true
14 | ZL_Upper
15 | false
16 |
17 |
18 |
19 | ZL_Upper
20 |
21 | ElevationFertility
22 | TerrainUpper
23 | FindLocationUnderground
24 | Fog
25 |
26 |
27 |
28 |
29 | ElevationFertilityUpper
30 | 10
31 |
32 |
33 |
34 |
35 | TerrainUpper
36 | 210
37 |
38 |
39 |
40 |
41 | FindLocationUpper
42 | 600
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Common/Defs/TerrainDef/OutsideTerrain.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ZL_OutsideTerrain
5 | Void
6 | Terrain/FogOfWar
7 | FadeRough
8 | 350
9 | 100000
10 | MetaOverlays
11 |
12 | 0
13 |
14 | Impassable
15 | SoftGray
16 | true
17 | false
18 | false
19 | false
20 |
21 | Light
22 | Medium
23 | Heavy
24 | Diggable
25 |
26 | Filth_Dirt
27 | 0.00
28 |
29 |
30 |
31 | ZL_OutsideTerrainTwo
32 | Void
33 | Terrain/FogOfWar
34 | FadeRough
35 | 350
36 | 1
37 |
38 | 0
39 |
40 | Standable
41 | SoftGray
42 | true
43 | false
44 | false
45 | false
46 |
47 | Light
48 | Medium
49 | Heavy
50 | Diggable
51 |
52 | Filth_Dirt
53 | 0.00
54 |
55 |
--------------------------------------------------------------------------------
/Common/Defs/TerrainDef/RoofTerrain.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZL_RoofTerrain
7 | roof
8 | (108,78,55)
9 | 220
10 | Wood plank roofing. While it is quick to lay, not very sturdy.
11 | Terrain/Surfaces/WoodFloor
12 |
13 | -1
14 |
15 | 1
16 | true
17 | Bridge_Collapse
18 | Bridge_CollapseWater
19 |
20 |
21 |
45 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseSimplified/DefInjected/BiomeDef/UndergroundBiome.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 地下
5 | 这里只有岩石,是开矿的理想场所。没有自然生物能够在这里生存。
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseSimplified/DefInjected/BiomeDef/UpperBiome.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 上面的
5 | 上面的。
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseSimplified/DefInjected/GameConditionDef/GameConditions_Misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 地下
5 | 你进入了地牢。
6 | 日食即将结束。
7 | 这颗行星的一颗卫星在太阳前方绕轨道运行。日食已经开始了。
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseSimplified/DefInjected/JobDef/Stairs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 通过 TargetA.
5 | 通过 TargetA.
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseSimplified/DefInjected/KeyBindingCategoryDef/KeyBindingCategories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ZLevels解锁
5 | ZLevels热键
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseSimplified/DefInjected/KeyBindingDef/KeyBindings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 切换到上面的地图
5 | 切换到下面的地图
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseSimplified/DefInjected/TerrainDef/OutsideTerrain.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 空的
5 | 空的
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseSimplified/DefInjected/TerrainDef/RoofTerrain.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 屋顶
5 | 木制屋顶。虽然铺设很快但不太结实。
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseSimplified/DefInjected/ThingDef/Stairs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 上楼楼梯
5 | 楼梯。
6 |
7 | 下楼楼梯
8 | 楼梯。
9 |
10 | 天然洞穴
11 | 天然洞穴。
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseSimplified/DefInjected/WorldObjectDef/Underground.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 地下
5 | 地下一层。
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseSimplified/DefInjected/WorldObjectDef/Upper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 楼上
5 | 楼上一层。
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseSimplified/Keyed/Keyed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 你确定要放弃这张地图吗?你可以从保存的预置中恢复。
5 | 上楼
6 | 下楼
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseTraditional/DefInjected/BiomeDef/UndergroundBiome.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 地下
5 | 岩石以外空無一物,礦工的夢想之地。沒有生物能於此自然生存。
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseTraditional/DefInjected/BiomeDef/UpperBiome.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 上層。
5 | 上層。
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseTraditional/DefInjected/GameConditionDef/GameConditions_Misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 地下
5 | 你進入了地下城。
6 | 日蝕即將結束。
7 | 一顆運行中的衛星阻擋了太陽光,日蝕開始了。
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseTraditional/DefInjected/JobDef/Jobs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 通過 TargetA.
5 | 通過 TargetA.
6 | 運送 TargetA.
7 | 運送 TargetA.
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseTraditional/DefInjected/KeyBindingCategoryDef/KeyBindingCategories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ZLevels 熱鍵
5 | ZLevels 熱鍵
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseTraditional/DefInjected/KeyBindingDef/KeyBindings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 切換至上層地圖
5 | 切換至下層地圖
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseTraditional/DefInjected/TerrainDef/OutsideTerrain.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 空的
5 | 空的
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseTraditional/DefInjected/TerrainDef/RoofTerrain.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 屋頂
5 | 木製屋頂。雖然能夠快速鋪設,但並不牢固。
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseTraditional/DefInjected/ThingDef/PowerTransferingColumn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 電力輸送柱
5 | 支撐屋頂的柱子,而且能上下輸送電力。
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseTraditional/DefInjected/ThingDef/Stairs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 上樓樓梯
5 | 樓梯。
6 |
7 | 下樓樓梯
8 | 樓梯。
9 |
10 | 天然洞穴
11 | 天然洞穴。
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseTraditional/DefInjected/WorldObjectDef/Underground.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 地下
5 | 地下。
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseTraditional/DefInjected/WorldObjectDef/Upper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 樓上
5 | 樓上一層。
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Common/Languages/ChineseTraditional/Keyed/Keyed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 你確定要放棄這張地圖嗎?你可以從保存的預設中恢復。
5 | 上樓
6 | 下樓
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Common/Languages/English/Keyed/Keyed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Are you sure you want to abandon the map? It can then be restored from the saved preset.
5 | Are you sure you want to permamently abandon the map? It cannot be restored later from the preset.
6 | Go Up
7 | Go Down
8 | Enable debug logging
9 | Go here usingLabel stairs
10 | Allow Z-Levels Infestation
11 |
12 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/DefInjected/BiomeDef/UndergroundBiome.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 地下空間
5 | 岩以外何もない鉱山労働者の夢の場所です。ここではどんな生命体も自然な状態では生存できません。
6 |
7 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/DefInjected/BiomeDef/UpperBiome.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 上層階
5 | 上層階です。
6 |
7 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/DefInjected/GameConditionDef/GameConditions_Misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 地下空間
5 | あなたは地下に広がるダンジョンに向かった.
6 | 日食は終わろうとしている.
7 | この惑星にある月のひとつが,太陽をさえぎる位置にきました.日食の始まりです.
8 |
9 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/DefInjected/JobDef/Stairs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | TargetAを昇降中
5 | TargetAに向けて昇降中
6 | TargetAを昇降中
7 | TargetAを昇降中
8 | TargetAに運搬中
9 |
10 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/DefInjected/KeyBindingCategoryDef/KeyBindingCategories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ZLevelsのキー設定
5 | ZLevelsのキー設定です
6 |
7 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/DefInjected/KeyBindingDef/KeyBindings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 上層マップに切替
5 | 下層マップに切替
6 |
7 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/DefInjected/TerrainDef/OutsideTerrain.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 空洞
5 | 空洞
6 |
7 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/DefInjected/TerrainDef/RoofTerrain.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 天井
5 | 板葺きの屋根です。敷設するのは簡単ですが、あまり頑丈ではありません。
6 |
7 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/DefInjected/ThingDef/PowerTransferingColumn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 電力中継柱
5 | 屋根を支えられる電柱です。上下の階層に電気を伝達します。
6 | 電力中継柱 (設計)
7 | 電力中継柱 (施工)
8 | 屋根を支えられる電柱です。上下の階層に電気を伝達します。
9 |
10 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/DefInjected/ThingDef/Stairs.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/DefInjected/ThingDef/_Terrain_Extra.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 天上 (設計)
5 | 天井 (施工)
6 | 施行中
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/DefInjected/WorldObjectDef/Underground.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 地下空間
5 | 地下空間のマップ層です.
6 |
7 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/DefInjected/WorldObjectDef/Upper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 上層階
5 | 上層階のマップ層です.
6 |
7 |
--------------------------------------------------------------------------------
/Common/Languages/Japanese/Keyed/Keyed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 本当にマップを破棄しますか?保存したプリセットから復元可能です.
5 | マップを完全に破棄しますか?プリセットも削除され,後で復元することは不可能です.
6 | 階段を昇る
7 | 階段を降りる
8 | デバッグログを有効
9 | ラベル階段を使用してここに移動
10 | 上下階層の侵入を許可
11 |
12 |
--------------------------------------------------------------------------------
/Common/Languages/Russian/DefInjected/BiomeDef/UndergroundBiome.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Подземный
5 | Только камень, мечта шахтера. Никакая жизнь не может жить здесь.
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/Russian/DefInjected/BiomeDef/UpperBiome.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Верхний
5 | Верхний.
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/Russian/DefInjected/GameConditions/GameConditions_Misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Подземелье
5 | Вы спустились в подземелье.
6 | Затмение прошло.
7 | Одна из лун оказалась в точке между планетой и солнцем. Началось солнечное затмение.
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Common/Languages/Russian/DefInjected/JobDef/Stairs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Переход на TarjetA.
5 | Переход на TargetA.
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/Russian/DefInjected/KeyBindingCategoryDef/KeyBindingCategories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Горячие клавиши ZLevels
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Common/Languages/Russian/DefInjected/KeyBindingDef/KeyBindings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Переключиться на верхнюю карту
5 | Переключиться на нижнюю карту
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/Russian/DefInjected/TerrainDef/OutsideTerrain.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Пустота
5 | Пустота
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/Russian/DefInjected/TerrainDef/RoofTerrain.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | крыша
5 | Деревянные доски крыши. Строится быстро, но не очень надежно.
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/Russian/DefInjected/ThingDef/PowerTransferingColumn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Колонна передачи энергии
5 | Колонна способная поддерживать крышу. Передает энергию вверх и вниз.
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/Russian/DefInjected/ThingDef/Stairs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Лестница вверх
5 | Лестница на верхний этаж.
6 |
7 | Лестница вниз
8 | Лестница на нижний этаж.
9 |
10 | Естественная дыра
11 | Естественная дыра.
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Common/Languages/Russian/DefInjected/WorldObjectDef/Underground.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Подземный этаж
5 | Подземный слой.
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/Russian/DefInjected/WorldObjectDef/Upper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Верхний этаж
5 | Верхний слой.
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Common/Languages/Russian/Keyed/Keyed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Вы уверены, что хотите отказаться от карты? Затем её можно восстановить из сохраненного пресета.
5 | Вы уверены, что хотите навсегда отказаться от карты? Она не может быть восстановлена позже из предустановки.
6 | Поднятся
7 | Спустится
8 |
9 |
--------------------------------------------------------------------------------
/Common/Textures/Building/LadderUp_north.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Common/Textures/Building/LadderUp_north.png
--------------------------------------------------------------------------------
/Common/Textures/Building/LadderUp_northm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Common/Textures/Building/LadderUp_northm.png
--------------------------------------------------------------------------------
/Common/Textures/Building/LadderUp_west.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Common/Textures/Building/LadderUp_west.png
--------------------------------------------------------------------------------
/Common/Textures/Building/LadderUp_westm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Common/Textures/Building/LadderUp_westm.png
--------------------------------------------------------------------------------
/Common/Textures/Building/Ladder_north.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Common/Textures/Building/Ladder_north.png
--------------------------------------------------------------------------------
/Common/Textures/Building/Ladder_northm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Common/Textures/Building/Ladder_northm.png
--------------------------------------------------------------------------------
/Common/Textures/Building/Ladder_west.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Common/Textures/Building/Ladder_west.png
--------------------------------------------------------------------------------
/Common/Textures/Building/Ladder_westm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Common/Textures/Building/Ladder_westm.png
--------------------------------------------------------------------------------
/Common/Textures/Terrain/FogOfWar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Common/Textures/Terrain/FogOfWar.png
--------------------------------------------------------------------------------
/Common/Textures/Terrain/FogOfWar1 (2).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Common/Textures/Terrain/FogOfWar1 (2).png
--------------------------------------------------------------------------------
/Common/Textures/Terrain/FogOfWar_bac.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Common/Textures/Terrain/FogOfWar_bac.png
--------------------------------------------------------------------------------
/LoadFolders.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Common
5 | 1.1
6 |
7 |
8 | Common
9 | 1.2
10 |
11 |
12 | Common
13 | 1.3
14 |
15 |
--------------------------------------------------------------------------------
/Source/ZLevels/Refs/0Harmony.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Source/ZLevels/Refs/0Harmony.dll
--------------------------------------------------------------------------------
/Source/ZLevels/Refs/Assembly-CSharp_publicized.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Source/ZLevels/Refs/Assembly-CSharp_publicized.dll
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30104.148
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZLevels", "ZLevels\ZLevels.csproj", "{4AADF459-3D4F-4729-9249-7A2EFA09C493}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {4AADF459-3D4F-4729-9249-7A2EFA09C493}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {4AADF459-3D4F-4729-9249-7A2EFA09C493}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {4AADF459-3D4F-4729-9249-7A2EFA09C493}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {4AADF459-3D4F-4729-9249-7A2EFA09C493}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {DAA9123A-071C-4646-96B1-6AA70F13A19F}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/ActiveArea.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Verse;
4 |
5 | namespace ZLevels
6 | {
7 | public class ActiveArea : IExposable
8 | {
9 | public ActiveArea()
10 | {
11 | }
12 |
13 | public void ExposeData()
14 | {
15 | if (Scribe.mode == LoadSaveMode.Saving && this.activeAreas != null)
16 | {
17 | this.activeAreas.RemoveAll(x => x.Value == null);
18 | }
19 | Scribe_Collections.Look(ref this.activeAreas, "activeAreas", LookMode.Reference, LookMode.Reference);
20 | }
21 |
22 | public Dictionary activeAreas;
23 | }
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/Buildings/Building_StairsDown.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using HarmonyLib;
7 | using Multiplayer.API;
8 | using RimWorld;
9 | using RimWorld.Planet;
10 | using Verse;
11 | using Verse.AI;
12 |
13 | namespace ZLevels
14 | {
15 | public class Building_StairsDown : Building_Stairs, IAttackTarget
16 | {
17 | public override void SpawnSetup(Map map, bool respawningAfterLoad)
18 | {
19 | base.SpawnSetup(map, respawningAfterLoad);
20 | var ZTracker = ZUtils.ZTracker;
21 | ZTracker.totalStairsDown = new HashSet();
22 | ZTracker.stairsDown = new Dictionary>();
23 |
24 | //if (ZTracker.totalStairsDown == null) ZTracker.totalStairsDown = new HashSet();
25 | //ZTracker.totalStairsDown.Add(this);
26 | //
27 | //foreach (var stairsPair in ZTracker.stairsDown)
28 | //{
29 | // if (stairsPair.Key != map && stairsPair.Value.Contains(this))
30 | // {
31 | // ZTracker.stairsDown[stairsPair.Key].Remove(this);
32 | // }
33 | //}
34 | //
35 | //if (!ZTracker.stairsDown.ContainsKey(this.Map))
36 | //{
37 | // ZTracker.stairsDown[this.Map] = new List();
38 | //}
39 | //if (!ZTracker.stairsDown[this.Map].Contains(this))
40 | //{
41 | // ZTracker.stairsDown[this.Map].Add(this);
42 | //}
43 |
44 |
45 | if (!respawningAfterLoad)
46 | {
47 | if (this.Position.GetTerrain(this.Map) == ZLevelsDefOf.ZL_OutsideTerrain)
48 | {
49 | this.Map.terrainGrid.SetTerrain(this.Position, ZLevelsDefOf.ZL_OutsideTerrainTwo);
50 | }
51 | Map mapBelow = ZTracker.GetLowerLevel(this.Map.Tile, this.Map);
52 | if (mapBelow != null && mapBelow != this.Map && this.def.defName == "FC_StairsDown")
53 | {
54 | for (int i = mapBelow.thingGrid.ThingsListAt(this.Position).Count - 1; i >= 0; i--)
55 | {
56 | Thing thing = mapBelow.thingGrid.ThingsListAt(this.Position)[i];
57 | if (thing is Mineable)
58 | {
59 | if (thing.Spawned)
60 | {
61 | thing.DeSpawn(DestroyMode.WillReplace);
62 | }
63 | }
64 | }
65 | if (!this.Position.GetThingList(mapBelow).Any(x => x.def == ZLevelsDefOf.ZL_StairsUp))
66 | {
67 | var stairsToSpawn = ThingMaker.MakeThing(ZLevelsDefOf.ZL_StairsUp, this.Stuff);
68 | mapBelow.terrainGrid.SetTerrain(this.Position, ZLevelsDefOf.ZL_OutsideTerrainTwo);
69 | GenPlace.TryPlaceThing(stairsToSpawn, this.Position, mapBelow, ThingPlaceMode.Direct);
70 | stairsToSpawn.SetFaction(this.Faction);
71 | }
72 | FloodFillerFog.FloodUnfog(this.Position, mapBelow);
73 | mapBelow.fogGrid.FloodUnfogAdjacent(this.Position);
74 | }
75 | else if (mapBelow == this.Map)
76 | {
77 | Log.Error("There was a mismatch of ZLevels indices. This is a serious error, report it to the mod developers");
78 | foreach (var map2 in ZTracker.GetAllMaps(this.Map.Tile))
79 | {
80 | ZLogger.Message("Index: " + ZTracker.GetMapInfo(map2));
81 | }
82 | }
83 | }
84 | }
85 |
86 | public override Building_Stairs GetMatchingStair()
87 | {
88 | Map upperMap = ZUtils.ZTracker.GetUpperLevel(this.Map.Tile, this.Map);
89 | if (upperMap != null)
90 | {
91 | return (Building_StairsUp)this.Position.GetThingList(upperMap).FirstOrFallback(x => x is Building_StairsUp);
92 | }
93 | return null;
94 | }
95 |
96 | public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
97 | {
98 | var ZTracker = ZUtils.ZTracker;
99 | if (ZTracker.stairsDown.TryGetValue(this.Map, out var stairsDown) && stairsDown.Contains(this))
100 | {
101 | ZTracker.stairsDown[this.Map].Remove(this);
102 | }
103 | if (this.Position.GetTerrain(this.Map) == ZLevelsDefOf.ZL_OutsideTerrainTwo)
104 | {
105 | this.Map.terrainGrid.SetTerrain(this.Position, ZLevelsDefOf.ZL_OutsideTerrain);
106 | }
107 | base.Destroy(mode);
108 | }
109 |
110 | public void GiveJob(Pawn pawn, Thing stairs)
111 | {
112 | Job job = JobMaker.MakeJob(ZLevelsDefOf.ZL_GoToStairs, stairs);
113 | pawn.jobs.StartJob(job, JobCondition.InterruptForced);
114 | }
115 |
116 | public override IEnumerable GetFloatMenuOptions(Pawn selPawn)
117 | {
118 | var text = "GoDown".Translate();
119 | foreach (var opt in base.GetFloatMenuOptions(selPawn))
120 | {
121 | if (opt.Label != text)
122 | {
123 | yield return opt;
124 | }
125 | }
126 | var opt2 = new FloatMenuOption(text, () =>
127 | {
128 | GiveJob(selPawn, this);
129 | }, MenuOptionPriority.Default, null, this);
130 | yield return opt2;
131 | }
132 |
133 | public override void ExposeData()
134 | {
135 | base.ExposeData();
136 | Scribe_Values.Look(ref this.shouldSpawnStairsBelow, "shouldSpawnStairsBelow", true);
137 | Scribe_Values.Look(ref this.visited, "visited", false);
138 | Scribe_Values.Look(ref this.pathToPreset, "pathToPreset", null);
139 | Scribe_Deep.Look(ref this.infestationData, "infestationData", null);
140 | Scribe_Collections.Look(ref this.visitedPawns, "visitedPawns");
141 | }
142 |
143 | public HashSet visitedPawns = new HashSet();
144 | public string pathToPreset = "";
145 | public bool shouldSpawnStairsBelow = true;
146 | public InfestationData infestationData;
147 | public bool visited = false;
148 |
149 | Thing IAttackTarget.Thing
150 | {
151 | get
152 | {
153 | return this;
154 | }
155 | }
156 | public LocalTargetInfo TargetCurrentlyAimingAt
157 | {
158 | get
159 | {
160 | return LocalTargetInfo.Invalid;
161 | }
162 | }
163 |
164 | public float TargetPriorityFactor
165 | {
166 | get
167 | {
168 | return 0f;
169 | }
170 | }
171 |
172 | public bool ThreatDisabled(IAttackTargetSearcher disabledFor)
173 | {
174 | return true;
175 | }
176 | }
177 | }
178 |
179 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/DebugLevel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using Verse;
4 |
5 | namespace ZLevels
6 | {
7 | public enum DebugLevel : byte
8 | {
9 | None,
10 | All,
11 | Jobs,
12 | Combat,
13 | Pathfinding
14 | }
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/GenSteps/GenStep_Animals.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using RimWorld;
4 | using Verse;
5 |
6 | namespace ZLevels
7 | {
8 | public class GenStep_AnimalsUnderground : GenStep
9 | {
10 | public override int SeedPart => 1298760307;
11 |
12 | public override void Generate(Map map, GenStepParams parms)
13 | {
14 | int num = 0;
15 | var mapParent = map.Parent as MapParent_ZLevel;
16 | if (mapParent.hasCaves)
17 | {
18 | int infestationCount = 0;
19 | if (mapParent.TotalInfestations != null && mapParent.TotalInfestations.Count > 0)
20 | {
21 | infestationCount = mapParent.TotalInfestations.Count;
22 | }
23 | var index = 0;
24 | while (true)
25 | {
26 | if (!map.wildAnimalSpawner.AnimalEcosystemFull)
27 | {
28 | num++;
29 | if (num >= 10000)
30 | {
31 | break;
32 | }
33 | IntVec3 loc = IntVec3.Invalid;
34 | if (infestationCount > 0 && index < infestationCount && CellFinder.TryFindRandomCellNear
35 | (mapParent.TotalInfestations[index].infestationPlace, map, 100,
36 | (IntVec3 c) => c.Walkable(map), out loc))
37 | {
38 | ZLogger.Message("Found loc: " + loc
39 | + " origin place: " + mapParent.TotalInfestations[index].infestationPlace);
40 | index++;
41 | }
42 | else
43 | {
44 | loc = RCellFinder.RandomAnimalSpawnCell_MapGen(map);
45 | }
46 | if (!map.wildAnimalSpawner.SpawnRandomWildAnimalAt(loc))
47 | {
48 | ZLogger.Message("Spawning in loc: " + loc);
49 | return;
50 | }
51 | ZLogger.Message("Spawning in loc: " + loc);
52 | continue;
53 | }
54 | return;
55 | }
56 | Log.Error("Too many iterations.");
57 | }
58 | }
59 | }
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/GenSteps/GenStep_CaveHives.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using RimWorld;
4 | using Verse;
5 |
6 | namespace ZLevels
7 | {
8 | public class GenStep_CaveHivesUnderground : GenStep
9 | {
10 | private List rockCells = new List();
11 |
12 | private List possibleSpawnCells = new List();
13 |
14 | private List spawnedHives = new List();
15 |
16 | private const int MinDistToOpenSpace = 10;
17 |
18 | private const int MinDistFromFactionBase = 50;
19 |
20 | private const float CaveCellsPerHive = 1000f;
21 |
22 | public override int SeedPart => 349641510;
23 |
24 | public override void Generate(Map map, GenStepParams parms)
25 | {
26 | if (!Find.Storyteller.difficulty.allowCaveHives)
27 | {
28 | return;
29 | }
30 | MapGenFloatGrid caves = MapGenerator.Caves;
31 | MapGenFloatGrid elevation = MapGenerator.Elevation;
32 | float num = 0.7f;
33 | int num2 = 0;
34 | rockCells.Clear();
35 | foreach (IntVec3 allCell in map.AllCells)
36 | {
37 | if (elevation[allCell] > num)
38 | {
39 | rockCells.Add(allCell);
40 | }
41 | if (caves[allCell] > 0f)
42 | {
43 | num2++;
44 | }
45 | }
46 | List list = map.AllCells.Where((IntVec3 c) => map.thingGrid.ThingsAt(c).Any((Thing thing) => thing.Faction != null)).ToList();
47 | GenMorphology.Dilate(list, 50, map);
48 | HashSet hashSet = new HashSet(list);
49 | int num3 = GenMath.RoundRandom((float)num2 / 1000f);
50 | GenMorphology.Erode(rockCells, 10, map);
51 | possibleSpawnCells.Clear();
52 | for (int i = 0; i < rockCells.Count; i++)
53 | {
54 | if (caves[rockCells[i]] > 0f && !hashSet.Contains(rockCells[i]))
55 | {
56 | possibleSpawnCells.Add(rockCells[i]);
57 | }
58 | }
59 | spawnedHives.Clear();
60 | for (int j = 0; j < num3; j++)
61 | {
62 | TrySpawnHive(map);
63 | }
64 | spawnedHives.Clear();
65 | }
66 |
67 | private void TrySpawnHive(Map map)
68 | {
69 | if (TryFindHiveSpawnCell(map, out IntVec3 spawnCell))
70 | {
71 | possibleSpawnCells.Remove(spawnCell);
72 | Hive hive = (Hive)GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.Hive), spawnCell, map);
73 | hive.SetFaction(Faction.OfInsects);
74 | hive.PawnSpawner.aggressive = false;
75 | (from x in hive.GetComps()
76 | where x.PropsSpawner.thingToSpawn == ThingDefOf.GlowPod
77 | select x).First().TryDoSpawn();
78 | hive.PawnSpawner.SpawnPawnsUntilPoints(Rand.Range(200f, 500f));
79 | hive.PawnSpawner.canSpawnPawns = false;
80 | hive.GetComp().canSpawnHives = false;
81 | spawnedHives.Add(hive);
82 | }
83 | }
84 |
85 | private bool TryFindHiveSpawnCell(Map map, out IntVec3 spawnCell)
86 | {
87 | float num = -1f;
88 | IntVec3 intVec = IntVec3.Invalid;
89 | for (int i = 0; i < 3; i++)
90 | {
91 | if (!possibleSpawnCells.Where((IntVec3 x) => x.Standable(map) && x.GetFirstItem(map) == null && x.GetFirstBuilding(map) == null && x.GetFirstPawn(map) == null).TryRandomElement(out IntVec3 result))
92 | {
93 | break;
94 | }
95 | float num2 = -1f;
96 | for (int j = 0; j < spawnedHives.Count; j++)
97 | {
98 | float num3 = result.DistanceToSquared(spawnedHives[j].Position);
99 | if (num2 < 0f || num3 < num2)
100 | {
101 | num2 = num3;
102 | }
103 | }
104 | if (!intVec.IsValid || num2 > num)
105 | {
106 | intVec = result;
107 | num = num2;
108 | }
109 | }
110 | spawnCell = intVec;
111 | return spawnCell.IsValid;
112 | }
113 | }
114 | }
115 |
116 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/GenSteps/GenStep_CavesTerrain.cs:
--------------------------------------------------------------------------------
1 | using RimWorld;
2 | using Verse;
3 | using Verse.Noise;
4 |
5 | namespace ZLevels
6 | {
7 | public class GenStep_CavesTerrainUnderground : GenStep
8 | {
9 | private const float WaterFrequency = 0.08f;
10 |
11 | private const float GravelFrequency = 0.16f;
12 |
13 | private const float WaterThreshold = 0.93f;
14 |
15 | private const float GravelThreshold = 0.55f;
16 |
17 | public override int SeedPart => 1921024373;
18 |
19 | public override void Generate(Map map, GenStepParams parms)
20 | {
21 | if (Find.World.HasCaves(map.Tile))
22 | {
23 | Perlin perlin = new Perlin(0.079999998211860657, 2.0, 0.5, 6, Rand.Int, QualityMode.Medium);
24 | Perlin perlin2 = new Perlin(0.15999999642372131, 2.0, 0.5, 6, Rand.Int, QualityMode.Medium);
25 | MapGenFloatGrid caves = MapGenerator.Caves;
26 | foreach (IntVec3 allCell in map.AllCells)
27 | {
28 | if (!(caves[allCell] <= 0f) && !allCell.GetTerrain(map).IsRiver)
29 | {
30 | float num = (float)perlin.GetValue(allCell.x, 0.0, allCell.z);
31 | float num2 = (float)perlin2.GetValue(allCell.x, 0.0, allCell.z);
32 | if (num > 0.93f)
33 | {
34 | map.terrainGrid.SetTerrain(allCell, TerrainDefOf.WaterShallow);
35 | }
36 | else if (num2 > 0.55f)
37 | {
38 | map.terrainGrid.SetTerrain(allCell, TerrainDefOf.Gravel);
39 | }
40 | }
41 | }
42 | }
43 | }
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/GenSteps/GenStep_ElevationFertility.cs:
--------------------------------------------------------------------------------
1 | using RimWorld;
2 | using RimWorld.Planet;
3 | using UnityEngine;
4 | using Verse;
5 | using Verse.Noise;
6 |
7 | namespace ZLevels
8 | {
9 | public class GenStep_ElevationFertilityUnderground : GenStep
10 | {
11 | private const float ElevationFreq = 0.021f;
12 |
13 | private const float FertilityFreq = 0.021f;
14 |
15 | private const float EdgeMountainSpan = 0.42f;
16 |
17 | public override int SeedPart => 826504671;
18 |
19 | public override void Generate(Map map, GenStepParams parms)
20 | {
21 | NoiseRenderer.renderSize = new IntVec2(map.Size.x, map.Size.z);
22 | ModuleBase input = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);
23 | input = new ScaleBias(0.5, 0.5, input);
24 | NoiseDebugUI.StoreNoiseRender(input, "elev base");
25 | float num = 1f;
26 | switch (map.TileInfo.hilliness)
27 | {
28 | case Hilliness.Flat:
29 | num = MapGenTuning.ElevationFactorFlat;
30 | break;
31 | case Hilliness.SmallHills:
32 | num = MapGenTuning.ElevationFactorSmallHills;
33 | break;
34 | case Hilliness.LargeHills:
35 | num = MapGenTuning.ElevationFactorLargeHills;
36 | break;
37 | case Hilliness.Mountainous:
38 | num = MapGenTuning.ElevationFactorMountains;
39 | break;
40 | case Hilliness.Impassable:
41 | num = MapGenTuning.ElevationFactorImpassableMountains;
42 | break;
43 | }
44 | input = new Multiply(input, new Const(num));
45 | NoiseDebugUI.StoreNoiseRender(input, "elev world-factored");
46 | if (map.TileInfo.hilliness == Hilliness.Mountainous || map.TileInfo.hilliness == Hilliness.Impassable)
47 | {
48 | ModuleBase input2 = new DistFromAxis((float)map.Size.x * 0.42f);
49 | input2 = new Clamp(0.0, 1.0, input2);
50 | input2 = new Invert(input2);
51 | input2 = new ScaleBias(1.0, 1.0, input2);
52 | Rot4 random;
53 | do
54 | {
55 | random = Rot4.Random;
56 | }
57 | while (random == Find.World.CoastDirectionAt(map.Tile));
58 | if (random == Rot4.North)
59 | {
60 | input2 = new Rotate(0.0, 90.0, 0.0, input2);
61 | input2 = new Translate(0.0, 0.0, -map.Size.z, input2);
62 | }
63 | else if (random == Rot4.East)
64 | {
65 | input2 = new Translate(-map.Size.x, 0.0, 0.0, input2);
66 | }
67 | else if (random == Rot4.South)
68 | {
69 | input2 = new Rotate(0.0, 90.0, 0.0, input2);
70 | }
71 | else
72 | {
73 | _ = (random == Rot4.West);
74 | }
75 | NoiseDebugUI.StoreNoiseRender(input2, "mountain");
76 | input = new Add(input, input2);
77 | NoiseDebugUI.StoreNoiseRender(input, "elev + mountain");
78 | }
79 | float b = map.TileInfo.WaterCovered ? 0f : float.MaxValue;
80 | MapGenFloatGrid elevation = MapGenerator.Elevation;
81 | foreach (IntVec3 allCell in map.AllCells)
82 | {
83 | elevation[allCell] = Mathf.Min(input.GetValue(allCell), b);
84 | }
85 | ModuleBase input3 = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);
86 | input3 = new ScaleBias(0.5, 0.5, input3);
87 | NoiseDebugUI.StoreNoiseRender(input3, "noiseFert base");
88 | MapGenFloatGrid fertility = MapGenerator.Fertility;
89 | foreach (IntVec3 allCell2 in map.AllCells)
90 | {
91 | fertility[allCell2] = input3.GetValue(allCell2);
92 | }
93 | }
94 | }
95 | }
96 |
97 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/GenSteps/GenStep_FindLocationUnderground.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Verse;
3 |
4 | namespace ZLevels
5 | {
6 | public class GenStep_FindLocationUnderground : GenStep
7 | {
8 | public override int SeedPart
9 | {
10 | get
11 | {
12 | return 820815231;
13 | }
14 | }
15 |
16 | public override void Generate(Map map, GenStepParams parms)
17 | {
18 | DeepProfiler.Start("RebuildAllRegions");
19 | map.regionAndRoomUpdater.RebuildAllRegionsAndRooms();
20 | DeepProfiler.End();
21 | MapGenerator.PlayerStartSpot = ((MapParent_ZLevel)map.Parent).PlayerStartSpot;
22 | }
23 | }
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/GenSteps/GenStep_Plants.cs:
--------------------------------------------------------------------------------
1 | using Verse;
2 |
3 | namespace ZLevels
4 | {
5 | public class GenStep_PlantsUnderground : GenStep
6 | {
7 | private const float ChanceToSkip = 0.001f;
8 |
9 | public override int SeedPart => 578415222;
10 |
11 | public override void Generate(Map map, GenStepParams parms)
12 | {
13 | map.regionAndRoomUpdater.Enabled = false;
14 | float currentPlantDensity = map.wildPlantSpawner.CurrentPlantDensity;
15 | float currentWholeMapNumDesiredPlants = map.wildPlantSpawner.CurrentWholeMapNumDesiredPlants;
16 | foreach (IntVec3 item in map.cellsInRandomOrder.GetAll())
17 | {
18 | map.wildPlantSpawner.CheckSpawnWildPlantAt(item, currentPlantDensity, currentWholeMapNumDesiredPlants, setRandomGrowth: true);
19 | }
20 | map.regionAndRoomUpdater.Enabled = true;
21 | }
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/GenSteps/GenStep_RockChunks.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using RimWorld;
3 | using Verse;
4 | using Verse.Noise;
5 |
6 | namespace ZLevels
7 | {
8 | public class GenStep_RockChunksUnderground : GenStep
9 | {
10 | private ModuleBase freqFactorNoise;
11 |
12 | private const float ThreshLooseRock = 0.55f;
13 |
14 | private const float PlaceProbabilityPerCell = 0.006f;
15 |
16 | private const float RubbleProbability = 0.5f;
17 |
18 | public override int SeedPart => 1898758716;
19 |
20 | public override void Generate(Map map, GenStepParams parms)
21 | {
22 | if (!map.TileInfo.WaterCovered)
23 | {
24 | freqFactorNoise = new Perlin(0.014999999664723873, 2.0, 0.5, 6, Rand.Range(0, 999999), QualityMode.Medium);
25 | freqFactorNoise = new ScaleBias(1.0, 1.0, freqFactorNoise);
26 | NoiseDebugUI.StoreNoiseRender(freqFactorNoise, "rock_chunks_freq_factor");
27 | MapGenFloatGrid elevation = MapGenerator.Elevation;
28 | foreach (IntVec3 allCell in map.AllCells)
29 | {
30 | float num = 0.006f * freqFactorNoise.GetValue(allCell);
31 | if (elevation[allCell] < 0.55f && Rand.Value < num)
32 | {
33 | GrowLowRockFormationFrom(allCell, map);
34 | }
35 | }
36 | freqFactorNoise = null;
37 | }
38 | }
39 |
40 | private void GrowLowRockFormationFrom(IntVec3 root, Map map)
41 | {
42 | ThingDef filth_RubbleRock = ThingDefOf.Filth_RubbleRock;
43 | ThingDef mineableThing = Find.World.NaturalRockTypesIn(map.Tile).RandomElement().building.mineableThing;
44 | Rot4 random = Rot4.Random;
45 | MapGenFloatGrid elevation = MapGenerator.Elevation;
46 | IntVec3 intVec = root;
47 | while (true)
48 | {
49 | Rot4 random2 = Rot4.Random;
50 | if (random2 == random)
51 | {
52 | continue;
53 | }
54 | intVec += random2.FacingCell;
55 | if (!intVec.InBounds(map) || intVec.GetEdifice(map) != null || intVec.GetFirstItem(map) != null || elevation[intVec] > 0.55f || !map.terrainGrid.TerrainAt(intVec).affordances.Contains(TerrainAffordanceDefOf.Heavy))
56 | {
57 | break;
58 | }
59 | GenSpawn.Spawn(mineableThing, intVec, map);
60 | IntVec3[] adjacentCellsAndInside = GenAdj.AdjacentCellsAndInside;
61 | foreach (IntVec3 b in adjacentCellsAndInside)
62 | {
63 | if (!(Rand.Value < 0.5f))
64 | {
65 | continue;
66 | }
67 | IntVec3 c = intVec + b;
68 | if (!c.InBounds(map))
69 | {
70 | continue;
71 | }
72 | bool flag = false;
73 | List thingList = c.GetThingList(map);
74 | for (int j = 0; j < thingList.Count; j++)
75 | {
76 | Thing thing = thingList[j];
77 | if (thing.def.category != ThingCategory.Plant && thing.def.category != ThingCategory.Item && thing.def.category != ThingCategory.Pawn)
78 | {
79 | flag = true;
80 | break;
81 | }
82 | }
83 | if (!flag)
84 | {
85 | FilthMaker.TryMakeFilth(c, map, filth_RubbleRock);
86 | }
87 | }
88 | }
89 | }
90 | }
91 | }
92 |
93 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/GenSteps/GenStep_RocksFromGrid.cs:
--------------------------------------------------------------------------------
1 | using RimWorld;
2 | using RimWorld.Planet;
3 | using System.Collections.Generic;
4 | using Verse;
5 |
6 | namespace ZLevels
7 | {
8 | public class GenStep_RocksFromGridUnderground : GenStep
9 | {
10 | private class RoofThreshold
11 | {
12 | public RoofDef roofDef;
13 |
14 | public float minGridVal;
15 | }
16 |
17 | private float maxMineableValue = float.MaxValue;
18 |
19 | private const int MinRoofedCellsPerGroup = 20;
20 |
21 | public override int SeedPart => 1182952823;
22 |
23 | public static ThingDef RockDefAt(IntVec3 c)
24 | {
25 | ThingDef thingDef = null;
26 | float num = -999999f;
27 | for (int i = 0; i < RockNoises.rockNoises.Count; i++)
28 | {
29 | float value = RockNoises.rockNoises[i].noise.GetValue(c);
30 | if (value > num)
31 | {
32 | thingDef = RockNoises.rockNoises[i].rockDef;
33 | num = value;
34 | }
35 | }
36 | if (thingDef == null)
37 | {
38 | ZLogger.ErrorOnce("Did not get rock def to generate at " + c);
39 | thingDef = ThingDefOf.Sandstone;
40 | }
41 | return thingDef;
42 | }
43 |
44 | public override void Generate(Map map, GenStepParams parms)
45 | {
46 | map.regionAndRoomUpdater.Enabled = false;
47 | float num = 0.7f;
48 | List list = new List();
49 | RoofThreshold roofThreshold = new RoofThreshold
50 | {
51 | roofDef = RoofDefOf.RoofRockThick,
52 | minGridVal = num * 1.14f
53 | };
54 | list.Add(roofThreshold);
55 | RoofThreshold roofThreshold2 = new RoofThreshold
56 | {
57 | roofDef = RoofDefOf.RoofRockThin,
58 | minGridVal = num * 1.04f
59 | };
60 | list.Add(roofThreshold2);
61 | MapGenFloatGrid elevation = MapGenerator.Elevation;
62 | MapGenFloatGrid caves = MapGenerator.Caves;
63 | foreach (IntVec3 allCell in map.AllCells)
64 | {
65 | if (caves[allCell] <= 0f)
66 | {
67 | GenSpawn.Spawn(RockDefAt(allCell), allCell, map);
68 | }
69 | map.roofGrid.SetRoof(allCell, RoofDefOf.RoofRockThick);
70 | }
71 | BoolGrid visited = new BoolGrid(map);
72 | List toRemove = new List();
73 | foreach (IntVec3 allCell2 in map.AllCells)
74 | {
75 | if (!visited[allCell2] && IsNaturalRoofAt(allCell2, map))
76 | {
77 | toRemove.Clear();
78 | map.floodFiller.FloodFill(allCell2, (IntVec3 x) => IsNaturalRoofAt(x, map), delegate(IntVec3 x)
79 | {
80 | visited[x] = true;
81 | toRemove.Add(x);
82 | });
83 | if (toRemove.Count < 20)
84 | {
85 | for (int j = 0; j < toRemove.Count; j++)
86 | {
87 | map.roofGrid.SetRoof(toRemove[j], null);
88 | }
89 | }
90 | }
91 | }
92 | GenStep_ScatterLumpsMineableUnderground genStep_ScatterLumpsMineable = new GenStep_ScatterLumpsMineableUnderground
93 | {
94 | maxValue = maxMineableValue
95 | };
96 | float num3 = 16f;
97 | genStep_ScatterLumpsMineable.countPer10kCellsRange = new FloatRange(num3, num3);
98 | genStep_ScatterLumpsMineable.Generate(map, parms);
99 | map.regionAndRoomUpdater.Enabled = true;
100 | }
101 |
102 | private bool IsNaturalRoofAt(IntVec3 c, Map map)
103 | {
104 | if (c.Roofed(map))
105 | {
106 | return c.GetRoof(map).isNatural;
107 | }
108 | return false;
109 | }
110 | }
111 | }
112 |
113 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/GenSteps/GenStep_ScatterLumpsMineable.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using RimWorld;
3 | using Verse;
4 |
5 | namespace ZLevels
6 | {
7 | public class GenStep_ScatterLumpsMineableUnderground : GenStep_Scatterer
8 | {
9 | public ThingDef forcedDefToScatter;
10 |
11 | public int forcedLumpSize;
12 |
13 | public float maxValue = float.MaxValue;
14 |
15 | [Unsaved(false)]
16 | protected List recentLumpCells = new List();
17 |
18 | public override int SeedPart => 920906419;
19 |
20 | public override void Generate(Map map, GenStepParams parms)
21 | {
22 | minSpacing = 5f;
23 | warnOnFail = false;
24 | int num = CalculateFinalCount(map);
25 | for (int i = 0; i < num; i++)
26 | {
27 | if (!TryFindScatterCell(map, out IntVec3 result))
28 | {
29 | return;
30 | }
31 | ScatterAt(result, map, parms);
32 | usedSpots.Add(result);
33 | }
34 | usedSpots.Clear();
35 | }
36 |
37 | protected ThingDef ChooseThingDef()
38 | {
39 | if (forcedDefToScatter != null)
40 | {
41 | return forcedDefToScatter;
42 | }
43 | return DefDatabase.AllDefs.RandomElementByWeightWithFallback(delegate(ThingDef d)
44 | {
45 | if (d.building == null)
46 | {
47 | return 0f;
48 | }
49 | return (d.building.mineableThing != null && d.building.mineableThing.BaseMarketValue > maxValue) ? 0f : d.building.mineableScatterCommonality;
50 | });
51 | }
52 |
53 | public override bool CanScatterAt(IntVec3 c, Map map)
54 | {
55 | if (NearUsedSpot(c, minSpacing))
56 | {
57 | return false;
58 | }
59 | Building edifice = c.GetEdifice(map);
60 | if (edifice == null || !edifice.def.building.isNaturalRock)
61 | {
62 | return false;
63 | }
64 | return true;
65 | }
66 |
67 | public override void ScatterAt(IntVec3 c, Map map, GenStepParams parms, int stackCount = 1)
68 | {
69 | ThingDef thingDef = ChooseThingDef();
70 | if (thingDef != null)
71 | {
72 | int numCells = (forcedLumpSize > 0) ? forcedLumpSize : thingDef.building.mineableScatterLumpSizeRange.RandomInRange;
73 | recentLumpCells.Clear();
74 | foreach (IntVec3 item in GridShapeMaker.IrregularLump(c, map, numCells))
75 | {
76 | GenSpawn.Spawn(thingDef, item, map);
77 | recentLumpCells.Add(item);
78 | }
79 | }
80 | }
81 | }
82 | }
83 |
84 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/HarmonyPatches/AnimalPatches.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Linq;
5 | using System.Linq.Expressions;
6 | using System.Reflection;
7 | using HarmonyLib;
8 | using RimWorld;
9 | using RimWorld.Planet;
10 | using RimWorld.QuestGen;
11 | using UnityEngine;
12 | using Verse;
13 | using Verse.AI;
14 | using Verse.AI.Group;
15 |
16 | namespace ZLevels
17 | {
18 | [StaticConstructorOnStartup]
19 | public static class AnimalPatches
20 | {
21 | [HarmonyPatch(typeof(WildAnimalSpawner), "SpawnRandomWildAnimalAt")]
22 | public class AnimalPatch2
23 | {
24 | [HarmonyPrefix]
25 | private static bool SpawnAnimalPrefix(WildAnimalSpawner __instance, ref IntVec3 loc,
26 | ref bool __result, Map ___map)
27 | {
28 | if (ZLevelsMod.settings.allowZLevelsInfestation)
29 | {
30 | try
31 | {
32 | bool result = false;
33 | var comp = ZUtils.GetMapComponentZLevel(___map);
34 | var ZTracker = ZUtils.ZTracker;
35 | if (___map.Parent is MapParent_ZLevel && comp != null
36 | && ZTracker.GetUpperLevel(___map.Tile, ___map) != null &&
37 | !ZUtils.GetMapComponentZLevel(ZTracker.GetUpperLevel(___map.Tile, ___map))
38 | .hasCavesBelow.GetValueOrDefault(false))
39 | {
40 | result = false;
41 | }
42 | else
43 | {
44 | PawnKindDef pawnKindDef = (from a in ___map.Biome.AllWildAnimals
45 | where ___map.mapTemperature.SeasonAcceptableFor(a.race)
46 | select a)
47 | .RandomElementByWeight((PawnKindDef def) =>
48 | ___map.Biome.CommonalityOfAnimal(def) / def.wildGroupSize.Average);
49 | if (pawnKindDef == null)
50 | {
51 | Log.Error("No spawnable animals right now.");
52 | result = false;
53 | }
54 | else
55 | {
56 | ZLogger.Message("Spawning animal: " + pawnKindDef + " in biome: " + ___map.Biome);
57 | int randomInRange = pawnKindDef.wildGroupSize.RandomInRange;
58 | int radius = Mathf.CeilToInt(Mathf.Sqrt((float)pawnKindDef.wildGroupSize.max));
59 | if (___map.Parent is MapParent_ZLevel && !loc.Walkable(___map))
60 | {
61 | loc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Walkable(___map), ___map);
62 | }
63 | for (int i = 0; i < randomInRange; i++)
64 | {
65 | IntVec3 loc2 = CellFinder.RandomClosewalkCellNear(loc, ___map, radius, null);
66 | GenSpawn.Spawn(PawnGenerator.GeneratePawn(pawnKindDef, null), loc2, ___map, WipeMode.Vanish);
67 | }
68 | result = true;
69 | }
70 | }
71 | __result = result;
72 | }
73 | catch (Exception ex)
74 | {
75 | Log.Error("[Z-Levels] SpawnAnimalPrefix patch produced an error. That should not happen and will break things. Send a Hugslib log to the Z-Levels developers. Error message: " + ex);
76 | }
77 | return false;
78 | }
79 | return true;
80 | }
81 | }
82 |
83 | [HarmonyPatch(typeof(IncidentWorker_Infestation), "TryExecuteWorker")]
84 | internal class Patch_Infestation_TryExecuteWorker
85 | {
86 | [HarmonyPrefix]
87 | private static bool PreFix(ref bool __result, IncidentParms parms)
88 | {
89 | if (ZLevelsMod.settings.allowZLevelsInfestation)
90 | {
91 | try
92 | {
93 | Map map = (Map)parms.target;
94 | var comp = ZUtils.GetMapComponentZLevel(map);
95 | if (comp.hasCavesBelow.HasValue && comp.hasCavesBelow.Value)
96 | {
97 | var foods = map.listerThings.AllThings.Where(x => !(x is Plant) && !(x is Pawn)
98 | && x.GetStatValue(StatDefOf.Nutrition, true) > 0.1f);
99 | if (foods != null && foods.Any())
100 | {
101 | List infestators = new List
102 | {
103 | ZLevelsDefOf.ZL_UndegroundBiome.AllWildAnimals.RandomElement()
104 | };
105 | var infestationPlace = foods.RandomElement().Position;
106 | var infestationData = new InfestationData(infestators, parms.points, infestationPlace);
107 | if (comp.ActiveInfestations == null)
108 | {
109 | comp.ActiveInfestations = new List();
110 | }
111 | comp.ActiveInfestations.Add(infestationData);
112 | if (comp.TotalInfestations == null)
113 | {
114 | comp.TotalInfestations = new List();
115 | }
116 | comp.TotalInfestations.Add(infestationData);
117 | var naturalHole = (Building_StairsDown)ThingMaker.MakeThing(ZLevelsDefOf.ZL_NaturalHole);
118 | naturalHole.infestationData = infestationData;
119 | GenSpawn.Spawn(naturalHole, infestationPlace, map, WipeMode.Vanish);
120 | Find.LetterStack.ReceiveLetter("ZLevelInfestation"
121 | .Translate(infestators.RandomElement().race.label), "ZLevelInfestationDesc".Translate(),
122 | LetterDefOf.ThreatBig, naturalHole);
123 | }
124 | }
125 | else
126 | {
127 | ZLogger.Message("The map has no caves below to generate infestation");
128 | }
129 | __result = false;
130 | }
131 | catch (Exception ex)
132 | {
133 | Log.Error("[Z-Levels] Patch_Infestation_TryExecuteWorker patch produced an error. That should not happen and will break things. Send a Hugslib log to the Z-Levels developers. Error message: " + ex);
134 | }
135 | return false;
136 | }
137 | return true;
138 | }
139 | }
140 | }
141 | }
142 |
143 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/HarmonyPatches/ColonistBarPatches.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using HarmonyLib;
6 | using RimWorld;
7 | using RimWorld.Planet;
8 | using UnityEngine;
9 | using Verse;
10 | using static RimWorld.ColonistBar;
11 |
12 | namespace ZLevels
13 | {
14 |
15 | [HarmonyPatch(typeof(ColonistBarDrawLocsFinder), "CalculateColonistsInGroup", new Type[] { typeof(int) })]
16 | public static class CalculateColonistsInGroupPatches
17 | {
18 | [HarmonyPrefix]
19 | public static void Prefix()
20 | {
21 | List list = new List();
22 | try
23 | {
24 | list = Find.ColonistBar.cachedEntries.OrderBy(x => x.map != null ? ZUtils.ZTracker.GetZIndexFor(x.map) : 9999).ToList();
25 | }
26 | finally
27 | {
28 | Find.ColonistBar.cachedEntries = list;
29 | }
30 | }
31 | }
32 |
33 | [HarmonyPatch(typeof(ColonistBar), "ColonistBarOnGUI")]
34 | public static class ColonistBarOnGUIPatch
35 | {
36 | public static Texture2D AbandonButtonTex = ContentFinder.Get("UI/Buttons/Abandon");
37 | [HarmonyPrefix]
38 | public static void Prefix(ColonistBar __instance, ref List ___cachedEntries,
39 | ref List ___cachedDrawLocs)
40 | {
41 | try
42 | {
43 | if (___cachedDrawLocs.Count == ___cachedEntries.Count)
44 | {
45 | for (int i = 0; i < ___cachedDrawLocs.Count; i++)
46 | {
47 | if (___cachedEntries[i].pawn == null && ___cachedEntries[i].map.Parent is MapParent_ZLevel)
48 | {
49 | //ZLogger.Message("Rect: " + ___cachedDrawLocs[i].x + " - " + ___cachedDrawLocs[i].y + " - "
50 | // + __instance.Size.x + " - " + __instance.Size.y);
51 | Rect rect = new Rect(___cachedDrawLocs[i].x + (__instance.Size.x / 1.25f),
52 | ___cachedDrawLocs[i].y + (__instance.Size.y / 1.25f),
53 | __instance.Size.x / 3, __instance.Size.y / 3);
54 | GUI.DrawTexture(rect, AbandonButtonTex);
55 | if (Mouse.IsOver(rect))
56 | {
57 | if (Input.GetMouseButtonDown(0) && ___cachedEntries[i].map != null)
58 | {
59 | Map map = ___cachedEntries[i].map;
60 | Find.WindowStack.Add(new Dialog_MessageBox("ZAbandonConfirmation".Translate(), "Yes".Translate(), delegate ()
61 | {
62 | var comp = ZUtils.GetMapComponentZLevel(map);
63 | var pathToWrite = Path.Combine(Path.Combine(GenFilePaths.ConfigFolderPath,
64 | "SavedMaps"), map.Tile + " - " + comp.Z_LevelIndex + ".xml");
65 | if (map.listerThings.AllThings.Count > 0)
66 | {
67 | BlueprintUtility.SaveEverything(pathToWrite, map, "SavedMap");
68 | ZLogger.Message("Removing map: " + map);
69 | }
70 | var parent = map.Parent as MapParent_ZLevel;
71 | var ZTracker = ZUtils.ZTracker;
72 | parent.Abandon();
73 | ZTracker.ZLevelsTracker[map.Tile].ZLevels.Remove(comp.Z_LevelIndex);
74 |
75 | foreach (var map2 in Find.Maps)
76 | {
77 | var comp2 = ZUtils.GetMapComponentZLevel(map2);
78 | if (ZTracker.ZLevelsTracker[map2.Tile] != null)
79 | {
80 | foreach (var d in ZTracker.ZLevelsTracker[map2.Tile].ZLevels)
81 | {
82 | ZLogger.Message(map2 + ": " + d.Key + " - " + d.Value);
83 | }
84 | }
85 | }
86 | }, "No".Translate(), null, null, false, null, null));
87 | }
88 | else if (Input.GetMouseButtonDown(1) && ___cachedEntries[i].map != null)
89 | {
90 | Map map = ___cachedEntries[i].map;
91 | Find.WindowStack.Add(new Dialog_MessageBox("ZAbandonPermanentlyConfirmation".Translate(), "Yes".Translate(), delegate ()
92 | {
93 | var comp = ZUtils.GetMapComponentZLevel(map);
94 | try
95 | {
96 | var pathToDelete = Path.Combine(Path.Combine(GenFilePaths.ConfigFolderPath,
97 | "SavedMaps"), map.Tile + " - " + comp.Z_LevelIndex + ".xml");
98 | var file = new FileInfo(pathToDelete);
99 | file.Delete();
100 | }
101 | catch
102 | {
103 |
104 | }
105 |
106 | var parent = map.Parent as MapParent_ZLevel;
107 | var ZTracker = ZUtils.ZTracker;
108 | parent.Abandon();
109 | ZTracker.ZLevelsTracker[map.Tile].ZLevels.Remove(comp.Z_LevelIndex);
110 |
111 | foreach (var map2 in Find.Maps)
112 | {
113 | var comp2 = ZUtils.GetMapComponentZLevel(map2);
114 | if (ZTracker.ZLevelsTracker[map2.Tile] != null)
115 | {
116 | foreach (var d in ZTracker.ZLevelsTracker[map2.Tile].ZLevels)
117 | {
118 | ZLogger.Message(map2 + ": " + d.Key + " - " + d.Value);
119 | }
120 | }
121 | }
122 | }, "No".Translate(), null, null, false, null, null));
123 | }
124 | }
125 | }
126 | }
127 | }
128 | }
129 | catch { };
130 | }
131 |
132 | private static bool ShowGroupFrames(List entries)
133 | {
134 | int num = -1;
135 | for (int i = 0; i < entries.Count; i++)
136 | {
137 | num = Mathf.Max(num, entries[i].group);
138 | }
139 | return num >= 1;
140 | }
141 | }
142 | }
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/HarmonyPatches/Logging.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using HarmonyLib;
5 | using RimWorld;
6 | using UnityEngine;
7 | using Verse;
8 | using Verse.AI;
9 |
10 | namespace ZLevels
11 | {
12 | [StaticConstructorOnStartup]
13 | public static class JobLogging
14 | {
15 | static JobLogging()
16 | {
17 | foreach (var type in typeof(JobDriver).AllSubclassesNonAbstract())
18 | {
19 | var method = AccessTools.Method(type, "TryMakePreToilReservations");
20 | if (method != null)
21 | {
22 | try
23 | {
24 | ZLevelsMod.harmony.Patch(method, new HarmonyMethod(AccessTools.Method(typeof(JobLogging), nameof(TryMakePreToilReservationsLog))));
25 | }
26 | catch { };
27 | }
28 | }
29 | }
30 |
31 | public static void TryMakePreToilReservationsLog(JobDriver __instance)
32 | {
33 | ZLogger.Message(__instance.pawn + " is doing TryMakePreToilReservations, job: " + __instance.job + " - jobdriver: " + __instance);
34 | }
35 | }
36 |
37 | [HarmonyPatch(typeof(Log), nameof(Log.Error), new Type[] { typeof(string) })]
38 | static class Log_Error_Patch
39 | {
40 | public static bool Prefix(string text)
41 | {
42 | if (text != null)
43 | {
44 | if (ZLogger.DebugEnabled && Current.gameInt?.tickManager != null)
45 | {
46 | Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
47 | }
48 | }
49 | else
50 | {
51 | return false;
52 | }
53 | return true;
54 | }
55 | }
56 | [HarmonyPatch(typeof(Log))]
57 | [HarmonyPatch(nameof(Log.Notify_MessageReceivedThreadedInternal))]
58 | static class Notify_MessageReceivedThreadedInternal_Patch
59 | {
60 | public static bool Prefix()
61 | {
62 | if (ZLogger.DebugEnabled)
63 | {
64 | return false;
65 | }
66 | return true;
67 | }
68 | }
69 |
70 | [HarmonyPatch(typeof(Map))]
71 | [HarmonyPatch(nameof(Map.ToString))]
72 | static class Map_ToString
73 | {
74 | public static void Postfix(Map __instance, ref string __result)
75 | {
76 | if (ZLogger.DebugEnabled)
77 | {
78 | __result = "(" + __result + " - Level " + ZUtils.ZTracker.GetZIndexFor(__instance) + ")";
79 | }
80 | }
81 | }
82 |
83 | [HarmonyPatch(typeof(WildAnimalSpawner))]
84 | [HarmonyPatch(nameof(WildAnimalSpawner.WildAnimalSpawnerTick))]
85 | static class WildAnimalSpawner_WildAnimalSpawnerTick
86 | {
87 | public static bool Prefix()
88 | {
89 | if (ZLogger.DebugEnabled)
90 | {
91 | return false;
92 | }
93 | return true;
94 | }
95 | }
96 |
97 | [HarmonyPatch(typeof(Pawn))]
98 | [HarmonyPatch(nameof(Pawn.SpawnSetup))]
99 | static class Pawn_SpawnSetup
100 | {
101 | public static bool Prefix(Pawn __instance)
102 | {
103 | if (ZLogger.DebugEnabled)
104 | {
105 | if (__instance.RaceProps.Animal)
106 | {
107 | Log.Message("Spawning: " + __instance);
108 | return false;
109 | }
110 | }
111 | return true;
112 | }
113 | }
114 | }
115 |
116 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/HarmonyPatches/MapPatches.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Linq;
5 | using System.Linq.Expressions;
6 | using System.Reflection;
7 | using System.Reflection.Emit;
8 | using HarmonyLib;
9 | using RimWorld;
10 | using RimWorld.Planet;
11 | using RimWorld.QuestGen;
12 | using UnityEngine;
13 | using Verse;
14 | using Verse.AI;
15 | using Verse.AI.Group;
16 |
17 | namespace ZLevels
18 | {
19 | [StaticConstructorOnStartup]
20 | public static class MapPatches
21 | {
22 | [HarmonyPatch(typeof(Map), "Biome", MethodType.Getter)]
23 | public class GetBiomePatch
24 | {
25 | [HarmonyPrefix]
26 | private static bool BiomePatch(Map __instance, ref BiomeDef __result)
27 | {
28 | if (__instance.ParentHolder is MapParent_ZLevel parent)
29 | {
30 | if (parent.IsUnderground)
31 | {
32 | __result = ZLevelsDefOf.ZL_UndegroundBiome;
33 | }
34 | else if (parent.IsUpperLevel)
35 | {
36 | __result = ZLevelsDefOf.ZL_UpperBiome;
37 | }
38 | else if (!parent.IsUpperLevel && !parent.IsUnderground)
39 | {
40 | if (parent.Z_LevelIndex < 0)
41 | {
42 | parent.IsUnderground = true;
43 | __result = ZLevelsDefOf.ZL_UndegroundBiome;
44 | }
45 | else if (parent.Z_LevelIndex > 0)
46 | {
47 | parent.IsUpperLevel = true;
48 | __result = ZLevelsDefOf.ZL_UpperBiome;
49 | }
50 | else if (parent.Z_LevelIndex == 0)
51 | {
52 | var ind = ZUtils.ZTracker.GetZIndexFor(__instance);
53 | if (ind < 0)
54 | {
55 | parent.IsUnderground = true;
56 | __result = ZLevelsDefOf.ZL_UndegroundBiome;
57 | }
58 | else if (ind > 0)
59 | {
60 | parent.IsUpperLevel = true;
61 | __result = ZLevelsDefOf.ZL_UpperBiome;
62 | }
63 | parent.Z_LevelIndex = ind;
64 | }
65 | }
66 | return false;
67 | }
68 | return true;
69 | }
70 | }
71 |
72 | [HarmonyPatch(typeof(Map))]
73 | [HarmonyPatch("ParentFaction", MethodType.Getter)]
74 | public class ParentFaction_Patch
75 | {
76 | [HarmonyPrefix]
77 | private static bool Prefix(Map __instance, ref Faction __result)
78 | {
79 | try
80 | {
81 | if (__instance != null && __instance.ParentHolder is MapParent_ZLevel)
82 | {
83 | __result = ZUtils.ZTracker.GetMapByIndex(__instance.Tile, 0).ParentFaction; ;
84 | return false;
85 | }
86 | }
87 | catch { };
88 | return true;
89 | }
90 | }
91 |
92 | [HarmonyPatch(typeof(ExitMapGrid))]
93 | [HarmonyPatch("MapUsesExitGrid", MethodType.Getter)]
94 | public class ExitCells_Patch
95 | {
96 | [HarmonyPrefix]
97 | private static bool Prefix(ExitMapGrid __instance, Map ___map, ref bool __result)
98 | {
99 | if (___map != null && ___map.ParentHolder is MapParent_ZLevel)
100 | {
101 | __result = false;
102 | return false;
103 | }
104 | return true;
105 | }
106 | }
107 |
108 | [HarmonyPatch(typeof(GenTemperature), "PushHeat")]
109 | [HarmonyPatch(new Type[]
110 | {
111 | typeof(Thing),
112 | typeof(float)
113 | }, new ArgumentType[]
114 | {
115 | 0,
116 | 0
117 | })]
118 | public class HeatPush_Patch
119 | {
120 | [HarmonyPrefix]
121 | private static bool Prefix(Thing t, float energy)
122 | {
123 | if (t.def == ThingDefOf.SteamGeyser && ZUtils.ZTracker.GetZIndexFor(t.Map) < 0
124 | && t.Position.GetThingList(ZUtils.ZTracker.GetUpperLevel(t.Map.Tile, t.Map)).Any(x => x.def == ThingDefOf.SteamGeyser))
125 | {
126 | return false;
127 | }
128 | return true;
129 | }
130 | }
131 |
132 | [HarmonyPatch(typeof(CompAssignableToPawn))]
133 | [HarmonyPatch("get_AssigningCandidates")]
134 | internal static class Patch_CandidatesFromAllLevels
135 | {
136 | private static void Postfix(ref IEnumerable __result, CompAssignableToPawn __instance)
137 | {
138 | if (__instance.parent.Spawned)
139 | {
140 | var list = __result.ToList();
141 | foreach (var map in ZUtils.ZTracker.GetAllMaps(__instance.parent.Map.Tile))
142 | {
143 | if (map != __instance.parent.Map)
144 | {
145 | list.AddRange(map.mapPawns.FreeColonists);
146 | }
147 | }
148 | __result = list;
149 | }
150 | }
151 | }
152 |
153 | [HarmonyPatch(typeof(Building), "SpawnSetup")]
154 | public static class SpawnSetup_Patch
155 | {
156 | public static void Postfix()
157 | {
158 | ZUtils.ZTracker.recheckStairs = true;
159 | }
160 | }
161 |
162 | [HarmonyPatch(typeof(Building), "DeSpawn")]
163 | public static class DeSpawn_Patch
164 | {
165 | public static void Postfix()
166 | {
167 | ZUtils.ZTracker.recheckStairs = true;
168 | }
169 | }
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/HarmonyPatches/PawnPatches.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Linq;
5 | using System.Linq.Expressions;
6 | using System.Reflection;
7 | using HarmonyLib;
8 | using RimWorld;
9 | using RimWorld.Planet;
10 | using RimWorld.QuestGen;
11 | using UnityEngine;
12 | using Verse;
13 | using Verse.AI;
14 | using Verse.AI.Group;
15 |
16 | namespace ZLevels
17 | {
18 | [StaticConstructorOnStartup]
19 | public static class PawnPatches
20 | {
21 | [HarmonyPatch(typeof(PawnCollisionTweenerUtility), "CanGoDirectlyToNextCell")]
22 | internal static class Patch_CanGoDirectlyToNextCell
23 | {
24 | private static Exception Finalizer(Exception __exception, Pawn pawn)
25 | {
26 | if (__exception != null)
27 | {
28 | Log.Error("Z-Levels caught an exception: " + __exception + ", trying to fix it");
29 | ZUtils.TryFixPawnError(pawn);
30 | IntVec3 nextCell = pawn.pather.nextCell;
31 | foreach (IntVec3 item in CellRect.FromLimits(nextCell, pawn.Position).ExpandedBy(1))
32 | {
33 | if (item.InBounds(pawn.Map))
34 | {
35 | List thingList = item.GetThingList(pawn.Map);
36 | for (int i = 0; i < thingList.Count; i++)
37 | {
38 | Pawn pawn2 = thingList[i] as Pawn;
39 | if (pawn2 != null && pawn2 != pawn && pawn2.GetPosture() == PawnPosture.Standing)
40 | {
41 | ZUtils.TryFixPawnError(pawn);
42 | }
43 | }
44 | }
45 | }
46 | return __exception;
47 | }
48 | return null;
49 | }
50 | }
51 |
52 | [HarmonyPatch(typeof(PawnCollisionTweenerUtility), "GetPawnsStandingAtOrAboutToStandAt")]
53 | internal static class Patch_GetPawnsStandingAtOrAboutToStandAt
54 | {
55 | private static Exception Finalizer(Exception __exception, IntVec3 at, Map map)
56 | {
57 | if (__exception != null)
58 | {
59 | foreach (IntVec3 item in CellRect.SingleCell(at).ExpandedBy(1))
60 | {
61 | if (item.InBounds(map))
62 | {
63 | List thingList = item.GetThingList(map);
64 | for (int i = 0; i < thingList.Count; i++)
65 | {
66 | Pawn pawn = thingList[i] as Pawn;
67 | if (pawn != null && pawn.GetPosture() == PawnPosture.Standing)
68 | {
69 | ZUtils.TryFixPawnError(pawn);
70 | }
71 | }
72 | }
73 | }
74 | Log.Error("Z-Levels caught an exception: " + __exception + ", trying to fix it");
75 | return __exception;
76 | }
77 | return null;
78 | }
79 | }
80 | }
81 | }
82 |
83 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/HarmonyPatches/ResourceCounterPatch.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Linq;
5 | using System.Linq.Expressions;
6 | using System.Reflection;
7 | using System.Reflection.Emit;
8 | using HarmonyLib;
9 | using RimWorld;
10 | using RimWorld.Planet;
11 | using RimWorld.QuestGen;
12 | using UnityEngine;
13 | using Verse;
14 | using Verse.AI;
15 | using Verse.AI.Group;
16 |
17 | namespace ZLevels
18 | {
19 | [StaticConstructorOnStartup]
20 | public static class ResourceCounterPatches
21 | {
22 | [HarmonyPatch(typeof(ResourceCounter))]
23 | [HarmonyPatch("UpdateResourceCounts")]
24 | public class UpdateResourceCounts_Patch
25 | {
26 | [HarmonyPrefix]
27 | private static bool Prefix(ResourceCounter __instance, Map ___map)
28 | {
29 | try
30 | {
31 | var ZTracker = ZUtils.ZTracker;
32 | if (ZTracker.ZLevelsTracker.ContainsKey(___map.Tile))
33 | {
34 | Dictionary countedAllAmounts = new Dictionary();
35 | foreach (var map1 in ZTracker.ZLevelsTracker[___map.Tile].ZLevels.Values)
36 | {
37 | if (map1.resourceCounter != null)
38 | {
39 | map1.resourceCounter.ResetResourceCounts();
40 | List allGroupsListForReading = map1.haulDestinationManager.AllGroupsListForReading;
41 | for (int i = 0; i < allGroupsListForReading.Count; i++)
42 | {
43 | foreach (Thing outerThing in allGroupsListForReading[i].HeldThings)
44 | {
45 | Thing innerIfMinified = outerThing.GetInnerIfMinified();
46 | if (innerIfMinified.def.CountAsResource && !innerIfMinified.IsNotFresh())
47 | {
48 | ThingDef def = innerIfMinified.def;
49 | if (countedAllAmounts.ContainsKey(def))
50 | {
51 | countedAllAmounts[def] += innerIfMinified.stackCount;
52 | }
53 | else
54 | {
55 | countedAllAmounts[def] = innerIfMinified.stackCount;
56 | }
57 | }
58 | }
59 | }
60 | }
61 | }
62 |
63 | foreach (var map1 in ZTracker.ZLevelsTracker[___map.Tile].ZLevels.Values)
64 | {
65 | if (map1.resourceCounter != null)
66 | {
67 | foreach (var d in countedAllAmounts)
68 | {
69 | map1.resourceCounter.AllCountedAmounts[d.Key] = d.Value;
70 | }
71 | }
72 | }
73 | return false;
74 | }
75 | }
76 | catch (Exception ex)
77 | {
78 | Log.Error("[Z-Levels] UpdateResourceCounts patch produced an error. That should not happen and will break things. Send a Hugslib log to the Z-Levels developers. Error message: " + ex);
79 | };
80 | return true;
81 | }
82 | }
83 |
84 | [HarmonyPatch(typeof(Designator_Build))]
85 | [HarmonyPatch("ProcessInput")]
86 | public class ProcessInput_Patch
87 | {
88 | public static IEnumerable Transpiler(IEnumerable instructions)
89 | {
90 | FieldInfo godmode = AccessTools.Field(typeof(DebugSettings), "godMode");
91 | foreach (CodeInstruction i in instructions)
92 | {
93 | yield return i;
94 | if (CodeInstructionExtensions.LoadsField(i, godmode, false))
95 | {
96 | yield return new CodeInstruction(OpCodes.Ldarg_1, null);
97 | yield return new CodeInstruction(OpCodes.Ldarg_0, null);
98 | yield return new CodeInstruction(OpCodes.Ldloc_S, 4);
99 | yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(
100 | typeof(ProcessInput_Patch), "IfInResourceCounter", null));
101 | }
102 | }
103 | IEnumerator enumerator = null;
104 | }
105 |
106 | public static bool IfInResourceCounter(bool __result, Event ev, Designator_Build instance, ThingDef thingDef2)
107 | {
108 | if (DebugSettings.godMode)
109 | {
110 | return true;
111 | }
112 | BuildableDef entDef = instance.entDef;
113 | ThingDef thingDef = entDef as ThingDef;
114 | if (thingDef2.IsStuff && thingDef2.stuffProps.CanMake(thingDef))
115 | {
116 | var ZTracker = ZUtils.ZTracker;
117 | foreach (var map in ZTracker.GetAllMaps(instance.Map.Tile))
118 | {
119 | if (map.listerThings.ThingsOfDef(thingDef2).Count > 0)
120 | {
121 | return true;
122 | }
123 | }
124 | }
125 | return false;
126 | }
127 | }
128 | }
129 | }
130 |
131 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/HarmonyPatches/SkyfallerPatches.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Linq;
5 | using System.Linq.Expressions;
6 | using System.Reflection;
7 | using HarmonyLib;
8 | using RimWorld;
9 | using RimWorld.Planet;
10 | using RimWorld.QuestGen;
11 | using UnityEngine;
12 | using Verse;
13 | using Verse.AI;
14 | using Verse.AI.Group;
15 |
16 | namespace ZLevels
17 | {
18 | [StaticConstructorOnStartup]
19 | public static class SkyfallerPatches
20 | {
21 |
22 | [HarmonyPatch(typeof(SkyfallerMaker))]
23 | [HarmonyPatch("SpawnSkyfaller")]
24 | [HarmonyPatch(new Type[] { typeof(ThingDef), typeof(IntVec3), typeof(Map) })]
25 | internal static class Patch_SpawnSkyfaller1
26 | {
27 | private static void Postfix(ref Skyfaller __result, ThingDef skyfaller, IntVec3 pos, Map map)
28 | {
29 | ZLogger.Message("Spawning " + __result);
30 |
31 | if (pos.Roofed(map))
32 | {
33 | var ZTracker = ZUtils.ZTracker;
34 | var upperMap = ZTracker.ZLevelsTracker[map.Tile]
35 | .ZLevels.Values.Where(x => !pos.Roofed(x)
36 | && pos.GetTerrain(x) != ZLevelsDefOf.ZL_OutsideTerrain)
37 | .OrderByDescending(x => ZTracker.GetZIndexFor(x)).FirstOrDefault();
38 | if (upperMap != null)
39 | {
40 | ZTracker.TeleportThing(__result, pos, upperMap);
41 | ZLogger.Message("Skyfaller: " + __result + " spawning in " + ZTracker.GetMapInfo(upperMap));
42 | }
43 | else
44 | {
45 | ZLogger.Message("Cant find unroofed map for " + __result);
46 | }
47 | ZLogger.Message("Roofed");
48 |
49 | }
50 | }
51 | }
52 |
53 | [HarmonyPatch(typeof(SkyfallerMaker))]
54 | [HarmonyPatch("SpawnSkyfaller")]
55 | [HarmonyPatch(new Type[] { typeof(ThingDef), typeof(ThingDef), typeof(IntVec3), typeof(Map) })]
56 | internal static class Patch_SpawnSkyfaller2
57 | {
58 | private static void Postfix(ref Skyfaller __result, ThingDef skyfaller, ThingDef innerThing, IntVec3 pos, Map map)
59 | {
60 | ZLogger.Message("Spawning " + __result);
61 |
62 | if (pos.Roofed(map))
63 | {
64 | var ZTracker = ZUtils.ZTracker;
65 | var upperMap = ZTracker.ZLevelsTracker[map.Tile]
66 | .ZLevels.Values.Where(x => !pos.Roofed(x)
67 | && pos.GetTerrain(x) != ZLevelsDefOf.ZL_OutsideTerrain)
68 | .OrderByDescending(x => ZTracker.GetZIndexFor(x)).FirstOrDefault();
69 | if (upperMap != null)
70 | {
71 | ZTracker.TeleportThing(__result, pos, upperMap);
72 | ZLogger.Message("Skyfaller: " + __result + " spawning in " + ZTracker.GetMapInfo(upperMap));
73 | }
74 | else
75 | {
76 | ZLogger.Message("Cant find unroofed map for " + __result);
77 | }
78 | ZLogger.Message("Roofed");
79 |
80 | }
81 | }
82 | }
83 |
84 | [HarmonyPatch(typeof(SkyfallerMaker))]
85 | [HarmonyPatch("SpawnSkyfaller")]
86 | [HarmonyPatch(new Type[] { typeof(ThingDef), typeof(Thing), typeof(IntVec3), typeof(Map) })]
87 | internal static class Patch_SpawnSkyfaller3
88 | {
89 | private static void Postfix(ref Skyfaller __result, ThingDef skyfaller, Thing innerThing, IntVec3 pos, Map map)
90 | {
91 | ZLogger.Message("Spawning " + __result);
92 |
93 | if (pos.Roofed(map))
94 | {
95 | var ZTracker = ZUtils.ZTracker;
96 | var upperMap = ZTracker.ZLevelsTracker[map.Tile]
97 | .ZLevels.Values.Where(x => !pos.Roofed(x)
98 | && pos.GetTerrain(x) != ZLevelsDefOf.ZL_OutsideTerrain)
99 | .OrderByDescending(x => ZTracker.GetZIndexFor(x)).FirstOrDefault();
100 | if (upperMap != null)
101 | {
102 | ZTracker.TeleportThing(__result, pos, upperMap);
103 | ZLogger.Message("Skyfaller: " + __result + " spawning in " + ZTracker.GetMapInfo(upperMap));
104 | }
105 | else
106 | {
107 | ZLogger.Message("Cant find unroofed map for " + __result);
108 | }
109 | ZLogger.Message("Roofed");
110 |
111 | }
112 | }
113 | }
114 |
115 | [HarmonyPatch(typeof(SkyfallerMaker))]
116 | [HarmonyPatch("SpawnSkyfaller")]
117 | [HarmonyPatch(new Type[] { typeof(ThingDef), typeof(IEnumerable), typeof(IntVec3), typeof(Map) })]
118 | internal static class Patch_SpawnSkyfaller4
119 | {
120 | private static void Postfix(ref Skyfaller __result, ThingDef skyfaller, IEnumerable things, IntVec3 pos, Map map)
121 | {
122 | ZLogger.Message("Spawning " + __result);
123 | if (pos.Roofed(map))
124 | {
125 | var ZTracker = ZUtils.ZTracker;
126 | var upperMap = ZTracker.ZLevelsTracker[map.Tile]
127 | .ZLevels.Values.Where(x => !pos.Roofed(x)
128 | && pos.GetTerrain(x) != ZLevelsDefOf.ZL_OutsideTerrain)
129 | .OrderByDescending(x => ZTracker.GetZIndexFor(x)).FirstOrDefault();
130 | if (upperMap != null)
131 | {
132 | ZTracker.TeleportThing(__result, pos, upperMap);
133 | ZLogger.Message("Skyfaller: " + __result + " spawning in " + ZTracker.GetMapInfo(upperMap));
134 | }
135 | else
136 | {
137 | ZLogger.Message("Cant find unroofed map for " + __result);
138 | }
139 | ZLogger.Message("Roofed");
140 | }
141 | }
142 | }
143 | }
144 | }
145 |
146 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/HarmonyPatches/TradePatches.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Linq;
5 | using System.Linq.Expressions;
6 | using System.Reflection;
7 | using System.Reflection.Emit;
8 | using HarmonyLib;
9 | using RimWorld;
10 | using RimWorld.Planet;
11 | using RimWorld.QuestGen;
12 | using UnityEngine;
13 | using Verse;
14 | using Verse.AI;
15 | using Verse.AI.Group;
16 |
17 | namespace ZLevels
18 | {
19 | [StaticConstructorOnStartup]
20 | public static class TradePatches
21 | {
22 | [HarmonyPatch(typeof(Pawn_TraderTracker), "ColonyThingsWillingToBuy")]
23 | public class Pawn_TraderTrackerPatch
24 | {
25 | [HarmonyPostfix]
26 | private static void Postfix(Pawn ___pawn, ref IEnumerable __result, Pawn playerNegotiator)
27 | {
28 | var result = __result.ToList();
29 | Map oldMap = ___pawn.Map;
30 | IntVec3 oldPosition = playerNegotiator.Position;
31 | bool select = false;
32 | if (Find.Selector.SelectedObjects.Contains(___pawn)) select = true;
33 | foreach (var map in ZUtils.GetAllMapsInClosestOrder(___pawn, oldMap, oldPosition))
34 | {
35 | if (map != oldMap)
36 | {
37 | IEnumerable enumerable = ___pawn.Map.listerThings.AllThings.Where((Thing x)
38 | => x.def.category == ThingCategory.Item && TradeUtility.PlayerSellableNow(x, ___pawn)
39 | && !x.Position.Fogged(x.Map) && (___pawn.Map.areaManager.Home[x.Position]
40 | || x.IsInAnyStorage()) && ReachableForTrade(x, ___pawn));
41 | foreach (Thing item in enumerable)
42 | {
43 | result.Add(item);
44 | }
45 | if (___pawn.GetLord() != null)
46 | {
47 | foreach (Pawn item2 in from x in TradeUtility.AllSellableColonyPawns(___pawn.Map)
48 | where !x.Downed && ReachableForTrade(x, ___pawn)
49 | select x)
50 | {
51 | result.Add(item2);
52 | }
53 | }
54 | }
55 | }
56 | ZUtils.TeleportThing(___pawn, oldMap, oldPosition);
57 | if (select) Find.Selector.Select(___pawn);
58 | __result = result;
59 | }
60 | public static bool ReachableForTrade(Thing thing, Pawn pawn)
61 | {
62 | if (pawn.Map != thing.Map)
63 | {
64 | return false;
65 | }
66 | return pawn.Map.reachability.CanReach(pawn.Position, thing, PathEndMode.Touch, TraverseMode.PassDoors, Danger.Some);
67 | }
68 | }
69 | }
70 | }
71 |
72 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/HarmonyPatches/WealthPatches.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Linq;
5 | using System.Linq.Expressions;
6 | using System.Reflection;
7 | using System.Reflection.Emit;
8 | using HarmonyLib;
9 | using RimWorld;
10 | using RimWorld.Planet;
11 | using RimWorld.QuestGen;
12 | using UnityEngine;
13 | using Verse;
14 | using Verse.AI;
15 | using Verse.AI.Group;
16 |
17 | namespace ZLevels
18 | {
19 | [StaticConstructorOnStartup]
20 | public static class WealthPatches
21 | {
22 |
23 | [HarmonyPatch(typeof(WealthWatcher), "WealthItems", MethodType.Getter)]
24 | internal static class WealthItemsPatch
25 | {
26 | [HarmonyPrefix]
27 | public static bool WealthItems(WealthWatcher __instance, Map ___map, ref float __result, float ___lastCountTick)
28 | {
29 | float result = 0;
30 | foreach (var map in ZUtils.ZTracker.GetAllMaps(___map.Tile))
31 | {
32 | if (Find.TickManager.TicksGame - ___lastCountTick > 5000f)
33 | {
34 | map.wealthWatcher.ForceRecount();
35 | }
36 | var value = map.wealthWatcher.wealthItems;
37 | result += value;
38 | //ZLogger.Message("Analyzing wealthItems: " + map + " - value: " + value);
39 | }
40 | //ZLogger.Message("New result: " + result);
41 | __result = result;
42 | return false;
43 | }
44 | }
45 |
46 | [HarmonyPatch(typeof(WealthWatcher), "WealthBuildings", MethodType.Getter)]
47 | internal static class WealthBuildingsPatch
48 | {
49 | [HarmonyPrefix]
50 | public static bool WealthBuildings(WealthWatcher __instance, Map ___map, ref float __result, float ___lastCountTick)
51 | {
52 | float result = 0;
53 | foreach (var map in ZUtils.ZTracker.GetAllMaps(___map.Tile))
54 | {
55 | if (Find.TickManager.TicksGame - ___lastCountTick > 5000f)
56 | {
57 | map.wealthWatcher.ForceRecount();
58 | }
59 | var value = map.wealthWatcher.wealthBuildings;
60 | result += value;
61 | //ZLogger.Message("Analyzing wealthBuildings: " + map + " - value: " + value);
62 | }
63 | //ZLogger.Message("New result: " + result);
64 | __result = result;
65 | return false;
66 | }
67 | }
68 |
69 | [HarmonyPatch(typeof(WealthWatcher), "WealthFloorsOnly", MethodType.Getter)]
70 | internal static class WealthFloorsOnlyPatch
71 | {
72 | [HarmonyPrefix]
73 | public static bool WealthFloorsOnly(WealthWatcher __instance, Map ___map, ref float __result, float ___lastCountTick)
74 | {
75 | float result = 0;
76 | foreach (var map in ZUtils.ZTracker.GetAllMaps(___map.Tile))
77 | {
78 | if ((float)Find.TickManager.TicksGame - ___lastCountTick > 5000f)
79 | {
80 | map.wealthWatcher.ForceRecount();
81 | }
82 | var value = map.wealthWatcher.wealthFloorsOnly;
83 | result += value;
84 | //ZLogger.Message("Analyzing wealthFloorsOnly: " + map + " - value: " + value);
85 | }
86 | //ZLogger.Message("New result: " + result);
87 | __result = result;
88 | return false;
89 | }
90 | }
91 |
92 | [HarmonyPatch(typeof(WealthWatcher), "WealthPawns", MethodType.Getter)]
93 | internal static class WealthPawnsPatch
94 | {
95 | [HarmonyPrefix]
96 | public static bool WealthPawns(WealthWatcher __instance, Map ___map, ref float __result, float ___lastCountTick)
97 | {
98 | float result = 0;
99 | foreach (var map in ZUtils.ZTracker.GetAllMaps(___map.Tile))
100 | {
101 | if ((float)Find.TickManager.TicksGame - ___lastCountTick > 5000f)
102 | {
103 | map.wealthWatcher.ForceRecount();
104 | }
105 | var value = map.wealthWatcher.wealthPawns;
106 | result += value;
107 | //ZLogger.Message("Analyzing wealthPawns: " + map + " - value: " + value);
108 | }
109 | //ZLogger.Message("New result: " + result);
110 | __result = result;
111 | return false;
112 | }
113 | }
114 |
115 | [HarmonyPatch(typeof(WealthWatcher), "WealthTotal", MethodType.Getter)]
116 | internal static class WealthTotalPatch
117 | {
118 | [HarmonyPrefix]
119 | public static bool WealthTotal(WealthWatcher __instance, Map ___map, ref float __result, float ___lastCountTick)
120 | {
121 | float result = 0;
122 | foreach (var map in ZUtils.ZTracker.GetAllMaps(___map.Tile))
123 | {
124 | if ((float)Find.TickManager.TicksGame - ___lastCountTick > 5000f)
125 | {
126 | map.wealthWatcher.ForceRecount();
127 | }
128 | var value = map.wealthWatcher.wealthItems + map.wealthWatcher.wealthBuildings + map.wealthWatcher.wealthPawns;
129 | result += value;
130 | //ZLogger.Message("Analyzing WealthTotal: " + map + " - value: " + value);
131 | }
132 | //ZLogger.Message("New result: " + result);
133 | __result = result;
134 | return false;
135 | }
136 | }
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/JobTracker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using RimWorld;
5 | using Verse;
6 | using Verse.AI;
7 |
8 | namespace ZLevels
9 | {
10 | public class JobTracker : IExposable
11 | {
12 | public Pawn pawn;
13 | public JobTracker()
14 | {
15 | activeJobs = new List();
16 | reservedThings = new List();
17 | reservedCells = new List();
18 | lookedAtLocalCellMap = new Dictionary();
19 | }
20 | public void ExposeData()
21 | {
22 | if (Scribe.mode == LoadSaveMode.Saving && this.activeJobs != null)
23 | {
24 | this.activeJobs.RemoveAll(x => x == null);
25 | }
26 | Scribe_TargetInfo.Look(ref targetDest, "targetDest");
27 | Scribe_Collections.Look(ref this.activeJobs, "activeJobs", LookMode.Deep);
28 | Scribe_References.Look(ref this.mainJob, "mainJob");
29 | Scribe_Values.Look(ref searchingJobsNow, "searchingJobsNow", false);
30 | Scribe_References.Look(ref oldMap, "oldMap");
31 | Scribe_Values.Look(ref forceGoToDestMap, "forceGoToDestMap", false);
32 | Scribe_References.Look(ref target, "target");
33 | Scribe_References.Look(ref mapDest, "mapDest");
34 | Scribe_Values.Look(ref forceGoToDestMap, "failIfTargetMapIsNotDest", false);
35 | Scribe_Collections.Look(ref reservedThings, "reservedThings", LookMode.LocalTargetInfo);
36 | Scribe_Collections.Look(ref reservedCells, "reservedCells", LookMode.LocalTargetInfo);
37 | Scribe_Collections.Look(ref lookedAtLocalCellMap, "lookedAtLocalCellMap", LookMode.Value, LookMode.Reference, ref intVec3Keys, ref mapValues);
38 | }
39 |
40 | public bool searchingJobsNow = false;
41 | public Map oldMap;
42 | public Job mainJob;
43 | public bool forceGoToDestMap;
44 | public Thing target;
45 | public bool failIfTargetMapIsNotDest;
46 | public List activeJobs;
47 | public List reservedThings;
48 | public List reservedCells;
49 | public TargetInfo targetDest;
50 | public Map mapDest;
51 | public Dictionary lookedAtLocalCellMap;
52 | private List intVec3Keys;
53 | private List mapValues;
54 | }
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/Jobs/JobDriver_GoToLocation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using RimWorld;
7 | using Verse;
8 | using Verse.AI;
9 | using ZLevels.Properties;
10 |
11 | namespace ZLevels
12 | {
13 | public class JobDriver_GoToLocation : JobDriver_ZLevels
14 | {
15 | //Target A = destination
16 | public override bool TryMakePreToilReservations(bool errorOnFailed)
17 | {
18 | return true;
19 | }
20 |
21 | public override void ExposeData()
22 | {
23 | base.ExposeData();
24 | }
25 |
26 | public List ActiveStairs;
27 |
28 | public override IEnumerable MakeNewToils()
29 | {
30 | //have pawn, and destination.
31 | //Check that pawn can reach destination with Dijkstra.
32 | //yield break if not.
33 | //Otherwise, calculate toils to go, then toils to destination and return them one at a time.
34 | ZLogger.Message($"JobDriver GoToLocation About to call findRouteWithStairs, with pawn {pawn}, dest { TargetA.ToTargetInfo(pawn.Map)}, instance {this}");
35 |
36 | foreach (var v in Toils_ZLevels.FindRouteWithStairs(pawn, TargetA.ToTargetInfo(pawn.Map), this))
37 | {
38 | yield return v;
39 | }
40 | }
41 |
42 |
43 | //Get pawn, target location and destination. (rough algorithm for hauling with dijkstra
44 | //Check that pawn can reach target location and destination with Dijkstra.
45 | //Break if not.
46 | //Otherwise, calculate toils to haul thing, then toils to destination and return them one at a time.
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/Jobs/JobDriver_GoToMap.cs:
--------------------------------------------------------------------------------
1 | using RimWorld;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Verse;
5 | using Verse.AI;
6 |
7 | namespace ZLevels
8 | {
9 | public class JobDriver_GoToMap : JobDriver_ZLevels
10 | {
11 | public override void ExposeData()
12 | {
13 | base.ExposeData();
14 | }
15 | public override bool TryMakePreToilReservations(bool errorOnFailed)
16 | {
17 | return true;
18 | }
19 | public override IEnumerable MakeNewToils()
20 | {
21 | this.FailOn(() => ZUtils.ZTracker.jobTracker.ContainsKey(pawn) && ZUtils.ZTracker.jobTracker[pawn].failIfTargetMapIsNotDest
22 | && ZUtils.ZTracker.jobTracker[pawn].target.Map != ZUtils.ZTracker.jobTracker[pawn].targetDest.Map);
23 | ZLogger.Message($"JobDriver GoToMap About to call findRouteWithStairs, with pawn {GetActor()}, dest { ZUtils.ZTracker.jobTracker[pawn].targetDest}, instance {this}");
24 | foreach (var toil in Toils_ZLevels.GoToMap(GetActor(), ZUtils.ZTracker.jobTracker[pawn].targetDest.Map, this))
25 | {
26 | yield return toil;
27 | }
28 | }
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/Jobs/JobDriver_GoToStairs.cs:
--------------------------------------------------------------------------------
1 | using RimWorld;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Verse;
5 | using Verse.AI;
6 |
7 | namespace ZLevels
8 | {
9 | public class JobDriver_GoToStairs : JobDriver
10 | {
11 | public override bool TryMakePreToilReservations(bool errorOnFailed)
12 | {
13 | return true;
14 | }
15 | public override IEnumerable MakeNewToils()
16 | {
17 | yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.OnCell);
18 | Toil useStairs = Toils_General.Wait(60, 0);
19 | ToilEffects.WithProgressBarToilDelay(useStairs, TargetIndex.A, false, -0.5f);
20 | ToilFailConditions.FailOnDespawnedNullOrForbidden(useStairs, TargetIndex.A);
21 | ToilFailConditions.FailOnCannotTouch(useStairs, TargetIndex.A, PathEndMode.OnCell);
22 | yield return useStairs;
23 |
24 | yield return new Toil
25 | {
26 | initAction = delegate ()
27 | {
28 | var ZTracker = ZUtils.ZTracker;
29 | Pawn pawn = GetActor();
30 | if (TargetA.Thing is Building_StairsUp stairsUp)
31 | {
32 | Map map = ZTracker.GetUpperLevel(this.pawn.Map.Tile, this.pawn.Map);
33 | if (map == null)
34 | {
35 | map = ZTracker.CreateUpperLevel(this.pawn.Map, stairsUp.Position);
36 | if (!string.IsNullOrEmpty(stairsUp.pathToPreset))
37 | {
38 | var comp = ZUtils.GetMapComponentZLevel(map);
39 | comp.DoGeneration = true;
40 | comp.path = stairsUp.pathToPreset;
41 | }
42 | ZTracker.TeleportPawn(pawn, pawn.Position, map, true, false, true);
43 | }
44 | else
45 | {
46 | if (!string.IsNullOrEmpty(stairsUp.pathToPreset))
47 | {
48 | var comp = ZUtils.GetMapComponentZLevel(map);
49 | comp.DoGeneration = true;
50 | comp.path = stairsUp.pathToPreset;
51 | }
52 | ZTracker.TeleportPawn(pawn, pawn.Position, map, false, false, stairsUp.shouldSpawnStairsUpper);
53 | stairsUp.shouldSpawnStairsUpper = false;
54 | }
55 | }
56 |
57 | else if (TargetA.Thing is Building_StairsDown stairsDown)
58 | {
59 | Map map = ZTracker.GetLowerLevel(this.pawn.Map.Tile, this.pawn.Map);
60 | if (map == null)
61 | {
62 | //ZLogger.Message("CREATING LOWER LEVEL AGAIG", true);
63 | map = ZTracker.CreateLowerLevel(this.pawn.Map, stairsDown.Position);
64 | if (!string.IsNullOrEmpty(stairsDown.pathToPreset))
65 | {
66 | var comp = ZUtils.GetMapComponentZLevel(map);
67 | comp.DoGeneration = true;
68 | comp.path = stairsDown.pathToPreset;
69 | }
70 | ZTracker.TeleportPawn(pawn, pawn.Position, map, true, true);
71 | }
72 | else
73 | {
74 | if (!string.IsNullOrEmpty(stairsDown.pathToPreset))
75 | {
76 | var comp = ZUtils.GetMapComponentZLevel(map);
77 | comp.DoGeneration = true;
78 | comp.path = stairsDown.pathToPreset;
79 | }
80 | ZTracker.TeleportPawn(pawn, pawn.Position, map, false, stairsDown.shouldSpawnStairsBelow);
81 | stairsDown.shouldSpawnStairsBelow = false;
82 | }
83 | }
84 | }
85 | };
86 | }
87 | }
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/Jobs/JobDriver_HaulThingToDest.cs:
--------------------------------------------------------------------------------
1 | using RimWorld;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using Verse;
6 | using Verse.AI;
7 |
8 | namespace ZLevels
9 | {
10 | public class JobDriver_HaulThingToDest : JobDriver_ZLevels
11 | {
12 | public override bool TryMakePreToilReservations(bool errorOnFailed)
13 | {
14 | return true;
15 | }
16 | public Thing savedThing = null;
17 |
18 | public override void ExposeData()
19 | {
20 | base.ExposeData();
21 | Scribe_References.Look(ref savedThing, "savedThing");
22 | }
23 | public override IEnumerable MakeNewToils()
24 | {
25 | var ZTracker = ZUtils.ZTracker;
26 |
27 | yield return new Toil
28 | {
29 | initAction = delegate ()
30 | {
31 | Log.Message("Test -1");
32 | if (this.job is null)
33 | {
34 | ZLogger.Error("JobDriver_HaulThingToDest: job is null, this should never happen.");
35 | }
36 | else if (this.job.targetA.Thing is null)
37 | {
38 | ZLogger.Error("JobDriver_HaulThingToDest: targetA.Thing is null, this should never happen.");
39 | }
40 | Log.Message("Test 0");
41 | if (pawn.Map == this.job.targetA.Thing.Map && pawn.Map == ZTracker.jobTracker[pawn].targetDest.Map)
42 | {
43 | ZLogger.Message("pawn map and thing map and dest map are same, yield breaking in JobDriver_HaulThingToDest");
44 | this.EndJobWith(JobCondition.InterruptForced);
45 | }
46 | else
47 | {
48 | Log.Message("Test 1");
49 | this.savedThing = this.job.targetA.Thing;
50 | Log.Message("Test 2");
51 | }
52 | }
53 | };
54 |
55 | Toil reserveItem = Toils_Reserve.Reserve(TargetIndex.A);
56 | if (TargetA.Thing?.Map != null)
57 | {
58 | foreach (var toil in Toils_ZLevels.GoToMap(GetActor(), new TargetInfo(TargetA.Thing).Map, this))
59 | {
60 | yield return toil;
61 | }
62 | }
63 |
64 | Toil toilGoto = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch);
65 | yield return reserveItem.FailOnDespawnedNullOrForbidden(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A);
66 | yield return toilGoto;
67 | yield return Toils_Haul.StartCarryThing(TargetIndex.A, putRemainderInQueue: false, subtractNumTakenFromJobCount: true).FailOnDestroyedNullOrForbidden(TargetIndex.A);
68 | if (job.haulOpportunisticDuplicates)
69 | {
70 | yield return Toils_Haul.CheckForGetOpportunityDuplicate(reserveItem, TargetIndex.A, TargetIndex.None, takeFromValidStorage: true);
71 | }
72 | yield return Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(toilGoto, TargetIndex.A);
73 | yield return new Toil
74 | {
75 | initAction = delegate ()
76 | {
77 | if (ZTracker.jobTracker.TryGetValue(pawn, out JobTracker jobTracker) && jobTracker.mainJob != null)
78 | {
79 | if (jobTracker.mainJob.targetA.Thing != null && jobTracker.mainJob.targetA.Thing == this.savedThing && jobTracker.mainJob.targetA.Thing != TargetA.Thing)
80 | {
81 | jobTracker.mainJob.targetA = new LocalTargetInfo(TargetA.Thing);
82 | }
83 | else if (jobTracker.mainJob.targetB.Thing != null && jobTracker.mainJob.targetB.Thing == this.savedThing && jobTracker.mainJob.targetB.Thing != TargetA.Thing)
84 | {
85 | jobTracker.mainJob.targetB = new LocalTargetInfo(TargetA.Thing);
86 | }
87 | if (jobTracker.mainJob.targetQueueA != null)
88 | {
89 | for (int i = jobTracker.mainJob.targetQueueA.Count - 1; i >= 0; i--)
90 | {
91 | var target = jobTracker.mainJob.targetQueueA[i];
92 | if (target.Thing != null && target.Thing == this.savedThing && target.Thing != TargetA.Thing)
93 | {
94 | jobTracker.mainJob.targetQueueA[i] = new LocalTargetInfo(TargetA.Thing);
95 | }
96 | }
97 | }
98 | if (jobTracker.mainJob.targetQueueB != null)
99 | {
100 | for (int i = jobTracker.mainJob.targetQueueB.Count - 1; i >= 0; i--)
101 | {
102 | var target = jobTracker.mainJob.targetQueueB[i];
103 | if (target.Thing != null && target.Thing == this.savedThing && target.Thing != TargetA.Thing)
104 | {
105 | if (jobTracker.mainJob.targetQueueB[i].Thing.stackCount == 0)
106 | {
107 | jobTracker.mainJob.targetQueueB[i] = new LocalTargetInfo(TargetA.Thing);
108 | jobTracker.mainJob.countQueue[i] = TargetA.Thing.stackCount;
109 | break;
110 | }
111 | else if (!jobTracker.mainJob.targetQueueB.Any(x => x.Thing == TargetA.Thing))
112 | {
113 | var newTarget = new LocalTargetInfo(TargetA.Thing);
114 | jobTracker.mainJob.targetQueueB.Add(newTarget);
115 | jobTracker.mainJob.countQueue.Add(newTarget.Thing.stackCount);
116 | int ind = jobTracker.mainJob.targetQueueB.FirstIndexOf(x => x.Thing == this.savedThing);
117 | jobTracker.mainJob.targetQueueB.RemoveAt(ind);
118 | jobTracker.mainJob.countQueue.RemoveAt(ind);
119 | break;
120 | }
121 | }
122 | }
123 | }
124 | }
125 | }
126 | };
127 |
128 | ZLogger.Message($"GoToMap 2");
129 | ZLogger.Message($"JobDriver HaulThingToDest 2About to call findRouteWithStairs, with pawn {GetActor()}, dest {ZTracker.jobTracker[pawn].targetDest.Map}, instance {this}");
130 | foreach (var toil in Toils_ZLevels.GoToMap(GetActor(), ZTracker.jobTracker[pawn].targetDest.Map, this))
131 | {
132 | yield return toil;
133 | }
134 | }
135 | }
136 | }
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/Jobs/JobDriver_HaulThingToDestAndToCell.cs:
--------------------------------------------------------------------------------
1 | using RimWorld;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using Verse;
6 | using Verse.AI;
7 |
8 | namespace ZLevels
9 | {
10 | public class JobDriver_HaulThingToDestAndToCell : JobDriver_ZLevels
11 | {
12 | private bool forbiddenInitially;
13 |
14 | private const TargetIndex HaulableInd = TargetIndex.A;
15 |
16 | private const TargetIndex StoreCellInd = TargetIndex.B;
17 |
18 | private Thing savedThing = null;
19 | public override void ExposeData()
20 | {
21 | base.ExposeData();
22 | Scribe_Values.Look(ref forbiddenInitially, "forbiddenInitially", defaultValue: false);
23 | }
24 |
25 | public override string GetReport()
26 | {
27 | Thing thing = null;
28 | if (pawn.CurJob == job && pawn.carryTracker.CarriedThing != null)
29 | {
30 | thing = pawn.carryTracker.CarriedThing;
31 | }
32 | else if (base.TargetThingA != null && base.TargetThingA.Spawned)
33 | {
34 | thing = base.TargetThingA;
35 | }
36 | if (thing == null)
37 | {
38 | return "ReportHaulingUnknown".Translate();
39 | }
40 | return "ReportHauling".Translate(thing.Label, thing);
41 | }
42 |
43 | public override bool TryMakePreToilReservations(bool errorOnFailed)
44 | {
45 | return true;
46 | }
47 |
48 | public override void Notify_Starting()
49 | {
50 | base.Notify_Starting();
51 | if (base.TargetThingA != null)
52 | {
53 | forbiddenInitially = base.TargetThingA.IsForbidden(pawn);
54 | }
55 | else
56 | {
57 | forbiddenInitially = false;
58 | }
59 | }
60 |
61 | public override IEnumerable MakeNewToils()
62 | {
63 | this.FailOnDestroyedOrNull(TargetIndex.A);
64 | //this.FailOnBurningImmobile(TargetIndex.B);
65 | if (!forbiddenInitially)
66 | {
67 | this.FailOnForbidden(TargetIndex.A);
68 | }
69 | var ZTracker = ZUtils.ZTracker;
70 | if (pawn.Map == this.job.targetA.Thing.Map && pawn.Map == ZTracker.jobTracker[pawn].targetDest.Map)
71 | {
72 | ZLogger.Message("pawn map and thing map and dest map are same, yield breaking in JobDriver_HaulThingToDest");
73 | yield break;
74 | }
75 | ZLogger.Message($"JobDriver HaulThingToDestAndCell1 About to call findRouteWithStairs, with pawn {GetActor()}, dest {new TargetInfo(TargetA.Thing)}, instance {this}");
76 | Log.Message("1 - pawn.Map: " + pawn.Map + " - dest: " + new TargetInfo(TargetA.Thing).Map);
77 | foreach (var toil in Toils_ZLevels.GoToMap(GetActor(), new TargetInfo(TargetA.Thing).Map, this))
78 | {
79 | yield return toil;
80 | }
81 | Toil reserveTargetA = Toils_Reserve.Reserve(TargetIndex.A);
82 | Toil toilGoto = null;
83 | toilGoto = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A).FailOn((Func)delegate
84 | {
85 | Pawn actor = toilGoto.actor;
86 | Job curJob = actor.jobs.curJob;
87 | if (curJob.haulMode == HaulMode.ToCellStorage)
88 | {
89 | Thing thing = curJob.GetTarget(TargetIndex.A).Thing;
90 | if (!actor.jobs.curJob.GetTarget(TargetIndex.B).Cell.IsValidStorageFor(base.Map, thing))
91 | {
92 | return true;
93 | }
94 | }
95 | return false;
96 | });
97 |
98 | yield return new Toil
99 | {
100 | initAction = delegate ()
101 | {
102 | ZLogger.Message("JobDriver_HaulThingToDestAndToCell 1: " + pawn + " trying to reserve: " + TargetA);
103 | }
104 | };
105 | yield return reserveTargetA;
106 | yield return toilGoto;
107 | yield return new Toil
108 | {
109 | initAction = delegate ()
110 | {
111 | this.savedThing = TargetA.Thing;
112 | }
113 | };
114 | yield return Toils_Haul.StartCarryThing(TargetIndex.A, putRemainderInQueue: false, subtractNumTakenFromJobCount: true);
115 | if (job.haulOpportunisticDuplicates)
116 | {
117 | yield return new Toil
118 | {
119 | initAction = delegate ()
120 | {
121 | ZLogger.Message("JobDriver_HaulThingToDestAndToCell 2: " + pawn + " trying to reserve other things: " + TargetA);
122 | }
123 | };
124 | yield return Toils_Haul.CheckForGetOpportunityDuplicate(reserveTargetA, TargetIndex.A, TargetIndex.B);
125 | }
126 | ZLogger.Message($"JobDriver HaulThingToDestAndCell2 About to call findRouteWithStairs, with pawn {GetActor()}, dest {ZTracker.jobTracker[pawn].targetDest}, instance {this}");
127 | Log.Message("2 - pawn.Map: " + pawn.Map + " - dest: " + ZTracker.jobTracker[pawn].targetDest.Map);
128 | foreach (var toil in Toils_ZLevels.GoToMap(GetActor(), ZTracker.jobTracker[pawn].targetDest.Map, this))
129 | {
130 | yield return toil;
131 | }
132 | Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);
133 | yield return carryToCell;
134 | yield return new Toil
135 | {
136 | initAction = delegate ()
137 | {
138 | if (TargetB.Cell.GetFirstItem(pawn.Map) != null)
139 | {
140 | IntVec3 newPosition = IntVec3.Invalid;
141 |
142 | IntVec3 center = (from x in GenRadial.RadialCellsAround(pawn.Position, 3f, useCenter: true)
143 | where x.InBounds(pawn.Map) && x.GetFirstItem(pawn.Map) == null
144 | select x).FirstOrDefault();
145 | if (center != null)
146 | {
147 | job.targetB = new LocalTargetInfo(center);
148 | }
149 | else if (CellFinder.TryFindRandomCellNear(TargetB.Cell, pawn.Map, 3,
150 | (IntVec3 c) => c.GetFirstItem(pawn.Map)?.def != TargetA.Thing.def, out newPosition))
151 | {
152 | job.targetB = new LocalTargetInfo(newPosition);
153 | }
154 | }
155 | }
156 | };
157 | yield return Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, false);
158 | }
159 | }
160 | }
161 |
162 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/Jobs/JobDriver_ZLevels.cs:
--------------------------------------------------------------------------------
1 | using RimWorld;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Verse;
5 | using Verse.AI;
6 | using ZLevels.Properties;
7 |
8 | namespace ZLevels
9 | {
10 | public abstract class JobDriver_ZLevels : JobDriver
11 | {
12 | public int curIndex = 0;
13 | public IntVec3 curLocation;
14 | public Map curMap;
15 | public Building_Stairs curStairs;
16 |
17 | private List nodeList;
18 | public List GetRoute(TargetInfo targetInfo)
19 | {
20 | if (nodeList == null)
21 | {
22 | ZLogger.Message($"pawn map: {pawn.Map}", debugLevel: DebugLevel.Pathfinding);
23 | nodeList = ZPathfinder.Instance.FindRoute(pawn.Position, targetInfo.Cell, pawn.Map, targetInfo.Map,
24 | out float routeCost);
25 | curIndex = 1;
26 | curMap = pawn.Map;
27 | }
28 | return nodeList;
29 | }
30 |
31 | public Building_Stairs GetCurrentStairs(TargetInfo targetInfo)
32 | {
33 | if (curStairs != null)
34 | {
35 | return curStairs;
36 | }
37 | else
38 | {
39 | var route = this.GetRoute(targetInfo);
40 | return route[curIndex].key;
41 | }
42 | }
43 |
44 | public IntVec3 GetCurrentLocation(TargetInfo targetInfo)
45 | {
46 | if (curLocation != null)
47 | {
48 | return curLocation;
49 | }
50 | else
51 | {
52 | var route = this.GetRoute(targetInfo);
53 | return route[curIndex].key.Position;
54 | }
55 | }
56 | public Map GetNextMap(TargetInfo targetInfo)
57 | {
58 | var route = this.GetRoute(targetInfo);
59 | return route[curIndex + 1].key.Map;
60 | }
61 |
62 | public override void ExposeData()
63 | {
64 | base.ExposeData();
65 | Scribe_Values.Look(ref curIndex, "curIndex", 0);
66 | Scribe_Values.Look(ref curLocation, "curLocation", IntVec3.Invalid);
67 | Scribe_References.Look(ref curMap, "curMap");
68 | Scribe_References.Look(ref curStairs, "curStairs");
69 | }
70 | }
71 | }
72 |
73 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/Map/BiomeWorker_NeverSpawn.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using RimWorld;
3 | using RimWorld.Planet;
4 |
5 | namespace ZLevels
6 | {
7 | public class BiomeWorker_NeverSpawn : BiomeWorker
8 | {
9 | public override float GetScore(Tile tile, int tileID)
10 | {
11 | return -100f;
12 | }
13 | }
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/Map/BlueprintUtility.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using RimWorld;
6 | using Verse;
7 |
8 | namespace ZLevels
9 | {
10 | public static class BlueprintUtility
11 | {
12 | public static void SaveEverything(string path, Map map, string elementName)
13 | {
14 | DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(path));
15 | if (!directoryInfo.Exists)
16 | {
17 | directoryInfo.Create();
18 | }
19 | List pawns = new List();
20 | List buildings = new List();
21 | List things = new List();
22 | List filths = new List();
23 | List plants = new List();
24 | Dictionary terrains = new Dictionary();
25 | Dictionary roofs = new Dictionary();
26 | foreach (var thing in map.listerThings.AllThings)
27 | {
28 | if (thing is Gas || thing is Mote) continue;
29 | if (thing is Pawn pawn)
30 | {
31 | pawns.Add(pawn);
32 | }
33 | else if (thing is Filth filth)
34 | {
35 | filths.Add(filth);
36 | }
37 | else if (thing is Plant plant)
38 | {
39 | plants.Add(plant);
40 | }
41 | else if (thing is Building building)
42 | {
43 | buildings.Add(building);
44 | }
45 | else
46 | {
47 | things.Add(thing);
48 | }
49 | }
50 |
51 | foreach (IntVec3 intVec in map.AllCells)
52 | {
53 | var terrain = intVec.GetTerrain(map);
54 | if (terrain != null)
55 | {
56 | terrains[intVec] = terrain;
57 | }
58 |
59 | var roof = intVec.GetRoof(map);
60 | if (roof != null)
61 | {
62 | roofs[intVec] = roof;
63 | }
64 | }
65 |
66 | Scribe.saver.InitSaving(path, elementName);
67 | Scribe_Collections.Look(ref pawns, "Pawns", LookMode.Deep, new object[0]);
68 | Scribe_Collections.Look(ref buildings, "Buildings", LookMode.Deep, new object[0]);
69 | Scribe_Collections.Look(ref filths, "Filths", LookMode.Deep, new object[0]);
70 | Scribe_Collections.Look(ref things, "Things", LookMode.Deep, new object[0]);
71 | Scribe_Collections.Look(ref plants, "Plants", LookMode.Deep, new object[0]);
72 | Scribe_Collections.Look(ref terrains, "Terrains",
73 | LookMode.Value, LookMode.Def, ref terrainKeys, ref terrainValues);
74 | Scribe_Collections.Look(ref roofs, "Roofs",
75 | LookMode.Value, LookMode.Def, ref roofsKeys, ref roofsValues);
76 | Scribe.saver.FinalizeSaving();
77 | }
78 |
79 | public static void LoadEverything(Map map, string path)
80 | {
81 | List pawns = new List();
82 | List buildings = new List();
83 | List filths = new List();
84 | List things = new List();
85 | List plants = new List();
86 | Dictionary terrains = new Dictionary();
87 | Dictionary roofs = new Dictionary();
88 |
89 | Scribe.loader.InitLoading(path);
90 |
91 | Scribe_Collections.Look(ref pawns, "Pawns", LookMode.Deep, new object[0]);
92 | Scribe_Collections.Look(ref buildings, "Buildings", LookMode.Deep, new object[0]);
93 | Scribe_Collections.Look(ref filths, "Filths", LookMode.Deep, new object[0]);
94 | Scribe_Collections.Look(ref things, "Things", LookMode.Deep, new object[0]);
95 | Scribe_Collections.Look(ref plants, "Plants", LookMode.Deep, new object[0]);
96 |
97 | Scribe_Collections.Look(ref terrains, "Terrains",
98 | LookMode.Value, LookMode.Def, ref terrainKeys, ref terrainValues);
99 | Scribe_Collections.Look(ref roofs, "Roofs",
100 | LookMode.Value, LookMode.Def, ref roofsKeys, ref roofsValues);
101 |
102 | Scribe.loader.FinalizeLoading();
103 |
104 | if (terrains != null && terrains.Count > 0)
105 | {
106 | foreach (var terrain in terrains)
107 | {
108 | try
109 | {
110 | if (GenGrid.InBounds(terrain.Key, map))
111 | {
112 | map.terrainGrid.SetTerrain(terrain.Key, terrain.Value);
113 | }
114 | }
115 | catch (Exception ex)
116 | {
117 | Log.Error("Error in map generating, cant spawn " + terrain.Key + " - " + ex);
118 | }
119 | }
120 | }
121 |
122 | if (pawns != null && pawns.Count > 0)
123 | {
124 | foreach (var pawn in pawns)
125 | {
126 | try
127 | {
128 | if (GenGrid.InBounds(pawn.Position, map))
129 | {
130 | GenSpawn.Spawn(pawn, pawn.Position, map, WipeMode.Vanish);
131 | pawn.SetFaction(pawn.Faction);
132 | }
133 | }
134 | catch (Exception ex)
135 | {
136 | Log.Error("Error in map generating, cant spawn " + pawn + " - " + ex);
137 | }
138 | }
139 | }
140 |
141 | if (buildings != null && buildings.Count > 0)
142 | {
143 | foreach (var building in buildings)
144 | {
145 | try
146 | {
147 | if (GenGrid.InBounds(building.Position, map))
148 | {
149 | GenSpawn.Spawn(building, building.Position, map, building.Rotation, WipeMode.Vanish);
150 | if (building.def.CanHaveFaction)
151 | {
152 | building.SetFaction(building.Faction);
153 | }
154 | }
155 | }
156 | catch (Exception ex)
157 | {
158 | Log.Error("Error in map generating, cant spawn " + building + " - " + ex);
159 | }
160 | }
161 | }
162 |
163 | if (filths != null && filths.Count > 0)
164 | {
165 | foreach (var filth in filths)
166 | {
167 | GenSpawn.Spawn(filth, filth.Position, map, WipeMode.Vanish);
168 | }
169 | }
170 |
171 | if (plants != null && plants.Count > 0)
172 | {
173 | foreach (var plant in plants)
174 | {
175 | GenSpawn.Spawn(plant, plant.Position, map, WipeMode.Vanish);
176 | }
177 | }
178 |
179 | if (things != null && things.Count > 0)
180 | {
181 | foreach (var thing in things)
182 | {
183 | GenSpawn.Spawn(thing, thing.Position, map, WipeMode.Vanish);
184 | }
185 | }
186 |
187 | if (roofs != null && roofs.Count > 0)
188 | {
189 | foreach (var roof in roofs)
190 | {
191 | try
192 | {
193 | if (GenGrid.InBounds(roof.Key, map))
194 | {
195 | map.roofGrid.SetRoof(roof.Key, roof.Value);
196 | }
197 | }
198 | catch (Exception ex)
199 | {
200 | Log.Error("Error in map generating, cant spawn " + roof.Key + " - " + ex);
201 | }
202 | }
203 | }
204 | }
205 |
206 | public static List terrainKeys = new List();
207 | public static List roofsKeys = new List();
208 | public static List terrainValues = new List();
209 | public static List roofsValues = new List();
210 | }
211 | }
212 |
213 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/Map/InfestationData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using RimWorld;
4 | using Verse;
5 |
6 | namespace ZLevels
7 | {
8 | public class InfestationData : IExposable
9 | {
10 | public InfestationData()
11 | {
12 | }
13 |
14 | public InfestationData(List infestators, float infestationParms, IntVec3 infestationPlace)
15 | {
16 | this.infestators = infestators;
17 | this.infestationParms = infestationParms;
18 | this.infestationPlace = infestationPlace;
19 | }
20 | public void ExposeData()
21 | {
22 | Scribe_Collections.Look(ref this.infestators, "infestators", LookMode.Def, Array.Empty());
23 | Scribe_Values.Look(ref this.infestationParms, "infestationParms", 0f, true);
24 | Scribe_Values.Look(ref this.infestationPlace, "infestationPlace", IntVec3.Invalid, true);
25 | }
26 |
27 | public List infestators;
28 | public float infestationParms;
29 | public IntVec3 infestationPlace;
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/Map/MapComponentZLevel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using HarmonyLib;
5 | using RimWorld;
6 | using RimWorld.Planet;
7 | using UnityEngine;
8 | using Verse;
9 | using Verse.AI;
10 |
11 | namespace ZLevels
12 | {
13 | public class MapComponentZLevel : MapComponent
14 | {
15 | public MapComponentZLevel(Map map) : base(map)
16 | {
17 |
18 | }
19 |
20 | public int Z_LevelIndex = 0;
21 | public override void MapGenerated()
22 | {
23 | base.MapGenerated();
24 | if (Rand.Chance(0.5f) && (Find.WorldGrid[map.Tile].hilliness == Hilliness.SmallHills
25 | || Find.WorldGrid[map.Tile].hilliness == Hilliness.LargeHills
26 | || Find.WorldGrid[map.Tile].hilliness == Hilliness.Mountainous
27 | || Find.WorldGrid[map.Tile].hilliness == Hilliness.Impassable))
28 | {
29 | ZLogger.Message("The map has caves below now");
30 | this.hasCavesBelow = true;
31 | }
32 | }
33 | public override void MapComponentUpdate()
34 | {
35 | base.MapComponentUpdate();
36 | //if (this.DoGeneration && path.Length > 0)
37 | //{
38 | // SettlementGeneration.DoSettlementGeneration(this.map, this.path, this.map.ParentFaction, false);
39 | // this.DoGeneration = false;
40 | //}
41 | if (this.ReFog)
42 | {
43 | ZLogger.Message("Refog" + this.map);
44 | FloodFillerFog.DebugRefogMap(this.map);
45 | this.ReFog = false;
46 | }
47 | }
48 |
49 | //public void DoForcedGeneration(bool disableFog)
50 | //{
51 | // SettlementGeneration.DoSettlementGeneration(this.map, this.path, this.map.ParentFaction, disableFog);
52 | // this.DoGeneration = false;
53 | //}
54 |
55 | public override void FinalizeInit()
56 | {
57 | base.FinalizeInit();
58 | if (!this.hasCavesBelow.HasValue)
59 | {
60 | if (Rand.Chance(0.5f) && (Find.WorldGrid[map.Tile].hilliness == Hilliness.SmallHills
61 | || Find.WorldGrid[map.Tile].hilliness == Hilliness.LargeHills
62 | || Find.WorldGrid[map.Tile].hilliness == Hilliness.Mountainous
63 | || Find.WorldGrid[map.Tile].hilliness == Hilliness.Impassable))
64 | {
65 | this.hasCavesBelow = true;
66 | }
67 | }
68 |
69 | var ZTracker = ZUtils.ZTracker;
70 | if (ZTracker.ZLevelsTracker == null)
71 | {
72 | ZTracker.ZLevelsTracker = new Dictionary();
73 | }
74 |
75 | if (!ZTracker.ZLevelsTracker.ContainsKey(this.map.Tile) && ZTracker.TryRegisterMap(this.map, 0))
76 | {
77 | this.Z_LevelIndex = 0;
78 | }
79 | }
80 |
81 | public override void MapComponentTick()
82 | {
83 | base.MapComponentTick();
84 | if (Find.TickManager.TicksGame % Rand.RangeInclusive(60, 100) == 0)
85 | {
86 | if (this.ActiveInfestations != null && this.ActiveInfestations.Count > 0)
87 | {
88 | foreach (var infestation in this.ActiveInfestations)
89 | {
90 | foreach (var pawnKind in infestation.infestators)
91 | {
92 | if (infestation.infestationParms > 0f)
93 | {
94 | var pawn = PawnGenerator.GeneratePawn(pawnKind, null);
95 | infestation.infestationParms -= pawnKind.combatPower;
96 | GenSpawn.Spawn(pawn, infestation.infestationPlace, map);
97 | }
98 | }
99 | }
100 | this.ActiveInfestations.RemoveAll(x => x.infestationParms <= 0f);
101 | }
102 | }
103 | }
104 |
105 | public override void ExposeData()
106 | {
107 | base.ExposeData();
108 | Scribe_Collections.Look(ref this.ActiveInfestations, "InfestationDatas", LookMode.Deep, null);
109 | Scribe_Collections.Look(ref this.TotalInfestations, "TotalInfestations", LookMode.Deep, null);
110 | Scribe_Values.Look(ref this.Z_LevelIndex, "Z_LevelIndex", 0);
111 |
112 | Scribe_Values.Look(ref this.DoGeneration, "DoGeneration", false);
113 | Scribe_Values.Look(ref this.hasCavesBelow, "hasCavesBelow", null);
114 | Scribe_Values.Look(ref this.path, "path", "");
115 | }
116 |
117 | public bool DoGeneration = false;
118 |
119 | public bool ReFog = false;
120 | public string path = "";
121 |
122 | public bool? hasCavesBelow;
123 |
124 | public List ActiveInfestations;
125 |
126 | public List TotalInfestations;
127 |
128 | }
129 | }
130 |
131 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/Map/MapParent_ZLevel.cs:
--------------------------------------------------------------------------------
1 | using RimWorld.Planet;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using Verse;
7 |
8 | namespace ZLevels
9 | {
10 | public class MapParent_ZLevel : MapParent
11 | {
12 | public bool shouldBeDeleted = false;
13 | public IntVec3 PlayerStartSpot = IntVec3.Invalid;
14 |
15 | public bool hasCaves = false;
16 |
17 | public int Z_LevelIndex = 0;
18 |
19 | public bool IsUnderground = false;
20 |
21 | public bool IsUpperLevel = false;
22 |
23 | public List TotalInfestations;
24 | public MapParent_ZLevel()
25 | {
26 |
27 | }
28 | public override void ExposeData()
29 | {
30 | base.ExposeData();
31 | Scribe_Collections.Look(ref this.TotalInfestations, "TotalInfestations", LookMode.Deep, null);
32 | Scribe_Values.Look(ref this.IsUnderground, "IsUnderground", false, false);
33 | Scribe_Values.Look(ref this.IsUpperLevel, "IsUpperLevel", false, false);
34 | Scribe_Values.Look(ref this.shouldBeDeleted, "shouldBeDeleted", false, false);
35 | Scribe_Values.Look(ref this.hasCaves, "hasCaves", false, false);
36 | Scribe_Values.Look(ref this.Z_LevelIndex, "Z_LevelIndex", 0, false);
37 | }
38 |
39 | public override IEnumerable GetGizmos()
40 | {
41 | foreach (Gizmo current in base.GetGizmos())
42 | {
43 | yield return current;
44 | }
45 | yield break;
46 | }
47 |
48 | public override bool UseGenericEnterMapFloatMenuOption
49 | {
50 | get
51 | {
52 | return false;
53 | }
54 | }
55 |
56 | public override void Abandon()
57 | {
58 | this.shouldBeDeleted = true;
59 | this.CheckRemoveMapNow();
60 | }
61 |
62 | public override bool ShouldRemoveMapNow(out bool alsoRemoveWorldObject)
63 | {
64 | alsoRemoveWorldObject = false;
65 | bool result = false;
66 | if (this.shouldBeDeleted)
67 | {
68 | result = true;
69 | alsoRemoveWorldObject = true;
70 | }
71 | return result;
72 | }
73 | }
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/MapRenderer/SectionLayer_LowerFogOfWar.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using UnityEngine;
4 | using Verse;
5 |
6 | namespace ZLevels
7 | {
8 | public class SectionLayer_LowerFogOfWar : SectionLayer
9 | {
10 | public override bool Visible
11 | {
12 | get
13 | {
14 | return DebugViewSettings.drawFog;
15 | }
16 | }
17 |
18 | public SectionLayer_LowerFogOfWar(Section section) : base(section)
19 | {
20 | this.relevantChangeTypes = MapMeshFlag.FogOfWar;
21 | }
22 |
23 | public override void Regenerate()
24 | {
25 | var ZTracker = ZUtils.ZTracker;
26 | int curLevel = ZTracker.GetZIndexFor(base.Map);
27 | bool[] fogGrid = base.Map.fogGrid.fogGrid;
28 | if (curLevel > 0)
29 | {
30 | foreach (var map in ZTracker.GetAllMaps(base.Map.Tile)
31 | .OrderByDescending(x => ZTracker.GetZIndexFor(x)))
32 | {
33 | int baseLevel = ZTracker.GetZIndexFor(map);
34 | CellIndices cellIndices = map.cellIndices;
35 |
36 | if (curLevel > baseLevel && baseLevel >= 0)
37 | {
38 | CellRect cellRect = this.section.CellRect;
39 |
40 | foreach (IntVec3 intVec in this.section.CellRect)
41 | {
42 | if (intVec.Fogged(map) && !intVec.Fogged(base.Map))
43 | {
44 | fogGrid[cellIndices.CellToIndex(intVec)] = true;
45 | base.Map.mapDrawer.MapMeshDirty(intVec, MapMeshFlag.FogOfWar);
46 | }
47 | }
48 | }
49 | }
50 | }
51 |
52 | }
53 |
54 | private bool[] vertsCovered = new bool[9];
55 |
56 | private const byte FogBrightness = 35;
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/MultiplayerSupport.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using HarmonyLib;
4 | using Multiplayer.API;
5 | using Verse;
6 |
7 | namespace ZLevels
8 | {
9 | [StaticConstructorOnStartup]
10 | internal static class MultiplayerSupport
11 | {
12 | static MultiplayerSupport()
13 | {
14 | if (!MP.enabled)
15 | {
16 | return;
17 | }
18 | MP.RegisterSyncMethod(typeof(Building_StairsDown), "GiveJob", null);
19 | MP.RegisterSyncMethod(typeof(Building_StairsUp), "GiveJob", null);
20 | var method = AccessTools.Method(typeof(MapComponentZLevel), "MapComponentTick", null, null);
21 | MultiplayerSupport.harmony.Patch(method, new HarmonyMethod(typeof(MultiplayerSupport),
22 | "FixRNGPre", null), new HarmonyMethod(typeof(MultiplayerSupport), "FixRNGPos", null), null, null);
23 |
24 | }
25 |
26 | private static void FixRNGPre()
27 | {
28 | Rand.PushState(Find.TickManager.TicksAbs);
29 | }
30 |
31 | private static void FixRNGPos()
32 | {
33 | Rand.PopState();
34 | }
35 |
36 | private static Harmony harmony = new Harmony("rimworld.zlevels.multiplayersupport");
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/PowerTransfer/Building_PowerTransmitter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using RimWorld;
5 | using UnityEngine;
6 | using Verse;
7 | using Verse.Noise;
8 | using Verse.Sound;
9 |
10 | namespace ZLevels
11 | {
12 | [StaticConstructorOnStartup]
13 | public class Building_PowerTransmitter : Building
14 | {
15 | public override void ExposeData()
16 | {
17 | base.ExposeData();
18 | Scribe_Values.Look(ref this.ticksToExplode, "ticksToExplode", 0, false);
19 | }
20 | public override void Draw()
21 | {
22 | base.Draw();
23 | if (this.ticksToExplode > 0 && base.Spawned)
24 | {
25 | base.Map.overlayDrawer.DrawOverlay(this, OverlayTypes.BurningWick);
26 | }
27 | }
28 |
29 | private CompPowerZTransmitter baseComp;
30 | public override void SpawnSetup(Map map, bool respawningAfterLoad)
31 | {
32 | base.SpawnSetup(map, respawningAfterLoad);
33 | baseComp = this.GetComp();
34 | }
35 |
36 | public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
37 | {
38 | base.Destroy(mode);
39 | if (this.upperPowerComp != null)
40 | {
41 | this.upperPowerComp.PowerNet.powerComps.Remove(this.upperPowerComp);
42 | }
43 | if (this.lowerPowerComp != null)
44 | {
45 | this.lowerPowerComp.PowerNet.powerComps.Remove(this.lowerPowerComp);
46 | }
47 | }
48 |
49 | public float GetPowerNetCurrentGain(PowerNet net)
50 | {
51 | float num = 0f;
52 | for (int i = 0; i < net.powerComps.Count; i++)
53 | {
54 | if (net.powerComps[i].PowerOn)
55 | {
56 | num += net.powerComps[i].EnergyOutputPerTick;
57 | }
58 | }
59 | return num;
60 | }
61 | public override void Tick()
62 | {
63 | base.Tick();
64 | if (this.ticksToExplode > 0)
65 | {
66 | if (this.wickSustainer == null)
67 | {
68 | this.StartWickSustainer();
69 | }
70 | else
71 | {
72 | this.wickSustainer.Maintain();
73 | }
74 | this.ticksToExplode--;
75 | if (this.ticksToExplode == 0)
76 | {
77 | IntVec3 randomCell = this.OccupiedRect().RandomCell;
78 | float radius = Rand.Range(0.5f, 1f) * 3f;
79 | GenExplosion.DoExplosion(randomCell, base.Map, radius, DamageDefOf.Flame, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false, null, null);
80 | }
81 | }
82 | }
83 | public override void PostApplyDamage(DamageInfo dinfo, float totalDamageDealt)
84 | {
85 | base.PostApplyDamage(dinfo, totalDamageDealt);
86 | if (!base.Destroyed && this.ticksToExplode == 0 && dinfo.Def == DamageDefOf.Flame && Rand.Value < 0.05f && base.GetComp().StoredEnergy > 500f)
87 | {
88 | this.ticksToExplode = Rand.Range(70, 150);
89 | this.StartWickSustainer();
90 | }
91 | }
92 |
93 | private void StartWickSustainer()
94 | {
95 | SoundInfo info = SoundInfo.InMap(this, MaintenanceType.PerTick);
96 | this.wickSustainer = SoundDefOf.HissSmall.TrySpawnSustainer(info);
97 | }
98 |
99 | public override string GetInspectString()
100 | {
101 | var baseComp = this.GetComp();
102 | if (baseComp.PowerNet == null)
103 | {
104 | return "PowerNotConnected".Translate();
105 | }
106 | string value = (baseComp.PowerNet.CurrentEnergyGainRate() / CompPower.WattsToWattDaysPerTick).ToString("F0");
107 | string value2 = baseComp.PowerNet.CurrentStoredEnergy().ToString("F0");
108 | return "PowerConnectedRateStored".Translate(value, value2);
109 | }
110 |
111 | private int ticksToExplode;
112 |
113 | public ConnectedPowerNets connectedPowerNets => ZUtils.ZTracker.connectedPowerNets;
114 |
115 | private Sustainer wickSustainer;
116 |
117 | CompPowerZTransmitter upperPowerComp = null;
118 |
119 | CompPowerZTransmitter lowerPowerComp = null;
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/PowerTransfer/CompPowerZTransmitter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using RimWorld;
5 | using UnityEngine;
6 | using Verse;
7 |
8 | namespace ZLevels
9 | {
10 | public class CompPowerZTransmitter : CompPowerPlant
11 | {
12 | PowerNet curPowerNet;
13 | public override float DesiredPowerOutput
14 | {
15 | get
16 | {
17 | return 0;
18 | }
19 | }
20 |
21 | public override void PostSpawnSetup(bool respawningAfterLoad)
22 | {
23 | base.PostSpawnSetup(respawningAfterLoad);
24 | }
25 |
26 | public new CompProperties_PowerZTransmitter Props
27 | {
28 | get
29 | {
30 | return (CompProperties_PowerZTransmitter)this.props;
31 | }
32 | }
33 |
34 | public override void PostExposeData()
35 | {
36 | base.PostExposeData();
37 | }
38 |
39 | public override void CompTick()
40 | {
41 | base.CompTick();
42 | if (this?.PowerNet != null)
43 | {
44 | if (this.PowerOn)
45 | {
46 | if (curPowerNet != this.PowerNet)
47 | {
48 | curPowerNet = this.PowerNet;
49 | ZUtils.ZTracker.connectedPowerNets.RegisterTransmitter(this);
50 | }
51 | }
52 | else
53 | {
54 | ZUtils.ZTracker.connectedPowerNets.DeregisterTransmitter(this);
55 | }
56 | }
57 | }
58 | public override IEnumerable CompGetGizmosExtra()
59 | {
60 | foreach (Gizmo gizmo in base.CompGetGizmosExtra())
61 | {
62 | yield return gizmo;
63 | }
64 | }
65 | }
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/PowerTransfer/CompProperties_PowerZTransmitter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using RimWorld;
3 | using Verse;
4 |
5 | namespace ZLevels
6 | {
7 | public class CompProperties_PowerZTransmitter : CompProperties_Power
8 | {
9 | public CompProperties_PowerZTransmitter()
10 | {
11 | this.compClass = typeof(CompPowerZTransmitter);
12 | }
13 | }
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/PowerTransfer/ConnectedPowerNets.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using HarmonyLib;
6 | using RimWorld;
7 | using RimWorld.Planet;
8 | using UnityEngine;
9 | using Verse;
10 | using Verse.AI;
11 |
12 | namespace ZLevels
13 | {
14 | [HarmonyPatch(typeof(World), "WorldPostTick")]
15 | public class WorldPostTick_Patch
16 | {
17 | private static void Postfix()
18 | {
19 | ZUtils.ZTracker.connectedPowerNets.Tick();
20 | }
21 | }
22 |
23 | [HarmonyPatch(typeof(PowerNet), "CurrentStoredEnergy")]
24 | public class CurrentStoredEnergy_Patch
25 | {
26 | private static bool Prefix(PowerNet __instance, ref float __result)
27 | {
28 | if (ZUtils.ZTracker.connectedPowerNets.connectedPowerNetsDict.TryGetValue(__instance, out ConnectedPowerNet connectedPowerNet))
29 | {
30 | __result = connectedPowerNet.TotalStoredEnergy;
31 | return false;
32 | }
33 | return true;
34 | }
35 | }
36 | public class ConnectedPowerNet
37 | {
38 | public ConnectedPowerNet(CompPowerZTransmitter comp)
39 | {
40 | connectedTransmitters = new List();
41 | AddTransmitter(comp);
42 | }
43 |
44 | public void AddTransmitter(CompPowerZTransmitter transmitter)
45 | {
46 | connectedTransmitters.Add(transmitter);
47 | }
48 |
49 | public void RemoveTransmitter(CompPowerZTransmitter transmitter)
50 | {
51 | connectedTransmitters.Remove(transmitter);
52 | }
53 |
54 | public void Tick()
55 | {
56 | var totalEnergy = TotalEnergy;
57 | var powerNets = new Dictionary>();
58 | foreach (var transmitter in connectedTransmitters)
59 | {
60 | if (powerNets.ContainsKey(transmitter.PowerNet))
61 | {
62 | powerNets[transmitter.PowerNet].Add(transmitter);
63 | }
64 | else
65 | {
66 | powerNets[transmitter.PowerNet] = new List { transmitter };
67 | }
68 | }
69 | foreach (var powerNet in powerNets)
70 | {
71 | foreach (var comp in powerNet.Value)
72 | {
73 | comp.powerOutputInt = 0;
74 | }
75 | var localEnergy = powerNet.Key.CurrentEnergyGainRate() / CompPower.WattsToWattDaysPerTick;
76 | var diffEnergy = totalEnergy - localEnergy;
77 | foreach (var comp in powerNet.Value)
78 | {
79 | comp.powerOutputInt = diffEnergy / powerNet.Value.Count();
80 | }
81 | }
82 | }
83 |
84 | public float CurrentStoredEnergy(PowerNet powerNet)
85 | {
86 | float num = 0f;
87 | for (int i = 0; i < powerNet.batteryComps.Count; i++)
88 | {
89 | num += powerNet.batteryComps[i].StoredEnergy;
90 | }
91 | return num;
92 | }
93 |
94 | private List connectedTransmitters;
95 | public List ConnectedTransmitters => connectedTransmitters;
96 | public HashSet ConnectedPowerNets => ConnectedTransmitters.Select(x => x.PowerNet).ToHashSet();
97 | public float TotalEnergy => ConnectedPowerNets.Sum(x => x.CurrentEnergyGainRate() / CompPower.WattsToWattDaysPerTick);
98 | public float TotalStoredEnergy => ConnectedPowerNets.Sum(x => CurrentStoredEnergy(x));
99 | }
100 | public class ConnectedPowerNets
101 | {
102 | public ConnectedPowerNets()
103 | {
104 | powerNets = new Dictionary();
105 | connectedPowerNetsDict = new Dictionary();
106 | }
107 | public void RegisterTransmitter(CompPowerZTransmitter comp)
108 | {
109 | Log.Message("Registering: " + comp);
110 | var lowerMap = ZUtils.ZTracker.GetLowerLevel(comp.parent.Tile, comp.parent.Map);
111 | var upperMap = ZUtils.ZTracker.GetUpperLevel(comp.parent.Tile, comp.parent.Map);
112 | foreach (var powerNet in powerNets)
113 | {
114 | if (!powerNet.Value.ConnectedTransmitters.Contains(comp))
115 | {
116 | if (powerNet.Value.ConnectedTransmitters.FirstOrDefault()?.PowerNet == comp.PowerNet)
117 | {
118 | AddTransmitter(powerNet.Value, comp);
119 | return;
120 | }
121 | if (lowerMap != null)
122 | {
123 | var lowerComps = powerNet.Value.ConnectedTransmitters.Where(x => x.parent.Map == lowerMap);
124 | foreach (var lowerComp in lowerComps)
125 | {
126 | if (lowerComp.parent.Position.DistanceTo(comp.parent.Position) < 3)
127 | {
128 | AddTransmitter(powerNet.Value, comp);
129 | return;
130 | }
131 | }
132 | }
133 | if (upperMap != null)
134 | {
135 | var upperComps = powerNet.Value.ConnectedTransmitters.Where(x => x.parent.Map == upperMap);
136 | foreach (var upperComp in upperComps)
137 | {
138 | if (upperComp.parent.Position.DistanceTo(comp.parent.Position) < 3)
139 | {
140 | AddTransmitter(powerNet.Value, comp);
141 | return;
142 | }
143 | }
144 | }
145 | }
146 | else
147 | {
148 | return;
149 | }
150 | }
151 | var connectedPowerNet = new ConnectedPowerNet(comp);
152 | AddTransmitter(connectedPowerNet, comp);
153 | powerNets.Add(powerNets.Count + 1, connectedPowerNet);
154 | }
155 |
156 | public void AddTransmitter(ConnectedPowerNet connectedPowerNet, CompPowerZTransmitter compPowerZTransmitter)
157 | {
158 | connectedPowerNet.AddTransmitter(compPowerZTransmitter);
159 | connectedPowerNetsDict[compPowerZTransmitter.PowerNet] = connectedPowerNet;
160 | }
161 | public void ChangePowerNet(CompPowerZTransmitter compPowerZTransmitter)
162 | {
163 | var connectedPowerNet = powerNets.Where(x => x.Value.ConnectedPowerNets.Contains(compPowerZTransmitter.PowerNet)).FirstOrDefault();
164 | if (connectedPowerNet.Value != null)
165 | {
166 | connectedPowerNetsDict[compPowerZTransmitter.PowerNet] = connectedPowerNet.Value;
167 | }
168 | }
169 | public void DeregisterTransmitter(CompPowerZTransmitter comp)
170 | {
171 | Log.Message("Deregistering: " + comp);
172 | foreach (var powerNet in powerNets)
173 | {
174 | powerNet.Value.RemoveTransmitter(comp);
175 | }
176 | }
177 | public void Tick()
178 | {
179 | foreach (var powerNet in powerNets)
180 | {
181 | powerNet.Value.Tick();
182 | }
183 | }
184 |
185 | public Dictionary powerNets = new Dictionary();
186 | public Dictionary connectedPowerNetsDict = new Dictionary();
187 | }
188 | }
189 |
190 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ZLevels")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ZLevels")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("4aadf459-3d4f-4729-9249-7a2efa09c493")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/ZLevelData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Verse;
4 |
5 | namespace ZLevels
6 | {
7 | public class ZLevelData : IExposable
8 | {
9 | public ZLevelData()
10 | {
11 | }
12 |
13 | public void ExposeData()
14 | {
15 | Scribe_Collections.Look(ref this.ZLevels, "ZLevels", LookMode.Value, LookMode.Reference,
16 | ref ZLevelsKeys, ref ZLevelsValues);
17 | }
18 |
19 | public Dictionary ZLevels;
20 | public List ZLevelsKeys = new List();
21 | public List ZLevelsValues = new List();
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/ZLevels.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {4AADF459-3D4F-4729-9249-7A2EFA09C493}
8 | Library
9 | Properties
10 | ZLevels
11 | ZLevels
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 | false
18 | none
19 | false
20 | ..\..\..\1.2\Assemblies\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 | true
25 |
26 |
27 | none
28 | true
29 | ..\..\..\1.3\Assemblies\
30 | TRACE
31 | prompt
32 | 4
33 | true
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 |
110 | 1.0.1
111 | runtime; build; native; contentfiles; analyzers; buildtransitive
112 | all
113 |
114 |
115 | 1.3.3200
116 |
117 |
118 | 2.1.1
119 | runtime
120 |
121 |
122 | 0.3.0
123 |
124 |
125 |
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/ZLevelsDefOf.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using RimWorld;
5 | using Verse;
6 | using Verse.AI;
7 | using Verse.Sound;
8 |
9 | namespace ZLevels
10 | {
11 | [DefOf]
12 | public static class ZLevelsDefOf
13 | {
14 | public static ThingDef ZL_StairsUp;
15 |
16 | public static ThingDef ZL_StairsDown;
17 |
18 | public static ThingDef ZL_NaturalHole;
19 |
20 | public static WorldObjectDef ZL_Underground;
21 |
22 | public static WorldObjectDef ZL_Upper;
23 |
24 | public static TerrainDef ZL_OutsideTerrain;
25 |
26 | public static TerrainDef ZL_OutsideTerrainTwo;
27 |
28 | public static TerrainDef ZL_RoofTerrain;
29 |
30 | public static BiomeDef ZL_UndegroundBiome;
31 |
32 | public static BiomeDef ZL_UpperBiome;
33 |
34 | public static GameConditionDef ZL_UndergroundCondition;
35 |
36 | public static KeyBindingDef ZL_switchToUpperMap;
37 |
38 | public static KeyBindingDef ZL_switchToLowerMap;
39 |
40 | public static MapGeneratorDef ZL_EmptyMap;
41 |
42 | public static JobDef ZL_GoToStairs;
43 |
44 | public static JobDef ZL_GoToMap;
45 |
46 | public static JobDef ZL_HaulThingToDest;
47 |
48 | public static JobDef ZL_HaulToCell;
49 |
50 | public static JobDef ZL_GoToLocation;
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/ZLevelsMod.cs:
--------------------------------------------------------------------------------
1 | using HarmonyLib;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using UnityEngine;
8 | using Verse;
9 |
10 | namespace ZLevels
11 | {
12 | class ZLevelsMod : Mod
13 | {
14 | public static Harmony harmony;
15 | public static ZLevelsSettings settings;
16 | public ZLevelsMod(ModContentPack pack) : base(pack)
17 | {
18 | settings = GetSettings();
19 | harmony = new Harmony("ZLevels.Mod");
20 | harmony.PatchAll();
21 | }
22 |
23 | public override void DoSettingsWindowContents(Rect inRect)
24 | {
25 | base.DoSettingsWindowContents(inRect);
26 | settings.DoSettingsWindowContents(inRect);
27 | }
28 | public override string SettingsCategory()
29 | {
30 | return this.Content.Name;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/ZLevelsSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using UnityEngine;
7 | using Verse;
8 |
9 | namespace ZLevels
10 | {
11 | class ZLevelsSettings : ModSettings
12 | {
13 | public bool DebugEnabled = false;
14 | public bool allowZLevelsInfestation = true;
15 | public override void ExposeData()
16 | {
17 | Scribe_Values.Look(ref DebugEnabled, "DebugEnabled", false);
18 | Scribe_Values.Look(ref allowZLevelsInfestation, "allowZLevelsInfestation", true);
19 | base.ExposeData();
20 | }
21 |
22 | // Draw the actual settings window that shows up after selecting Z-Levels in the list
23 | public void DoSettingsWindowContents(Rect inRect)
24 | {
25 | Listing_Standard listingStandard = new Listing_Standard();
26 | listingStandard.Begin(inRect);
27 | listingStandard.CheckboxLabeled("debugEnabledExplanation".Translate(), ref DebugEnabled);
28 | listingStandard.CheckboxLabeled("allowZLevelsInfestation".Translate(), ref allowZLevelsInfestation);
29 | listingStandard.End();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/ZLogger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using Verse;
4 |
5 | namespace ZLevels
6 | {
7 | public static class ZLogger
8 | {
9 | public static DebugLevel curDebugLevel = DebugLevel.All;
10 |
11 | //[Conditional("Debug")]
12 | public static void Pause(string reason)
13 | {
14 | Log.Error("Pausing, reason: " + reason);
15 | Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
16 | }
17 | //[Conditional("Debug")]
18 | public static void Message(string message, DebugLevel debugLevel = DebugLevel.All)
19 | {
20 | if (DebugEnabled && curDebugLevel != DebugLevel.None)
21 | {
22 | if (debugLevel == curDebugLevel || curDebugLevel == DebugLevel.All)
23 | {
24 | Log.Message(ZLogger.Prefix + message);
25 | }
26 | }
27 | }
28 |
29 | public static void Warning(string message)
30 | {
31 | if (DebugEnabled)
32 | Log.Warning(ZLogger.Prefix + message);
33 | }
34 |
35 | public static void Warning(string message, Exception e)
36 | {
37 | if (DebugEnabled)
38 | Log.Warning(ZLogger.Prefix + message + "\n" + (e?.ToString()));
39 | }
40 |
41 | public static void Error(string message)
42 | {
43 | Log.Error(ZLogger.Prefix + message);
44 | }
45 |
46 | public static void Error(string message, Exception e)
47 | {
48 | Log.Error(ZLogger.Prefix + message + "\n" + (e?.ToString()));
49 | }
50 |
51 | public static void ErrorOnce(string message)
52 | {
53 | Log.Error(ZLogger.Prefix + message);
54 | }
55 |
56 | public static bool DebugEnabled => ZLevelsMod.settings.DebugEnabled;
57 |
58 | private static readonly string Prefix = "[Z-Levels] ";
59 | }
60 | }
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/obj/Release/ZLevels.csproj.CopyComplete:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RamRod6198/Z-Levels/7cf66ce417d8fc4928afa7b713f925e9a6494239/Source/ZLevels/ZLevels/obj/Release/ZLevels.csproj.CopyComplete
--------------------------------------------------------------------------------
/Source/ZLevels/ZLevels/obj/Release/ZLevels.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | D:\GAMES\RimWorld\Mods\Z-Levels\Source\ZLevels\ZLevels\bin\Release\ZLevels.dll
2 | D:\GAMES\RimWorld\Mods\Z-Levels\Source\ZLevels\ZLevels\bin\Release\ZLevels.pdb
3 | D:\GAMES\RimWorld\Mods\Z-Levels\Source\ZLevels\ZLevels\bin\Release\0MultiplayerAPI.dll
4 | D:\GAMES\RimWorld\Mods\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.csprojAssemblyReference.cache
5 | D:\GAMES\RimWorld\Mods\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.csproj.CoreCompileInputs.cache
6 | D:\GAMES\RimWorld\Mods\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.csproj.CopyComplete
7 | D:\GAMES\RimWorld\Mods\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.dll
8 | D:\GAMES\RimWorld\Mods\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.pdb
9 | C:\Users\Isaac\Source\Repos\Z-Levels\Source\ZLevels\ZLevels\bin\Release\ZLevels.dll
10 | C:\Users\Isaac\Source\Repos\Z-Levels\Source\ZLevels\ZLevels\bin\Release\ZLevels.pdb
11 | C:\Users\Isaac\Source\Repos\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.csproj.CoreCompileInputs.cache
12 | C:\Users\Isaac\Source\Repos\Z-Levels\Assemblies\ZLevels.dll
13 | C:\Users\Isaac\Source\Repos\Z-Levels\Assemblies\ZLevels.pdb
14 | C:\Users\Isaac\Source\Repos\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.csproj.CopyComplete
15 | C:\Users\Isaac\Source\Repos\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.dll
16 | C:\Users\Isaac\Source\Repos\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.csprojAssemblyReference.cache
17 | C:\Users\Isaac\Source\Repos\Z-Levels\1.2\Assemblies\ZLevels.dll
18 | C:\GAMES\Rimworld\Mods\Z-Levels\1.2\Assemblies\ZLevels.dll
19 | C:\GAMES\Rimworld\Mods\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.csprojAssemblyReference.cache
20 | C:\GAMES\Rimworld\Mods\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.csproj.CoreCompileInputs.cache
21 | C:\GAMES\Rimworld\Mods\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.dll
22 | C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\Z-Levels\1.2\Assemblies\ZLevels.dll
23 | C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.csproj.AssemblyReference.cache
24 | C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.csproj.CoreCompileInputs.cache
25 | C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.dll
26 | C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\Z-Levels\Source\ZLevels\ZLevels\obj\Release\ZLevels.csproj.CopyComplete
27 | C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\Z-Levels\1.3\ZLevels.dll
28 | C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\Z-Levels\1.3\Assemblies\ZLevels.dll
29 |
--------------------------------------------------------------------------------