Data fields

From Cosmoteer Wiki
< ModdingModding/Data fields
Jump to navigation Jump to search
CalloutIconWarning.png
Work in Progress
This page is currently WORK IN PROGRESS. Some things may not be up-to-date or documented at all.

Feel free to contribute and don't worry about perfection - other editors can make corrections if necessary. Just get creating!

Definition

«Data fields» are the individual fields that are present in every .rules file. A field is a place where you can write text.

They act like variables that help define the nature and function of the part.

CalloutIconTip.png
Tip
To see the basic usage of data fields for modding purposes, check out the example mod.

"Part" data fields

Code location (what's this?): Cosmoteer.Ships.Parts.PartRules

This section describes the data fields used in parts.

Inheritance

The class PartRules itself inherits nothing.

However base_part.rules is the .rules that ALL other parts inherit from (directly on not). It's in the game's Data directory, in the ships folder.

CalloutIconNote.pngInfo
Technically, asteroid bits are parts too, and inherit from base_part like all the others.

Here is the inheritance visualized :

  • base_part
    • base_part_terran
      • most parts you are familiar with
    • base_part_asteroid
    • base_part_megaroid

This means that even fields defined below as "Required" may not be present in parts you look at or make, but that's not a problem as long as they are defined in base_part.rules.or base_part_terran.rules .

List of fields

CalloutIconWarning.pngWork in Progress
This list is currently work-in-progress. Some things may be missing.

Feel free to contribute to make it better!

Name Type Required Buffable? Default value Description
NameKey
KeyString Yes - - The part's name, displayed when selected or hovered over.
IconNameKey
KeyString? - - - The part name as it shows up in the ship editor's menus.
JobsNameKey
KeyString? - - - ??
ID
ID<PartRules> Yes - - Game-wide unique ID of the part, which must start with the author's name.
OtherIDs
ID<PartRules>[]? - - -
FlipWhenLoadingIDs
(see description) - - - HashSet<Cosmoteer.Data.ID<PartRules>>?
EditorGroups
ID<EditorGroupRules>[]?

meaning : A list of names in [].

Yes - - These are the names of the tabs in which the part will appear, in the ship editor.
IsBuildable
bool - - true If "false", you cannot build it. The part will not appear in the build menus, and is considered an invalid part when found in a ship. Whether or not you can paste such a ship in depends on your settings.
Resources
(see description) Yes - - Type : (Cosmoteer.Data.ID<ResourceRules> Type, int Quantity)[]

An array of "Resource Name & Cost" pairs in [] which define what a part costs. Presumably goes up to 2,147,483,647 and accepts negative values (needs testing). The Cost part of each pair also accepts formulas, E.g. 8 * 4.

Note that reducing this in copies of base game parts can lead to a crash when the part is destroyed.

FractionalCostToRepair
float (%) Yes - 25%

(base_part)

How much of the building cost at most will be spent to repair the part to full health.

Note that this does not seem to affect rare resources, which seem ignored in repair costs entirely. (verify)

Size
IntVector2 Yes - - An array which defines the width and height of a part.

The minimum value for both width and height is 1. Cannot accept decimal values.

Density
float Yes - 1

(base_part)

How much 1 tile of the part weighs in tons. The total mass of the part, not accounting for other Colliders, is (Size_X * Size_Y * Density).

It is not reduced when the part becomes more damaged. More massive parts are harder to move. Example mod.

See also : BaseCollider

MaxHealth
int Yes - - How much damage the part can endure before being destroyed.

Repair is only possible before this reaches 0.

HealthType
HealthType Yes - Operational

(base_part)

See HealthTypes.
Flammable
bool Yes - true

(base_part)

Can the part catch on fire.

Structures and armor blocks have "false".

Part placement blocking
Used for thruster and weapon exclusion zones. Has more potential.

Click the Name for details.

HasNonContiguousPathing
bool - - - For optimization[1]. Set it to "true" if there are any tiles/cells of your custom part that crew can't walk on in any direction.
SelectionPriority
int Yes - -
SelectionTypeID
ID<PartRules>? - - -
SelectionTypeByRotation
bool Yes - false If true, double-clicking the part in-game will only select all parts of the same type that are facing the same direction.

That's usually the case for thrusters and weapons.

IsExternal
bool Yes - false

(base_part)

If false, the part can have either no doors between itself and anything else, or all doors that have legal placement. If true, the part can have doors with other parts but not between itself and other parts with the same part ID.

Only ion_beam_prism and all structures have "true". See the examples below. Also see IsWalled.

IsRotateable
bool Yes - -
IsFlippable
bool Yes - -
IsWalled
bool Yes - true

(base_part)

If false, the part can only have doors to parts where it is not false (other parts don't need doors to be accessible), unless IsExternal is true, in which case it can have doors to other "non-walled" parts.

Armors have "true". Only corridor, conveyor, ion_beam_prism and all structures have "false".

See the examples below.

JobsIcon
ISprite? - - -
FlipHRotate
int[] Yes - -
FlipVRotate
int[] Yes - -
AIValueFactor
float - - 1 Presumably, how much the AI wants to destroy this part on ships it considers enemies.
ReceivableBuffIDs

alias

ReceivableBuffs

(see description) - - - Type : HashSet<Cosmoteer.Data.ID<BuffType>>?

The list containing the identifiers of the buffs this part can be affected by.

MinBuffValues
(see description) - - - Type : Dictionary<Cosmoteer.Data.ID<BuffType>, float>?
MaxBuffValues
(see description) - - - Type : Dictionary<Cosmoteer.Data.ID<BuffType>, float>?

Other fields

This section describes the part's data fields that don't fit into other categories.

Name Type Defines types

Default value Description
EditorGroup string none The one and only group where the part will appear in Build Mode. If you put more than 1 group there, the game crashes.
EditorGroups list [string, string] none The multiple groups where the part will appear in Build Mode. If you forgot the "s" in the data field's name, it becomes the singular version, and the game crashes.

To-do fields

These fields have not been added to this page, and thus require research and descriptions.

If you document any fields, please remove them from the table afterwards.

header
Fields:
public ViKey[]? DefaultEditorHotkey;
public Cosmoteer.Data.ID<PartRules> EditorReplacementPartID;
public KeyString? DescriptionKey;
public readonly int Cost;
public Dictionary<Cosmoteer.Data.ID<ResourceRules>, int> ResourcesByType;
public IntRect? PhysicalRect;
public IntRect? SaveRect;
public AdjacencyFlags AllowedContiguity = AdjacencyFlags.Sides;h
public bool GenerateRectCollider = true;
public PartRectType RectColliderRectType = PartRectType.Physical;
public PartRectType BoundingRectType;
public int SelectionPriority;
public Cosmoteer.Data.ID<PartRules>? SelectionTypeID;
public int[] SelectionTypeRotations = new int[1];
public bool IgnoreRotationForMirroredSelection;
public Time? ConstructionDuration;
public Time ConstructionSwapDelay;
public Time? RepairDuration;
public MultiMediaEffectRules? SalvageProgressMediaEffects;
public Time SalvageProgressMediaEffectsTimeout;
public MultiMediaEffectRules? ConstructionProgressMediaEffects;
public Time ConstructionProgressMediaEffectsTimeout;
public MultiMediaEffectRules? ConstructionFinishedMediaEffects;
public Range<BuffableFloat> ExplosiveDamageAbsorption;
public Dictionary<Cosmoteer.Data.ID<DamageType>, Range<BuffableFloat>> DamageResistances = new Dictionary<Cosmoteer.Data.ID<DamageType>, Range<BuffableFloat>>();
public Cosmoteer.Data.ID<PartRules> UnderlyingPart;
public Cosmoteer.Data.ID<PartRules> UnderlyingPartPerTile;
public bool CreateUnderlyingWhenDestroyed = true;
public Cosmoteer.Data.ID<PartRules> TempConstructionPartPerTile;
public Cosmoteer.Data.ID<PartRules> CreatePartPerTileWhenGrabbed;
public float DestroyedPartHealthFraction = 1f;
public float CrewKillChanceWhenDestroyed;
public float CrewThrowSpeedWhenDestroyed;
public Range<BuffableFloat> InitialPenetrationResistance;
public Range<BuffableFloat> ContinuingPenetrationResistance;
public DirectionalCrewSpeeds CrewSpeedFactor;
public DirectionalCrewSpeeds CrewCongestedSpeedFactor;
public DirectionalCrewSpeeds CrewFireSpeedFactor;
public BuffableFloat FireDamageFactor = (BuffableFloat) 1f;
public bool IsCrewSalvageable = true;
public HashSet<IntVector2>? BlockedTravelCells;
public Dictionary<IntVector2, TravelDirection[]>? BlockedTravelCellDirections;
public bool ForceManhattanPathInPart;
public int ContiguityOriginPriority;
public bool IsSelfDestructible;
public bool IsLowPriorityDeconstruction;
public bool? ForceBrushCompatibility;
public IntVector2[]? AllowedDoorLocations;
public int MaxDoors = int.MaxValue;
public bool GeneratorRequiresDoor;
public int AutoDoorMaxPathLength;
public bool NoAutoDoors;
public AdjacencyFlags ExternalWalls;
public AdjacencyFlags? BlueprintExternalWalls;
public Dictionary<IntVector2, AdjacencyFlags>? ExternalWallsByCell;
public Dictionary<IntVector2, AdjacencyFlags>? BlueprintExternalWallsByCell;
public AdjacencyFlags InternalWalls;
public AdjacencyFlags? BlueprintInternalWalls;
public Dictionary<IntVector2, AdjacencyFlags>? InternalWallsByCell;
public Dictionary<IntVector2, AdjacencyFlags>? BlueprintInternalWallsByCell;
public VirtualInternalCell[]? VirtualInternalCells;
public HashSet<Cosmoteer.Data.ID<PartCategory>> TypeCategories;
public HashSet<Cosmoteer.Data.ID<PartCategory>> RequiresCategories;
public HashSet<Cosmoteer.Data.ID<PartCategory>>? AffectsValidityOfCategories;
public ISprite EditorIcon;
public readonly List<PartComponentRules> Components = new List<PartComponentRules>();
public readonly List<PartComponentRules> PhysicalComponents = new List<PartComponentRules>();
public readonly List<PartComponentRules> BlueprintComponents = new List<PartComponentRules>();
public readonly List<PartComponentRules> DestroyedComponents = new List<PartComponentRules>();
public readonly List<PartComponentRules> BlueprintDrawableComponents = new List<PartComponentRules>();
public readonly Dictionary<Cosmoteer.Data.ID<PartComponentRules>, PartComponentRules> ComponentsByID = new Dictionary<Cosmoteer.Data.ID<PartComponentRules>, PartComponentRules>();
public readonly Dictionary<Cosmoteer.Data.ID<PartToggleGuiRules>, PartUIToggleRules> UIToggleComponentsByID = new Dictionary<Cosmoteer.Data.ID<PartToggleGuiRules>, PartUIToggleRules>();
public readonly Dictionary<Cosmoteer.Data.ID<PartColorGuiRules>, PartUIColorRules> UIColorComponentsByID = new Dictionary<Cosmoteer.Data.ID<PartColorGuiRules>, PartUIColorRules>();
public Dictionary<Cosmoteer.Data.ID<PartStatRules>, PartStatValues>? Stats;
public List<PartStatsCategory>? StatsByCategory;
public KeyString? StatsNotesKey;
public ShipRules ShipRules;
public readonly List<PriorityInfo> PriorityInfos = new List<PriorityInfo>();
public HashSet<IntVector2>? FlexResourceGridCells;

BuffableFloat ExplosiveDamageResistance;

Examples

IsExternal = true

IsExternal examples

IsExternal when "false" (images on the left), and when "true" (image on the right) (both courtesy of Ahlgreen) :

IsWalled = false | IsWalled = true

See also