边缘世界 RimWorld

边缘世界 RimWorld

Layered Atmosphere and Orbit
 此主题已被置顶,因此可能具有重要性
[Zerg03] MrHydralisk  [开发者] 9 月 15 日 下午 1:49
For Modders
Requirments
- defName of PlanetLayerDef, PlanetLayerSettingsDef and ScenPartDef must be same.
- PlanetLayerDef should have LAO's defModExtension to get all needed data about it.

DefModExtension
In your PlanetLayerDef you need to add this defModExtension.

PlanetLayerDef
Vanilla class that determine the planet layer itself. Adding LayeredAtmosphereOrbit.LayeredAtmosphereOrbitDefModExtension to it integrates it into LAO's systems.

DefModExtension
<modExtensions> <li Class="LayeredAtmosphereOrbit.LayeredAtmosphereOrbitDefModExtension"> <isReplaceConnections>true</isReplaceConnections> <isOptionToAutoAdd>true</isOptionToAutoAdd> <elevation>20</elevation> <tempOffest>-10</tempOffest> <planetLayerGroup>LAO_Atmosphere</planetLayerGroup> <isSurface>true</isSurface> <multScatterLumpsMineable>2</multScatterLumpsMineable> <IncidentChanceMultipliers> <SolarFlare>2.3</SolarFlare> </IncidentChanceMultipliers> </li> </modExtensions>
Variables related only to PlanetLayerDef:

- planetLayerGroup [Must have] decides in what layer group it will belong.
- elevation [Must have] decides order and connections between layers. Better be aligned with PlanetLayerDef.elevationString and visualy with PlanetLayerSettingsDef.settings.radius for consistency.
- isReplaceConnections [Suggested] will automatically recalculated connections between this layer and others with such variable.
- isOptionToAutoAdd [Suggested] will show this layer in LAO mod settings to auto add into game scenarios including existing save files.
- tempOffest decide what is the difference between temperature on this planet layer in comparison to same tile on surface.
- isSurface notify game that this planet layer can be considered as surface like layer. Used for separate planets/moon surface.
- multScatterLumpsMineable increase amount of ore chunks spawned on maps within planet layer.
- IncidentChanceMultipliers increase chance of selected IncidentDefs.
- forcedConnectToPlanetLayer add connection to selected planet layer even if doesn't need one automatically. Not advised unless you know what you doing, since LAO will handle connections on it own properly.
- isAvoidFactionDuplication prevents creation of fully new faction for this planet layer, since vanilla game will try to create new faction instead of using existing one of same type. True by default and not advised to change unless you know what you doing.
- birdArrivalChance a chance of birds spawn on maps within layer 6 times a day. Useful for layers within Atmosphere of planet or moon.

More details in DefModExtension.

Can use LAO_TerrainLuna as worldGenSteps, if you want to all not generated terrain on the moon, due to coverage % being made of backgroundBiome instead of vanilla Ocean.

PlanetLayerSettingsDef
Vanilla class that determine in-game values of planet layer itself. Some variables explanations for consistency:

- settings.origin decides coordinates of the in-game position of planet layer. Avoid changing it, even tho it do make moon orbiting Rimworld planet, but it also cause dozens of issue, since vanilla game just not ready for such, which includes but not limited to caravans being drawn on a wrong planet, surface texture being broken...
- settings.radius decides on a size of the sphere defining planet layer. It doesn't affect perfomance, so just keep it logical to your imagined Planet/Moon size. Rimworld surface radius is 100, while Orbit is 130 at 200 km elevation. So you can use formula to determine radius for any layer above planet's surface by [surface radius] + [elevation above surface in km] * 6.667.
- subdivisions defines density of tiles within planet layer. Directly affects perfomance, since bigger number mean bigger amount of generated and calculated tiles within planer layer. Avoid going over 10, since 10 is the density of Rimworld planet's surface. For orbits can use 5, while for moons 6 seems optimal, but can go lower. Try avoid having different density of layers within layer group, since this will make tiles not being directly on top of each other.
- extraCameraAltitude defines how much camera is zoomed, when this planet layer is selected. Prefer values that still allow tiles and text being distinguishable from each other and check if at maximum zoom camera not going through surface of the planets.

PlanetLayerGroupDef
LayeredAtmosphereOrbit.PlanetLayerGroupDef is deciding on how to group layers with similar traits.

By default we have on Rimworld planet:

- Surface. For vanilla surface planet layer, so no new planet layers should be added to it, since surface type is single only per planet.
- Atmosphere. For planet layers with orbiting objects that within Rimworld atmosphere, so objects within it doesn't have vacuum.
- Orbit. For planet layers with orbiting objects that above Rimworld atmosphere, so objects within it have exposure to vacuum.

To make a separate planet or moon you would need to create new planet layer groups. At the very least one for surface of new planet/moon.
For example Luna moon have only Luna surface, but adding orbits around it still possible by adding new planet layer group.
<LayeredAtmosphereOrbit.PlanetLayerGroupDef> <defName>LAO_Surface</defName> <label>surface</label> <description>The foundational ...</description> <defaultPlanetLayer>Surface</defaultPlanetLayer> <viewGizmoTexPath>UI/Commands/ViewPlanet</viewGizmoTexPath> <planet>LAO_Rimworld</planet> <planetLayerGroupsToShowToo> <li>LAO_Atmosphere</li> </planetLayerGroupsToShowToo> <planetLayerGroupsDirectConnection> <li>LAO_Atmosphere</li> <li>LAO_Orbit</li> </planetLayerGroupsDirectConnection> </LayeredAtmosphereOrbit.PlanetLayerGroupDef>
Variables of PlanetLayerGroupDef:

- defaultPlanetLayer determine one of the planet layers within itself. Currently obsolete and not needed.
- planet [Must have] determine what planet/moon this planet layer group related to.
- planetLayerGroupsDirectConnection override DirectConnectionTo() to also consider layers from this planet layer groups in addition to all within current planet layer group.
- viewGizmoTexPath similar to the one in PlanetLayerDef.

Similar to PlanetLayerDef can utilize LayeredAtmosphereOrbitDefModExtension. More details in DefModExtension.

DefModExtension
Variables related only to PlanetLayerGroupDef:

- isPreventQuestMapIfNotWhitelisted prevent spawn of quest sites within this planet layer group. Which is useful if it contains planet layers that not isSpace and also no surface type, since without it ground and orbital sites would have being able to spawn within atmosphere.

PlanetDef
LayeredAtmosphereOrbit.PlanetDef is defining new Planets/Moons.
<LayeredAtmosphereOrbit.PlanetDef> <defName>LAO_Luna</defName> <label>Luna</label> <description>Luna is a large...</description> <posFromRimworld>(-56055.71, 4671.31, 0)</posFromRimworld> <viewGizmoTexPath>UI/Commands/LAO_ViewLuna</viewGizmoTexPath> <typeTag>Moon</typeTag> <gravityWellExitElevation>300</gravityWellExitElevation> <gravityWellRadius>75</gravityWellRadius> <permamentGameConditionDefs/> </LayeredAtmosphereOrbit.PlanetDef>
Variables of PlanetLayerGroupDef:

- posFromRimworld [Must have] define position of this planet/moon in comparison to main Rimworld planet. This position will be used to calculate fuel cost for gravship travel between planets/moons. Distance between plants/moons positions divided by km/fuel in LAO settings. To define distance from main Rimworld planet in km for description just multiply distance between both by 6.67. Use Luna as reference.
- viewGizmoTexPath similar to the one in PlanetLayerDef.
- typeTag [Must have] used for description of whenever it planet or moon in Layer interface world tab.
- gravityWellExitElevation [Must have] used for defining at what elevation in km gravship can initiate grav jump to different planet. And at what elevation gravship will appear next to the planet/moon.
- gravityWellRadius [Must have] defining at what in game radius of planet center gravship will raise before grav jump. Similar to PlanetLayerSettingsDef.radius.
- permamentGameConditionDefs define GameConditionDefs that will be permament on any map within this planet.

DefModExtension
LayeredAtmosphereOrbitDefModExtension also helps defining what incidents, biomes, quests, factions and game conditions can appear on planet layer.
<modExtensions> <li Class="LayeredAtmosphereOrbit.LayeredAtmosphereOrbitDefModExtension"> <vacuum>1</vacuum> <onlyAllowWhitelistedFactions>true</onlyAllowWhitelistedFactions> <minFactionTechLevel>Spacer</minFactionTechLevel> <WhitelistFactionDef> <li>Insect</li> </WhitelistFactionDef> <BlacklistFactionDef> <li>Mechanoid</li> </BlacklistFactionDef> <minArrivalFactionTechLevel>Spacer</minArrivalFactionTechLevel> <WhitelistArrivalFactionDef> <li>Insect</li> </WhitelistArrivalFactionDef> <BlacklistArrivalFactionDef> <li>Mechanoid</li> </BlacklistArrivalFactionDef> <WhitelistGameConditionDef> <li>SolarFlare</li> <li>PsychicDroner</li> </WhitelistGameConditionDef> <WhitelistIncidentDef> <li>Disease_OrganDecay</li> <li>RefugeePodCrash</li> </WhitelistIncidentDef> </li> </modExtensions>
Variables of PlanetLayerDef and PlanetLayerGroupDef:

- onlyAllowWhitelistedFactions similar to onlyAllowWhitelistedGameConditions, which will prevent faction from appearing on this planet layer unless it included in FactionDef.layerWhitelist. Should be enabled, if you don't want universal vanilla factions to spawn on your layers.
- minFactionTechLevel and maxFactionTechLevel defines what range of tech level of factions allowed to appear as settlements on this planet layer.
- WhitelistFactionDef and BlacklistFactionDef defines what factions allowed to appear as settlements on this planet layer.
- minArrivalFactionTechLevel and maxArrivalFactionTechLevel defines what range of tech level of factions allowed to arrive on a map on this planet layer.
- WhitelistArrivalFactionDef and BlacklistArrivalFactionDef defines what factions allowed to arrive on a map on this planet layer.
- WhitelistQuestScriptDef and BlacklistQuestScriptDef defines what quests player can get on this planet layer.
- WhitelistGameConditionDef and BlacklistGameConditionDef defines what game conditions can happen on a map on this planet layer.
- WhitelistIncidentDef and BlacklistIncidentDef defines what incidents can happen on a map on this planet layer.
- WhitelistBiomeDef and BlacklistBiomeDef defines what biomes can spawn on this planet layer.

Variables of PlanetLayerDef, PlanetLayerGroupDef and BiomeDef:

- vacuum used to additionally define amount of vacuum on map for generated pawns to understand if they need vac resistant clothes. Currently there is no point in setting it to non 1, but in future maybe possible to make non space maps with less than 100% vacuum.

Whitelist/Blacklist system
As we all can guess current way in vanilla to handle what can happen on what planet layer quite problematic to work with, especially when many mods trying to change something regarding it. So using described above variables in planet layers or planet layer groups it can be done in a simpler way without need for manual patching. Now let's describe how that works with FactionDef as example:

1. LAO goes through all FactionDef, checking their vanilla layerWhitelist and layerBlacklist, including LAO's onlyAllowWhitelistedFactions to determine list of allowed FactionDefs that currently can spawn on each planet layer.
2. LAO goes through all PlanetLayerGroupDef and PlanetLayerDef, checking for minFactionTechLevel and maxFactionTechLevel. Then, if they defined, allowed FactionDefs overriden by Tech Level.
3. LAO goes through all PlanetLayerGroupDef and PlanetLayerDef, checking for WhitelistFactionDef and BlacklistFactionDef. Then, if they defined, then it adds to allowed FactionDefs.

So in short what can override what: LAO's White/BlacklistFactionDef > LAO's min/maxFactionTechLevel > Vanilla layerWhite/Blacklist. Which allow you to skip patching of each FactionDef to be allowed on your planet layer and define it in LayeredAtmosphereOrbitDefModExtension in your planet layer and planet layer group containing it.
In addition to that LAO's min/maxFactionTechLevel from PlanetLayerGroupDef is overriden by such of PlanetLayerDef. While LAO's White/BlacklistFactionDef PlanetLayerGroupDef combined with such of PlanetLayerDef.
最后由 [Zerg03] MrHydralisk 编辑于; 10 月 12 日 上午 9:34