Simulator::cSpaceTrading class

Singleton class for everything related to space stage trading, such as obtaining tradable items or generating NPC stores.

This class manages the objects in the GroupIDs::SpaceTrading_ folder. Example usage:

// Get 3 red spice
SpaceTrading.ObtainTradingObject({ id("spice1"), TypeIDs::prop, GroupIDs::SpaceTrading_ }, 3);

Base classes

class cStrategy
class App::IMessageListener
An interface that can receive messages sent through the app.

Public types

struct RareGroup

Public static functions

static auto Get() -> cSpaceTrading*
static auto IsRare(const ResourceKey& key) -> bool
Returns true if the space trading item configuration in spacetrading~ folder has its spaceTradingType set to rare.

Constructors, destructors, conversion operators

ASSERT_SIZE(RareGroup, 0x24)

Public functions

auto ClearNPCStores() -> void
auto ObtainTradingObject(const ResourceKey& key, int amount = 1) -> void
Gives the specified trading object to the player, adding it to its inventory.
auto AssignPlanetSpice(cPlanetRecord* planetRecord, bool forceReassign = false) -> void
Assigns the spice of a planet; if the planet already has a spice, it will only recalculate it if forceReassign is true.
auto GetRareHasBeenFound(const ResourceKey& key) -> int
Returns whether the given rare has been discovered yet or not.
auto SetRareAsFound(const ResourceKey& key, bool found) -> void
Marks whether the given rare has been found or not.
auto GenerateNPCStore(cPlanetRecord* planetRecord, LocalizedString& dstSpiceText) -> void
Generates what the NPC sells and buys from the player; called when the player enters the store communication screen.

Public variables

eastl::vector<ResourceKey> mSpices
List of possible spices for planets.
eastl::vector<ResourceKey> field_34
eastl::fixed_vector<cNPCStorePtr, 5> mNPCStore
eastl::vector<ObjectPtr> field_74
eastl::vector<ObjectPtr> field_88
int mLastNPCStoreIndex
eastl::map<ResourceKey, uint32_t> mRareMap
When a rare is found, it's key is set to 1 in this map.
eastl::vector<RareGroup> mRareGroups
int field_D0
eastl::vector<uint32_t> mNewlyAvailableCommodities

Function documentation

static bool Simulator::cSpaceTrading::IsRare(const ResourceKey& key)

Returns true if the space trading item configuration in spacetrading~ folder has its spaceTradingType set to rare.

Parameters
key Key of the trading item, only the instance ID is used
Returns True if the item is rare

void Simulator::cSpaceTrading::ObtainTradingObject(const ResourceKey& key, int amount = 1)

Gives the specified trading object to the player, adding it to its inventory.

Parameters
key The key of the item
amount Quantity to give

The key must be a .prop file in GroupIDs::SpaceTrading_ group. If the item is a rare, it will show an event log, give a badge if necessary, and emit the SimulatorMessages::kMsgSpaceRareFound message.

void Simulator::cSpaceTrading::AssignPlanetSpice(cPlanetRecord* planetRecord, bool forceReassign = false)

Assigns the spice of a planet; if the planet already has a spice, it will only recalculate it if forceReassign is true.

Parameters
planetRecord
forceReassign [Optional] If this is true, it will assign a new spice even if the planet already had one.

The function checks all the spices in cSpaceTrading::mSpices, and picks one based on the probabilities and the planet type and difficulty (blue orbit on easy, red orbit on hard, etc.). It then sets the cPlanetRecord::mSpiceGen key.

int Simulator::cSpaceTrading::GetRareHasBeenFound(const ResourceKey& key)

Returns whether the given rare has been discovered yet or not.

Parameters
key

void Simulator::cSpaceTrading::SetRareAsFound(const ResourceKey& key, bool found)

Marks whether the given rare has been found or not.

Parameters
key
found

If found is true, it will emit a message.

void Simulator::cSpaceTrading::GenerateNPCStore(cPlanetRecord* planetRecord, LocalizedString& dstSpiceText)

Generates what the NPC sells and buys from the player; called when the player enters the store communication screen.

Parameters
planetRecord Current planet where the player is trading
dstSpiceText out