Skip to content

Component Definitions and the JsonParser.

se5a edited this page Dec 15, 2024 · 14 revisions

The Json parser uses NCalc https://github.com/ncalc/ncalc/ and comes with builtin functions: https://github.com/ncalc/ncalc/wiki/Functions

In addition we've added a number of custom functions:

Function Name Arguments
PropertyValue (string) Name of another Property, References the PropetyFormula Value of another Property on the component
EnumDict (string) Type name of the enum
TechData (GuidString) Guid of the Tech
TechLevel (GuidString) Guid of the Tech
CargoType (GuidString) Guid of the CargoType
GuidString (string) Guid in string format
AtbConstrArgs List of arguments used in associated datablob constructor
ExhaustVelocityLookup (GuidString) Guid of an ICargoable that has an ExhaustVelocityFormula

TechSD

TechSD is fairly straightforward and simple. The class for this is located here: https://github.com/Pulsar4xDevs/Pulsar4x/blob/ECS-CrossPlatform/Pulsar4X/Pulsar4X.ECSLib/StaticData/TechSD.cs

Tech Formula Fields:

  • DataFormula
  • CostFormula

Tech Parameters:

Currently there is only one:

  • [Level]
    Returns the Level that a faction currently has researched to for this Tech: factionTechs.LevelforTech(tech));

Tech Formula

Currently there are only the built in formula found here: https://github.com/ncalc/ncalc/wiki/Functions

Tech Json Example

  {
    "Type": "Tech",
    "Payload": {
      "UniqueID": "tech-conventional-engine-max-power",
      "Name": "Rocket Engine Maximum Power",
      "Description": "Research to increase the upper limits of conventional rocket power",
      "MaxLevel": 7,
      "DataFormula": "1 + ([Level] * 1.5)",
      "Category": "tech-category-power-propulsion",
      "CostFormula": "(1 + [Level]) * 100"
    }

ComponentSD

Components are quite complex and will be expanded on in another page. here: https://github.com/Pulsar4xDevs/Pulsar4x/wiki/Component-Blueprints

Clone this wiki locally