本文整理汇总了C++中GetTypeId函数的典型用法代码示例。如果您正苦于以下问题:C++ GetTypeId函数的具体用法?C++ GetTypeId怎么用?C++ GetTypeId使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetTypeId函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTotalAuraModifier
void Player::UpdateBlockPercentage()
{
// No block
float value = 0.0f;
if (CanBlock())
{
// Base value
value = 5.0f;
// Increase from SPELL_AURA_MOD_BLOCK_PERCENT aura
value += GetTotalAuraModifier(SPELL_AURA_MOD_BLOCK_PERCENT);
// Custom MoP Script
// 76671 - Mastery : Divine Bulwark - Block Percentage
if (GetTypeId() == TYPEID_PLAYER && HasAura(76671))
value += GetFloatValue(PLAYER_MASTERY);
// Custom MoP Script
// 76857 - Mastery : Critical Block - Block Percentage
if (GetTypeId() == TYPEID_PLAYER && HasAura(76857))
value += GetFloatValue(PLAYER_MASTERY) / 2.0f;
// Increase from rating
value += GetRatingBonusValue(CR_BLOCK);
if (sWorld->getBoolConfig(CONFIG_STATS_LIMITS_ENABLE))
value = value > sWorld->getFloatConfig(CONFIG_STATS_LIMITS_BLOCK) ? sWorld->getFloatConfig(CONFIG_STATS_LIMITS_BLOCK) : value;
value = value < 0.0f ? 0.0f : value;
}
SetStatFloatValue(PLAYER_BLOCK_PERCENTAGE, value);
}
示例2: TEST_F
TEST_F(TypeTests, GetInstanceTest) {
for (auto col_type : typeTestTypes) {
auto t = type::Type::GetInstance(col_type);
EXPECT_NE(nullptr, t);
EXPECT_EQ(col_type, t->GetTypeId());
}
}
示例3: GetModifierValue
void Player::UpdateArmor()
{
float value = 0.0f;
UnitMods unitMod = UNIT_MOD_ARMOR;
value = GetModifierValue(unitMod, BASE_VALUE); // base armor (from items)
value *= GetModifierValue(unitMod, BASE_PCT); // armor percent from items
value += GetModifierValue(unitMod, TOTAL_VALUE);
// Custom MoP Script
// 77494 - Mastery : Nature's Guardian
if (GetTypeId() == TYPEID_PLAYER && HasAura(77494))
{
float Mastery = 1.0f + GetFloatValue(PLAYER_MASTERY) * 1.25f / 100.0f;
value *= Mastery;
}
//add dynamic flat mods
AuraEffectList const& mResbyIntellect = GetAuraEffectsByType(SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT);
for (AuraEffectList::const_iterator i = mResbyIntellect.begin(); i != mResbyIntellect.end(); ++i)
{
if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
value += CalculatePct(GetStat(Stats((*i)->GetMiscValueB())), (*i)->GetAmount());
}
value *= GetModifierValue(unitMod, TOTAL_PCT);
SetArmor(int32(value));
UpdateAttackPowerAndDamage(); // armor dependent auras update for SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR
}
示例4: switch
BOOL RecyclableObject::GetDiagTypeString(StringBuilder<ArenaAllocator>* stringBuilder, ScriptContext* requestContext)
{
switch(GetTypeId())
{
case TypeIds_Undefined:
stringBuilder->AppendCppLiteral(_u("Undefined"));
break;
case TypeIds_Null:
stringBuilder->AppendCppLiteral(_u("Null"));
break;
case TypeIds_Integer:
case TypeIds_Number:
stringBuilder->AppendCppLiteral(_u("Number"));
break;
case TypeIds_Boolean:
stringBuilder->AppendCppLiteral(_u("Boolean"));
break;
case TypeIds_String:
stringBuilder->AppendCppLiteral(_u("String"));
break;
default:
stringBuilder->AppendCppLiteral(_u("Object, (Static Type)"));
break;
}
return TRUE;
}
示例5: CanInteract
/////////////////////////////////////////////////
/// Interaction: Unit can interact with another unit (generic)
///
/// @note Relations API Tier 1
///
/// Client-side counterpart: <tt>CGUnit_C::CanInteract(const CGUnit_C *this, const CGUnit_C *unit)</tt>
/////////////////////////////////////////////////
bool Unit::CanInteract(const Unit* unit) const
{
// Simple sanity check
if (!unit)
return false;
// Original logic
// Unit must be selectable
if (unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
return false;
// Unit must have NPC flags so we can actually interact in some way
if (!unit->GetUInt32Value(UNIT_NPC_FLAGS))
return false;
// We can't interact with anyone as a ghost except specially flagged NPCs
if (GetTypeId() == TYPEID_PLAYER && static_cast<const Player*>(this)->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
{
if (unit->GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_GHOST_VISIBLE))
return false;
}
return (GetReactionTo(unit) > REP_UNFRIENDLY && unit->GetReactionTo(this) > REP_UNFRIENDLY);
}
示例6: PL_ASSERT
CmpBool BooleanType::CompareGreaterThanEquals(const Value& left,
const Value& right) const {
PL_ASSERT(GetTypeId() == TypeId::BOOLEAN);
PL_ASSERT(left.CheckComparable(right));
if (left.IsNull() || right.IsNull()) return CMP_NULL;
return BOOLEAN_COMPARE_FUNC(>=);
}
示例7: CheckInteger
std::string IntegerValue::ToString() const {
CheckInteger();
switch(GetTypeId()) {
case Type::TINYINT:
if (IsNull())
return "tinyint_null";
return std::to_string(value_.tinyint);
case Type::SMALLINT:
if (IsNull())
return "smallint_null";
return std::to_string(value_.smallint);
case Type::INTEGER:
case Type::PARAMETER_OFFSET:
if (IsNull())
return "integer_null";
return std::to_string(value_.integer);
case Type::BIGINT:
if (IsNull())
return "bigint_null";
return std::to_string(value_.bigint);
default:
break;
}
throw Exception("type error");
}
示例8: PL_ASSERT
Value *BooleanValue::CompareGreaterThanEquals(const Value &o) const {
PL_ASSERT(GetTypeId() == Type::BOOLEAN);
CheckComparable(o);
if (IsNull() || o.IsNull())
return new BooleanValue(PELOTON_BOOLEAN_NULL);
return new BooleanValue(value_.boolean >= o.GetAs<int8_t>());
}
示例9: PL_ASSERT
Value DecimalType::Modulo(const Value& left, const Value &right) const {
PL_ASSERT(GetTypeId() == Type::DECIMAL);
PL_ASSERT(left.CheckComparable(right));
if (left.IsNull() || right.IsNull())
return left.OperateNull(right);
if (right.IsZero()) {
throw Exception(EXCEPTION_TYPE_DIVIDE_BY_ZERO,
"Division by zero.");
}
switch(right.GetTypeId()) {
case Type::TINYINT:
return ValueFactory::GetDecimalValue(ValMod(left.value_.decimal, right.GetAs<int8_t>()));
case Type::SMALLINT:
return ValueFactory::GetDecimalValue(ValMod(left.value_.decimal, right.GetAs<int16_t>()));
case Type::INTEGER:
return ValueFactory::GetDecimalValue(ValMod(left.value_.decimal, right.GetAs<int32_t>()));
case Type::BIGINT:
return ValueFactory::GetDecimalValue(ValMod(left.value_.decimal, right.GetAs<int64_t>()));
case Type::DECIMAL:
return ValueFactory::GetDecimalValue(ValMod(left.value_.decimal, right.GetAs<double>()));
default:
throw Exception("type error");
}
}
示例10: CanInteractNow
/////////////////////////////////////////////////
/// Interaction: Unit can interact with another unit (immediate response)
///
/// @note Relations API Tier 1
///
/// Client-side counterpart: <tt>CGUnit_C::CanInteractNow(const CGUnit_C *this, const CGUnit_C *unit)</tt>
/////////////////////////////////////////////////
bool Unit::CanInteractNow(const Unit* unit) const
{
// Simple sanity check
if (!unit)
return false;
// Original logic
// We can't intract while on taxi
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_TAXI_FLIGHT))
return false;
// We can't interact while being charmed
if (GetCharmerGuid())
return false;
// We can't interact with anyone while being dead (this does not apply to player ghosts, which allow very limited interactions)
if (!isAlive() && (GetTypeId() == TYPEID_UNIT || !(static_cast<const Player*>(this)->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))))
return false;
// We can't interact with anyone while being shapeshifted, unless form flags allow us to do so
if (IsShapeShifted())
{
if (SpellShapeshiftFormEntry const* formEntry = sSpellShapeshiftFormStore.LookupEntry(GetShapeshiftForm()))
{
if (!(formEntry->flags1 & SHAPESHIFT_FORM_FLAG_ALLOW_NPC_INTERACT))
return false;
}
}
// We can't interact with dead units, unless it's a creature with special flag
if (!unit->isAlive())
{
if (GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_INTERACT_DEAD))
return false;
}
// We can't interact with charmed units
if (unit->GetCharmerGuid())
return false;
// We can't interact with units who are currently fighting
if (unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT) || unit->getVictim())
return false;
return CanInteract(unit);
}
示例11: DoPetCastSpell
void Unit::DoPetCastSpell(Player* owner, uint8 cast_count, SpellCastTargets targets, const SpellEntry* spellInfo)
{
// chained
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet())
if (Pet *chainedPet = GetPet())
if (((Creature*)this)->GetEntry() == chainedPet->GetEntry())
chainedPet->DoPetCastSpell(owner, cast_count, targets, spellInfo);
if(GetTypeId() != TYPEID_UNIT)
return;
Creature* pet = dynamic_cast<Creature*>(this);
uint32 spellid = spellInfo->Id;
clearUnitState(UNIT_STAT_MOVING);
Spell *spell = new Spell(pet, spellInfo, false);
spell->m_cast_count = cast_count; // probably pending spell cast
spell->m_targets = targets;
SpellCastResult result = spell->CheckPetCast(NULL);
if (result == SPELL_CAST_OK)
{
pet->AddCreatureSpellCooldown(spellid);
if (pet->isPet())
{
//10% chance to play special pet attack talk, else growl
//actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell
if(((Pet*)pet)->getPetType() == SUMMON_PET && (urand(0, 100) < 10))
pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL);
else
pet->SendPetAIReaction(pet->GetGUID());
}
spell->prepare(&(spell->m_targets));
}
else
{
pet->SendPetCastFail(spellid, result);
if (!pet->HasSpellCooldown(spellid))
owner->SendClearCooldown(spellid, pet);
spell->finish(false);
delete spell;
}
}
示例12: CheckIdResolver
BinaryObjectImpl BinaryObjectImpl::GetField(const char* name) const
{
CheckIdResolver();
int32_t fieldId = idRslvr->GetFieldId(GetTypeId(), name);
int32_t pos = FindField(fieldId);
return FromMemory(*mem, pos, metaMgr);
}
示例13: GetTotalAuraModValue
void Creature::UpdateMaxHealth()
{
float value = GetTotalAuraModValue(UNIT_MOD_HEALTH);
float hpDiff = GetMaxHealth() - GetHealth();
SetMaxHealth((uint32)value);
if (GetTypeId() == TYPEID_UNIT)
SetHealth((uint32)(value - hpDiff));
}
示例14: GetMap
void Corpse::RemoveFromWorld()
{
///- Remove the corpse from the accessor
if(IsInWorld())
sObjectAccessor.RemoveObject(this);
Object::RemoveFromWorld();
if (GetMap())
GetMap()->AddProcessedObject(GetTypeId(), false);
}
示例15: CopyFrom
int asCScriptObject::CopyFrom(asIScriptObject *other)
{
if( other == 0 ) return asINVALID_ARG;
if( GetTypeId() != other->GetTypeId() )
return asINVALID_TYPE;
*this = *(asCScriptObject*)other;
return 0;
}