// Ryzom - MMORPG Framework
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
#ifndef RY_GAME_SHARE_PROPERTIES_H
#define RY_GAME_SHARE_PROPERTIES_H
#include "nel/misc/types_nl.h"
/**
* Class to manage some properties of an entity.
* \author Guillaume PUZIN
* \author Nevrax France
* \date 2001
*/
class CProperties
{
public:
typedef struct
{
union
{
uint16 properties;
struct
{
uint16 isSelectable : 1; // The entity is selectable.
uint16 isGivable : 1; // It'possible to give something to the entity.
uint16 isTalkableTo : 1; // It's possible to talk to the entity.
uint16 isUsable : 1; // The entity can be used.
uint16 isLiftable : 1; // The entity is liftable.
uint16 isLookableAt : 1; // It's possible to look at the entity.
uint16 isAttackable : 1; // It's possible to attack the entity.
uint16 isCurativable : 1; // It's possible to heal or cure the entity
uint16 isInvitable : 1; // It'possible to invite the entity in a team.
uint16 isHarvestable : 1; // It'possible to loot the entity.
uint16 canExchangeItem : 1; // It is possible to exchange items with the entity
uint16 isMountable : 1; // It is possible to mount the creature
uint16 isLootable : 1; // It'possible to loot the entity.
uint16 isAfk : 1; // entity is away from keyboard
uint16 isInvulnerable : 1; // entity is invulnerable (traders, rolemasters...)
uint16 freeProperty : 1; // free 1 bits
} prop;
};
} TProperties;
protected:
/// Entity properties.
TProperties _Properties;
public:
/// Constructor
CProperties() {_Properties.properties = 0;}
CProperties(uint16 p) {_Properties.properties = p;}
CProperties(TProperties p) {_Properties = p;}
// Operator (uint16)
operator uint16() const { return _Properties.properties; }
// Operator ()
const TProperties& operator () () const { return _Properties; }
// Operator ==
bool operator == ( const CProperties& p ) const { return p().properties == _Properties.properties; }
// Operator !=
bool operator != ( const CProperties& p ) const { return p().properties != _Properties.properties; }
// Operator !=
bool operator [] ( uint32 nBitNbWanted ) const
{
switch( nBitNbWanted )
{
case 0:
return selectable();
case 1:
return givable();
case 2:
return talkableTo();
case 3:
return usable();
case 4:
return liftable();
case 5:
return lookableAt();
case 6:
return attackable();
case 7:
return curativable();
case 8:
return invitable();
case 9:
return harvestable();
case 10:
return canExchangeItem();
case 11:
return mountable();
case 12:
return lootable();
case 13:
return afk();
case 14:
return invulnerable();
default:
return false;
}
//return _Properties.properties & (1<