Skip to content
Milan Ender edited this page Aug 22, 2016 · 14 revisions

Economy Wiki

I'll try to extend this wiki and provide an easy walkthrough/tutorial in the future. For now, you can find some basic guidelines here.

Table of contents

1. Create resource production and consumer entities.
2. Make your custom storage component compatible with other storage/logistic systems.
3. Interacting with the logistic interface.

1. Creating resource producers/consumers

That one is easy: Just add a MarketSubscriberComponent to your entity. There you have the possibility to specify what resources are needed to produce the specified products (can be left empty if there are none). You also have to set an entityRefs to the entities where the MarketLogisticSystem should look for storage components, one to draw potential consumption resources from and one to store potential products. You'll also need to specify the time interval (should be in seconds) on which the production and consumption events are sent. Currently you'll also need to register your entity to the MarketUpdaterSystem by sending a SubscriberRegistrationEvent (uses default constructor).

2. Registering custom storage components

The only thing you really have to do is to implement the StorageComponentHandler for the storage-component you use in your mod. When the handler is ready, you'll need to register it in the StorageHandlerLibrary by calling storageHandlerLibrary.registerHandler(StorageComponentHandler handler). Then you are already done :). Keep in mind that the handler most likely has to translate the resource representation within the economy module (String type, int amount) into your own, which will most likely be an actual item. I'll try to set up the a standard handler for the core stuff as a good example. For now you can use the very simple InfiniteStorageHandler for the InfiniteStorageComponent as a rough guide.

3. Interacting with the logistic system

Using the logistic capabilities of this module is pretty straightforward: You'll find the current available actions in the events folder. Just send them from the entity of your choice and the system should to the rest! Current actions include:

  • Store resource in a target.
  • Draw resource from a target.
  • Create resource.
  • Destroy resource.
    Conditioned production of resources and store them in a target: The condition here is currently only that the specified consumption resources are available in the respective entity and that the target has enough storage capacity.
  • Request information: Get the resources and their amount.

I have plans to include a condition interface, which will allow to check target/origin entities for extra conditions that you can specify.