-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
cSpaceTrading
class, with methods such as `ObtainTradingObjec…
…t()`, `AssignPlanetSpice()`, and `GenerateNPCStore()`. Added `cSpaceInventoryItem::CreateTradingObject()`. Added messages `SimulatorMessages::kMsgkMsgSpaceRareFound` and `kMsgSpaceRareDiscovered`. Added `cDistributeEffect`. Added `cSpaceInventoryItem::CreateTradingObject()`. Added messages `SimulatorMessages::kMsgkMsgSpaceRareFound` and `kMsgSpaceRareDiscovered`. Added `cDistributeEffect`.
- Loading branch information
Showing
10 changed files
with
271 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#pragma once | ||
|
||
#include <Spore\Simulator\SubSystem\cStrategy.h> | ||
#include <Spore\Simulator\cGonzagoTimer.h> | ||
#include <Spore\Simulator\cSpaceInventoryItem.h> | ||
#include <Spore\Simulator\cPlanetRecord.h> | ||
#include <Spore\App\IMessageListener.h> | ||
#include <EASTL\map.h> | ||
#include <EASTL\vector.h> | ||
#include <EASTL\fixed_vector.h> | ||
|
||
#define SpaceTrading (*Simulator::cSpaceTrading::Get()) | ||
#define cNPCStorePtr eastl::intrusive_ptr<Simulator::cNPCStore> | ||
|
||
namespace Simulator | ||
{ | ||
class cNPCStore | ||
: public RefCountTemplate | ||
, public ISimulatorSerializable | ||
{ | ||
public: | ||
static const uint32_t TYPE = 0x5B82EF9; | ||
static const uint32_t NOUN_ID = 0x5B82EFA; | ||
|
||
public: | ||
/* 0Ch */ uint32_t planetkey; // -1 | ||
/* 10h */ cGonzagoTimer lifetime; | ||
/* 30h */ int spiceBought; | ||
/* 34h */ eastl::vector<cSpaceInventoryItemPtr> mNPCInventory; | ||
/* 48h */ eastl::vector<cGonzagoTimer> mNPCInventoryAges; | ||
/// If true, this store is not valid anymore and must be refreshed | ||
/* 5Ch */ bool mbDirty; | ||
/* 60h */ eastl::fixed_vector<ResourceKey, 3> mSpiceID; | ||
/* 9Ch */ eastl::fixed_vector<int, 3> mSpiceCost; | ||
}; | ||
ASSERT_SIZE(cNPCStore, 0xC0); | ||
|
||
class cSpaceTrading | ||
/* 00h */ : public cStrategy | ||
/* 1Ch */ , public App::IMessageListener | ||
{ | ||
public: | ||
static cSpaceTrading* Get(); | ||
|
||
void ClearNPCStores(); | ||
|
||
/// Returns true if the space trading item configuration in `spacetrading~` folder | ||
/// has its `spaceTradingType` set to `rare`. | ||
/// @param key Key of the trading item, only the instance ID is used | ||
/// @returns True if the item is rare | ||
static bool IsRare(const ResourceKey& key); | ||
|
||
/// Gives the specified trading object to the player, adding it to its inventory. | ||
/// 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. | ||
/// @param key The key of the item | ||
/// @param amount Quantity to give | ||
void ObtainTradingObject(const ResourceKey& key, int amount = 1); | ||
|
||
/// Assigns the spice of a planet; if the planet already has a spice, it will only recalculate it if `forceReassign` is true. | ||
/// 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. | ||
/// @param planetRecord | ||
/// @param forceReassign [Optional] If this is true, it will assign a new spice even if the planet already had one. | ||
void AssignPlanetSpice(cPlanetRecord* planetRecord, bool forceReassign = false); | ||
|
||
/// Returns whether the given rare has been discovered yet or not. | ||
/// @param key | ||
int GetRareHasBeenFound(const ResourceKey& key); | ||
|
||
/// Marks whether the given rare has been found or not. If found is true, it will emit a message. | ||
/// @param key | ||
/// @param found | ||
void SetRareAsFound(const ResourceKey& key, bool found); | ||
|
||
/// Generates what the NPC sells and buys from the player; called when the player enters the store communication screen. | ||
/// @param planetRecord Current planet where the player is trading | ||
/// @param[out] dstSpiceText | ||
void GenerateNPCStore(cPlanetRecord* planetRecord, LocalizedString& dstSpiceText); | ||
|
||
public: | ||
struct RareGroup { | ||
/* 00h */ uint32_t mGroupID; | ||
/* 04h */ int field_4; | ||
/* 08h */ int field_8; | ||
/* 0Ch */ int field_C; | ||
/* 10h */ eastl::vector<ResourceKey> mRares; | ||
}; | ||
ASSERT_SIZE(RareGroup, 0x24); | ||
|
||
/// List of possible spices for planets | ||
/* 20h */ eastl::vector<ResourceKey> mSpices; | ||
/* 34h */ eastl::vector<ResourceKey> field_34; | ||
/* 48h */ eastl::fixed_vector<cNPCStorePtr, 5> mNPCStore; | ||
/* 74h */ eastl::vector<ObjectPtr> field_74; | ||
/* 88h */ eastl::vector<ObjectPtr> field_88; | ||
/* 9Ch */ int mLastNPCStoreIndex; // not initalized | ||
/// When a rare is found, it's key is set to 1 in this map | ||
/* A0h */ eastl::map<ResourceKey, uint32_t> mRareMap; | ||
/* BCh */ eastl::vector<RareGroup> mRareGroups; | ||
/* D0h */ int field_D0[5]; //TODO | ||
/* E4h */ eastl::vector<uint32_t> mNewlyAvailableCommodities; | ||
}; | ||
ASSERT_SIZE(cSpaceTrading, 0xF8); | ||
|
||
namespace Addresses(cSpaceTrading) | ||
{ | ||
DeclareAddress(Get); // 0xB3D330 0xB3D4D0 | ||
DeclareAddress(ClearNPCStores); // 0x103E9D0 0x103DCD0 | ||
DeclareAddress(IsRare); // 0x103B3B0 0x103A3D0 | ||
DeclareAddress(ObtainTradingObject); // 0x1040890 0x103FC20 | ||
DeclareAddress(AssignPlanetSpice); // 0x103D750 0x103CA50 | ||
DeclareAddress(GetRareHasBeenFound); // 0x103BC30 0x103AC50 | ||
DeclareAddress(SetRareAsFound); // 0x1040820 0x103FBB0 | ||
DeclareAddress(GenerateNPCStore); // 0x103F560 0x103E8F0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
|
||
#include <Spore\Swarm\cGlobalParams.h> | ||
#include <Spore\Swarm\Components\cDistributeDescription.h> | ||
#include <Spore\Swarm\IComponent.h> | ||
#include <Spore\Swarm\IEffectMap.h> | ||
#include <Spore\Swarm\ISurface.h> | ||
#include <Spore\Swarm\ParticleStreamers.h> | ||
|
||
namespace Swarm | ||
{ | ||
class cDistributeEffect | ||
/* 00h */ : public cComponentBase | ||
/* 0Ch */ , public ITextureParticleStreamer | ||
/* 10h */ , public IModelParticleStreamer | ||
{ | ||
public: | ||
/* 14h */ cDistributeDescription* mpDescription; | ||
/* 18h */ int field_18; | ||
/* 1Ch */ IEffectsWorld* mpEffectsWorld; | ||
/* 20h */ cGlobalParams* mpGlobalParams; | ||
/* 24h */ cEffectParams* mpEffectParams; | ||
/* 28h */ int field_28; | ||
/* 2Ch */ Transform field_2C; | ||
/* 64h */ Transform field_64; | ||
/* 9Ch */ int field_9C; | ||
/* A0h */ float mAltitudeRange[2]; // -10000.0, 10000.0 | ||
/* A8h */ eastl::vector<int> field_A8; | ||
/* BCh */ eastl::vector<int> field_BC; | ||
/* D0h */ int field_D0; | ||
/* D4h */ int field_D4; | ||
/* D8h */ eastl::vector<int> field_D8; | ||
/* ECh */ int field_EC; // -1 | ||
/* F0h */ int field_F0; // -1 | ||
/* F4h */ int field_F4; // -1 | ||
/* F8h */ bool field_F8; | ||
/* FCh */ int field_FC; // not initialized | ||
/* 100h */ Math::BoundingBox field_100; | ||
/* 118h */ int field_118; | ||
/* 11Ch */ eastl::vector<cSurfaceRec> mSurfaces; | ||
/* 130h */ eastl::vector<uint8_t> field_130; | ||
/* 144h */ eastl::vector<int> field_144; | ||
/* 158h */ int field_158; | ||
/* 15Ch */ IEffectMapPtr mpEmitMap; | ||
/* 160h */ IEffectMapPtr mpColorMap; | ||
/* 164h */ IEffectMapPtr mpPinMap; | ||
/* 168h */ int mEmitMapModificationCount; | ||
/* 16Ch */ int field_16C; // not initialized | ||
/* 170h */ float field_170; // 1.0 | ||
/* 174h */ float field_174; // 1.0 | ||
/* 178h */ float field_178; // 1.0 | ||
/* 17Ch */ float field_17C; // 1.0 | ||
/* 180h */ float field_180; // 1.0 | ||
/* 184h */ float field_184; // 1.0 | ||
/* 188h */ float field_188; // 1.0 | ||
/* 18Ch */ float field_18C; // 1.0 | ||
/* 190h */ int field_190; | ||
/* 194h */ int field_194; // 1 | ||
/* 19Ch */ eastl::vector<int> field_19C; | ||
}; | ||
ASSERT_SIZE(cDistributeEffect, 0x1B0); | ||
} |