Class Rules

java.lang.Object
mindustry.game.Rules

public class Rules extends Object
Defines current rules on how the game should function. Does not store game state, just configuration.
  • Field Details

    • allowEditRules

      public boolean allowEditRules
      Allows editing the rules in-game. Essentially a cheat mode toggle.
    • infiniteResources

      public boolean infiniteResources
      Sandbox mode: Enables infinite resources, build range and build speed.
    • teams

      public Rules.TeamRules teams
      Team-specific rules.
    • waveTimer

      public boolean waveTimer
      Whether the waves come automatically on a timer. If not, waves come when the play button is pressed.
    • waveSending

      public boolean waveSending
      Whether the waves can be manually summoned with the play button.
    • waves

      public boolean waves
      Whether waves are spawnable at all.
    • airUseSpawns

      public boolean airUseSpawns
      Whether air units spawn at spawns instead of the edge of the map
    • wavesSpawnAtCores

      public boolean wavesSpawnAtCores
      If true, units spawn at enemy cores in attack maps with waves enabled.
    • pvp

      public boolean pvp
      Whether the game objective is PvP. Note that this enables automatic hosting.
    • pvpAutoPause

      public boolean pvpAutoPause
      Whether is waiting for players enabled in PvP.
    • pauseDisabled

      public boolean pauseDisabled
      Whether pause is enabled or not in singleplayer
    • waitEnemies

      public boolean waitEnemies
      Whether to pause the wave timer until all enemies are destroyed.
    • attackMode

      public boolean attackMode
      Determines if gamemode is attack mode.
    • editor

      public boolean editor
      Whether this is the editor gamemode.
    • derelictRepair

      public boolean derelictRepair
      Whether blocks can be repaired by clicking them.
    • canGameOver

      public boolean canGameOver
      Whether a gameover can happen at all. Set this to false to implement custom gameover conditions.
    • coreCapture

      public boolean coreCapture
      Whether cores change teams when they are destroyed.
    • reactorExplosions

      public boolean reactorExplosions
      Whether reactors can explode and damage other blocks.
    • possessionAllowed

      public boolean possessionAllowed
      Whether to allow manual unit control.
    • schematicsAllowed

      public boolean schematicsAllowed
      Whether schematics are allowed.
    • damageExplosions

      public boolean damageExplosions
      Whether friendly explosions can occur and set fire/damage other blocks.
    • fire

      public boolean fire
      Whether fire (and neoplasm spread) is enabled.
    • randomWaveAI

      public boolean randomWaveAI
      If true, air and ground units target random things each wave instead of only the core/generators.
    • unitPayloadUpdate

      public boolean unitPayloadUpdate
      EXPERIMENTAL! If true, blocks will update in units and share power.
    • unitPayloadsExplode

      public boolean unitPayloadsExplode
      If true, units' payloads are destroy()ed when the unit is destroyed.
    • unitCapVariable

      public boolean unitCapVariable
      Whether cores add to unit limit
    • hideSpawns

      public boolean hideSpawns
      If true, unit spawn points are hidden.
    • solarMultiplier

      public float solarMultiplier
      Multiplies power output of solar panels.
    • unitBuildSpeedMultiplier

      public float unitBuildSpeedMultiplier
      How fast unit factories build units.
    • unitCostMultiplier

      public float unitCostMultiplier
      Multiplier of resources that units take to build.
    • unitDamageMultiplier

      public float unitDamageMultiplier
      How much damage units deal.
    • unitHealthMultiplier

      public float unitHealthMultiplier
      How much health units start with.
    • unitCrashDamageMultiplier

      public float unitCrashDamageMultiplier
      How much damage unit crash damage deals. (Compounds with unitDamageMultiplier)
    • unitMineSpeedMultiplier

      public float unitMineSpeedMultiplier
      How fast units can mine.
    • unitFactoryActivationDelay

      public float unitFactoryActivationDelay
      Time until unit factories activate (global).
    • ghostBlocks

      public boolean ghostBlocks
      If true, ghost blocks will appear upon destruction, letting builder blocks/units rebuild them.
    • showOtherTeamPings

      public boolean showOtherTeamPings
      If true, pings of players from other teams will be shown.
    • logicUnitControl

      public boolean logicUnitControl
      Whether to allow logic to control units.
    • logicUnitBuild

      public boolean logicUnitBuild
      Whether to allow units to build with logic.
    • logicUnitDeconstruct

      public boolean logicUnitDeconstruct
      Whether to allow units to deconstruct blocks with logic.
    • allowEditWorldProcessors

      public boolean allowEditWorldProcessors
      If true, world processors can be edited and placed on this map.
    • disableWorldProcessors

      public boolean disableWorldProcessors
      If true, world processors no longer update. Used for testing.
    • blockHealthMultiplier

      public float blockHealthMultiplier
      How much health blocks start with.
    • blockDamageMultiplier

      public float blockDamageMultiplier
      How much damage blocks (turrets) deal.
    • buildCostMultiplier

      public float buildCostMultiplier
      Multiplier for buildings resource cost.
    • buildSpeedMultiplier

      public float buildSpeedMultiplier
      Multiplier for building speed.
    • deconstructRefundMultiplier

      public float deconstructRefundMultiplier
      Multiplier for percentage of materials refunded when deconstructing.
    • objectiveTimerMultiplier

      public float objectiveTimerMultiplier
      Multiplier for time in timer objectives.
    • enemyCoreBuildRadius

      public float enemyCoreBuildRadius
      No-build zone around enemy core radius.
    • polygonCoreProtection

      public boolean polygonCoreProtection
      If true, no-build zones are calculated based on the closest core.
    • placeRangeCheck

      public boolean placeRangeCheck
      If true, blocks cannot be placed near blocks that are near the enemy team.
    • cleanupDeadTeams

      public boolean cleanupDeadTeams
      If true, dead teams in PvP automatically have their blocks & units converted to derelict upon death.
    • onlyDepositCore

      public boolean onlyDepositCore
      If true, items can only be deposited in the core.
    • allowCoreUnloaders

      public boolean allowCoreUnloaders
      If true, Serpulo unloaders can take items from the core.
    • itemDepositCooldown

      public float itemDepositCooldown
      Cooldown, in seconds, of item depositing for players.
    • coreDestroyClear

      public boolean coreDestroyClear
      If true, every enemy block in the radius of the (enemy) core is destroyed upon death. Used for campaign maps.
    • hideBannedBlocks

      public boolean hideBannedBlocks
      If true, banned blocks are hidden from the build menu.
    • allowEnvironmentDeconstruct

      public boolean allowEnvironmentDeconstruct
      If true, most blocks (including environmental walls) can be deconstructed. This is only meant to be used internally in sandbox/test maps.
    • instantBuild

      public boolean instantBuild
      If true, buildings will be constructed instantly, with no limit on blocks placed per second. This is highly experimental and may cause lag!
    • blockWhitelist

      public boolean blockWhitelist
      If true, bannedBlocks becomes a whitelist.
    • unitWhitelist

      public boolean unitWhitelist
      If true, bannedUnits becomes a whitelist.
    • dropZoneRadius

      public float dropZoneRadius
      Radius around enemy wave drop zones.
    • waveSpacing

      public float waveSpacing
      Time between waves in ticks.
    • initialWaveSpacing

      public float initialWaveSpacing
      Starting wave spacing; if <=0, uses waveSpacing * 2.
    • winWave

      public int winWave
      Wave after which the player 'wins'. Use a value <= 0 to disable.
    • unitCap

      public int unitCap
      Base unit cap. Can still be increased by blocks.
    • disableUnitCap

      public boolean disableUnitCap
      If true, the unit cap is disabled.
    • dragMultiplier

      public float dragMultiplier
      Environment drag multiplier.
    • env

      public int env
      Environmental flags that dictate visuals & how blocks function.
    • attributes

      public Attributes attributes
      Attributes of the environment.
    • sector

      @Nullable public Sector sector
      Sector for saves that have them.
    • ambientMusic

      @Nullable public arc.struct.Seq<MusicContainer> ambientMusic
      Overrides random ambient music to be played.
    • darkMusic

      @Nullable public arc.struct.Seq<MusicContainer> darkMusic
      Overrides music that is played in certain situations, like during boss waves or low core health.
    • alwaysPlayMusic

      public boolean alwaysPlayMusic
      If true, this overrides the game setting to always play ambient music.
    • disableMusic

      public boolean disableMusic
      If true, automatic music is disabled.
    • musicVolume

      public float musicVolume
      Multiplier for music volume (max value is 1).
    • spawns

      public arc.struct.Seq<SpawnGroup> spawns
      Spawn layout.
    • loadout

      public arc.struct.Seq<ItemStack> loadout
      Starting items put in cores.
    • weather

      public arc.struct.Seq<Weather.WeatherEntry> weather
      Weather events that occur here.
    • blockLimits

      public arc.struct.ObjectIntMap<Block> blockLimits
      Block placement limits by type.
    • bannedBlocks

      public arc.struct.ObjectSet<Block> bannedBlocks
      Blocks that cannot be placed.
    • bannedUnits

      public arc.struct.ObjectSet<UnitType> bannedUnits
      Units that cannot be built.
    • revealedBlocks

      public arc.struct.ObjectSet<Block> revealedBlocks
      Reveals blocks normally hidden by build visibility.
    • researched

      public arc.struct.ObjectSet<UnlockableContent> researched
      Unlocked content names. Only used in multiplayer when the campaign is enabled.
    • objectives

      public MapObjectives objectives
      In-map objective executor.
    • objectiveFlags

      public arc.struct.ObjectSet<String> objectiveFlags
      Flags set by objectives. Used in world processors.
    • fog

      public boolean fog
      If true, fog of war is enabled. Enemy units and buildings are hidden unless in radar view.
    • staticFog

      public boolean staticFog
      If fog = true, this is whether static (black) fog is enabled.
    • staticColor

      public arc.graphics.Color staticColor
      Color for static, undiscovered fog of war areas.
    • dynamicColor

      public arc.graphics.Color dynamicColor
      Color for discovered but un-monitored fog of war areas.
    • lighting

      public boolean lighting
      Whether ambient lighting is enabled.
    • ambientLight

      public arc.graphics.Color ambientLight
      Ambient light color, used when lighting is enabled.
    • defaultTeam

      public Team defaultTeam
      team of the player by default.
    • waveTeam

      public Team waveTeam
      team of the enemy in waves/sectors.
    • cloudColor

      public arc.graphics.Color cloudColor
      color of clouds that is displayed when the player is landing
    • modeName

      @Nullable public String modeName
      name of the custom mode that this ruleset describes, or null.
    • mission

      @Nullable public String mission
      Mission string displayed instead of wave/core counter. Null to disable.
    • coreIncinerates

      public boolean coreIncinerates
      Whether cores incinerate items when full, just like in the campaign.
    • borderDarkness

      public boolean borderDarkness
      If false, borders fade out into darkness. Only use with custom backgrounds!
    • limitMapArea

      public boolean limitMapArea
      If true, the map play area is cropped based on the rectangle below.
    • limitX

      public int limitX
      Map area limit rectangle.
    • limitY

      public int limitY
      Map area limit rectangle.
    • limitWidth

      public int limitWidth
      Map area limit rectangle.
    • limitHeight

      public int limitHeight
      Map area limit rectangle.
    • disableOutsideArea

      public boolean disableOutsideArea
      If true, blocks outside the map area are disabled.
    • tags

      public arc.struct.StringMap tags
      special tags for additional info.
    • customBackgroundCallback

      @Nullable public String customBackgroundCallback
      Name of callback to call for background rendering in mods; see Renderer#addCustomBackground. Runs last.
    • backgroundTexture

      @Nullable public String backgroundTexture
      path to background texture with extension (e.g. "sprites/space.png")
    • backgroundSpeed

      public float backgroundSpeed
      background texture move speed scaling - bigger numbers mean slower movement. 0 to disable.
    • backgroundScl

      public float backgroundScl
      background texture scaling factor
    • backgroundOffsetX

      public float backgroundOffsetX
      background UV offsets
    • backgroundOffsetY

      public float backgroundOffsetY
      background UV offsets
    • planetBackground

      @Nullable public PlanetParams planetBackground
      Parameters for planet rendered in the background. Cannot be changed once a map is loaded.
    • planet

      public Planet planet
      Rules from this planet are applied. If it's sun, mixed tech is enabled.
    • allowLogicData

      public boolean allowLogicData
      If the `data` instruction is allowed for world processors
  • Constructor Details

    • Rules

      public Rules()
  • Method Details

    • copy

      public Rules copy()
      Copies this ruleset exactly. Not efficient at all, do not use often.
    • retainContentFields

      public void retainContentFields(Rules source)
      When a map is played, it uses rules from the rules dialog, which cannot contain patched content, since it doesn't exist at that point in time. This means that any existing rules containing patched content will contain garbage or empty data. This function copies original map rule data from (obtained after map load) that may contain new content into this ruleset.
    • mode

      public Gamemode mode()
      Returns the gamemode that best fits these rules.
    • hasEnv

      public boolean hasEnv(int env)
    • buildRadius

      public float buildRadius(Team team)
    • unitBuildSpeed

      public float unitBuildSpeed(Team team)
    • unitCost

      public float unitCost(Team team)
    • unitDamage

      public float unitDamage(Team team)
    • unitHealth

      public float unitHealth(Team team)
    • unitCrashDamage

      public float unitCrashDamage(Team team)
    • unitMineSpeed

      public float unitMineSpeed(Team team)
    • blockHealth

      public float blockHealth(Team team)
    • blockDamage

      public float blockDamage(Team team)
    • buildSpeed

      public float buildSpeed(Team team)
    • isBanned

      public boolean isBanned(Block block)
    • isBanned

      public boolean isBanned(UnitType unit)
    • unitActivationDelay

      public float unitActivationDelay(Team team)