Skip to content

IComponentDesignAttribute

se5a edited this page Dec 20, 2024 · 1 revision

Attributes are any class that inherits from IComponentDesignAttribute

they give components and entities their abilities.

Old Code:

These classes used to inherit from BaseDatablob making them datablobs, while this is no longer the case, there is still some older code where the atribute may still inherit from the BaseDatablob and also the Nomenclature (some are still called DB at the end) in this regard this page is a little outdated.

Json relationship:

A component design attribute is something that gets set on a component at design time, the object is created when a component is designed and is directly referenced in the json, eg:
"AttributeType": "Pulsar4X.Storage.CargoTransferAtb"
AttributeType here references the CargoTransferAtb which inherits from IComponentDesignAttribute.
The json PropertyFormula is used to create the constructor parameters:
"PropertyFormula": "AtbConstrArgs(PropertyValue('Transfer Rate'), PropertyValue('Transfer Range'))",

Specific Atb objects:

MineResourcesAtbDB

Stores a dictionary of raw mineral guid, and the amount that resource can be mined each econ tick:
public Dictionary<Guid, int> ResourcesPerEconTick { get; internal set; }
Note that the constructor takes the amounts as a double, this is converted to an int(this is due to how the json parser works)
public MineResourcesAtbDB(Dictionary<Guid,double> resources)
AbilityFormula format: AbilityFormula": "DataBlobArgs([GuidDict]) (note that the GuidDictionary needs to have the guid key, int value pairs)

RefineResourcesAtbDB

Stores a list of Guid for the ProcessedMaterials it can produce, and an int for the speed at which it can produce them:
public List<Guid> RefinableMatsList { get; internal set; }
public int RefineryPoints { get; internal set; }
The constructor takes a dictionary<Guid, double> and refinary points as a double that gets cast to an int the dictionary values are ignored (mostly this is due to me not wanting to add a list field in the AbilitySD, when a dictionary already exsisted)
public RefineResourcesAtbDB(Dictionary<Guid, double> refinableMatsList, double refineryPoints) (again, the GuidDictionary stores the guid key, int value pairs).
TODO: we may look at changing this to be similar to the MineResourcesAtbDB, it would make this attribute simpler to create, but more importantly it would give more flexibility to the game play - currently if two different component designs are added, one which creates fuel at 10 points per etick, and another which creates energy at 5 points per etick, the parent entity would be able to make fuel or energy at 15 per tick. on the downside it'd make the processor more complex however.

CargoStorageAtbDB

Stores:
public int StorageCapacity { get; internal set; }
public Guid CargoTypeGuid { get; internal set; }
Constructor: (storageCapaicty gets cast to int)
public CargoStorageAtbDB(double storageCapacity, Guid cargoType)
AbilityFormula format: "AbilityFormula": "1000, GuidString('16b4c4f0-7292-4f4d-8fea-22103c70b288'))"

EnginePowerAtbDB

Stores an int defining how much enginepower a component will provide

TODO: add more AtbDB as they get fully implemented.

Clone this wiki locally