the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at master 150 lines 3.7 kB view raw
1#pragma once 2 3#include "AgableMob.h" 4#include "Npc.h" 5#include "Merchant.h" 6#include "ParticleTypes.h" 7 8class Level; 9class Village; 10class MerchantRecipeList; 11class MerchantRecipe; 12 13class Villager : public AgableMob, public Npc, public Merchant 14{ 15public: 16 eINSTANCEOF GetType() { return eTYPE_VILLAGER; } 17 static Entity *create(Level *level) { return new Villager(level); } 18 19 //public static final String comment = "No, I won't 'fix' these! They're fine!! - Notch"; 20 21public: 22 static const int PROFESSION_FARMER = 0; 23 static const int PROFESSION_LIBRARIAN = 1; 24 static const int PROFESSION_PRIEST = 2; 25 static const int PROFESSION_SMITH = 3; 26 static const int PROFESSION_BUTCHER = 4; 27 static const int PROFESSION_MAX = 5; 28 29private: 30 static const int DATA_PROFESSION_ID = 16; 31 int villageUpdateInterval; 32 33 bool inLove; 34 bool chasing; 35 weak_ptr<Village> village; 36 37 weak_ptr<Player> tradingPlayer; 38 MerchantRecipeList *offers; 39 int updateMerchantTimer; 40 bool addRecipeOnUpdate; 41 int riches; 42 wstring lastPlayerTradeName; 43 44 bool rewardPlayersOnFirstVillage; 45 46private: 47 48 void _init(int profession); 49 50public: 51 Villager(Level *level); 52 Villager(Level *level, int profession); 53 ~Villager(); 54 55protected: 56 virtual void registerAttributes(); 57 58public: 59 virtual bool useNewAi(); 60 61protected: 62 virtual void serverAiMobStep(); 63 64public: 65 virtual bool mobInteract(shared_ptr<Player> player); 66 67protected: 68 virtual void defineSynchedData(); 69 70public: 71 virtual void addAdditonalSaveData(CompoundTag *tag); 72 virtual void readAdditionalSaveData(CompoundTag *tag); 73 74protected: 75 virtual bool removeWhenFarAway(); 76 virtual int getAmbientSound(); 77 virtual int getHurtSound(); 78 virtual int getDeathSound(); 79 80public: 81 void setProfession(int profession); 82 int getProfession(); 83 bool isInLove(); 84 void setInLove(bool inLove); 85 void setChasing(bool chasing); 86 bool isChasing(); 87 void setLastHurtByMob(shared_ptr<LivingEntity> mob); 88 void die(DamageSource *source); 89 90 void handleEntityEvent(byte id); 91 92private: 93 void addParticlesAroundSelf(ePARTICLE_TYPE particle); 94 95public: 96 void setTradingPlayer(shared_ptr<Player> player); 97 shared_ptr<Player> getTradingPlayer(); 98 bool isTrading(); 99 void notifyTrade(MerchantRecipe *activeRecipe); 100 void notifyTradeUpdated(shared_ptr<ItemInstance> item); 101 MerchantRecipeList *getOffers(shared_ptr<Player> forPlayer); 102 103private: 104 float baseRecipeChanceMod; 105 106 float getRecipeChance(float baseChance); 107 void addOffers(int addCount); 108 109public: 110 void overrideOffers(MerchantRecipeList *recipeList); 111 112private: 113 static unordered_map<int, pair<int,int> > MIN_MAX_VALUES; 114 static unordered_map<int, pair<int,int> > MIN_MAX_PRICES; 115 116public: 117 static void staticCtor(); 118 119private: 120 /** 121 * Adds a merchant recipe that trades items for a single ruby. 122 * 123 * @param list 124 * @param itemId 125 * @param random 126 * @param likelyHood 127 */ 128 static void addItemForTradeIn(MerchantRecipeList *list, int itemId, Random *random, float likelyHood); 129 static shared_ptr<ItemInstance> getItemTradeInValue(int itemId, Random *random); 130 static int getTradeInValue(int itemId, Random *random); 131 132 /** 133 * Adds a merchant recipe that trades rubies for an item. If the cost is 134 * negative, one ruby will give several of that item. 135 * 136 * @param list 137 * @param itemId 138 * @param random 139 * @param likelyHood 140 */ 141 static void addItemForPurchase(MerchantRecipeList *list, int itemId, Random *random, float likelyHood); 142 static int getPurchaseCost(int itemId, Random *random); 143 144public: 145 virtual MobGroupData *finalizeMobSpawn(MobGroupData *groupData, int extraData = 0); // 4J Added extraData param 146 virtual void setRewardPlayersInVillage(); 147 virtual shared_ptr<AgableMob> getBreedOffspring(shared_ptr<AgableMob> target); 148 virtual bool canBeLeashed(); 149 virtual wstring getDisplayName(); 150};