class
cSpaceTradingSingleton 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::
// 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 itsspaceTradingType
set torare
.
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.
- auto CreateTradingObject(cSpaceInventoryItemPtr& dst, const ResourceKey& itemID, int itemCount, float itemCost) -> void
- Creates a trading object, which is an inventory item from GroupIDs::
SpaceTrading_.
Public variables
- eastl::vector<ResourceKey> mSpices
- List of possible spices for planets.
- eastl::vector<ResourceKey> field_34
- Apparently list of possible tools to be bought.
- 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::
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::
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 |
void Simulator:: cSpaceTrading:: CreateTradingObject(cSpaceInventoryItemPtr& dst,
const ResourceKey& itemID,
int itemCount,
float itemCost)
Creates a trading object, which is an inventory item from GroupIDs::
Parameters | |
---|---|
dst out | Pointer where the new object will be written. |
itemID | Key to the item configuration in GroupIDs:: |
itemCount | Number of items to create |
itemCost | Cost of the object |