⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shapebase.h

📁 五行MMORPG引擎系统V1.0
💻 H
📖 第 1 页 / 共 5 页
字号:
   Point3F        shellExitDir;        ///< Vector along which to eject shells from the image.
   F32            shellExitVariance;   ///< Variance from this vector in degrees.
   F32            shellVelocity;       ///< Velocity with which to eject shell casings.
   /// @}

   /// @name State Array
   ///
   /// State array is initialized onAdd from the individual state
   /// struct array elements.
   ///
   /// @{
   StateData state[MaxStates];   ///< Array of states.
   bool      statesLoaded;       ///< Are the states loaded yet?
   /// @}

   /// @name Infrastructure
   ///
   /// Miscellaneous inherited methods.
   /// @{

   DECLARE_CONOBJECT(ShapeBaseImageData);
   ShapeBaseImageData();
   ~ShapeBaseImageData();
   bool onAdd();
   bool preload(bool server, char errorBuffer[256]);
   S32 lookupState(const char* name);  ///< Get a state by name.
   static void initPersistFields();
   virtual void packData(BitStream* stream);
   virtual void unpackData(BitStream* stream);
   /// @}
};


//--------------------------------------------------------------------------
/// @nosubgrouping
struct ShapeBaseData : public GameBaseData {
  private:
   typedef GameBaseData Parent;

public:
   /// Various constants relating to the ShapeBaseData
   enum Constants {
      NumMountPoints = 32,
      NumMountPointBits = 5,
      MaxCollisionShapes = 8,
      AIRepairNode = 31
   };

   StringTableEntry  shapeName;
   StringTableEntry  cloakTexName;

   /// @name Destruction
   ///
   /// Everyone likes to blow things up!
   /// @{
   DebrisData *      debris;
   S32               debrisID;
   StringTableEntry  debrisShapeName;
   Resource<TSShape> debrisShape;

   ExplosionData*    explosion;
   S32               explosionID;

   ExplosionData*    underwaterExplosion;
   S32               underwaterExplosionID;
   /// @}

   /// @name Physical Properties
   /// @{
   F32 mass;
   F32 drag;
   F32 density;
   F32 maxEnergy;
   F32 maxDamage;
   F32 repairRate;                  ///< Rate per tick.

   F32 disabledLevel;
   F32 destroyedLevel;

   S32 shieldEffectLifetimeMS;
   /// @}

   /// @name 3rd Person Camera
   /// @{
#ifdef TGE_RPG /// TGE_Move
   F32 cameraDefaultDist;            ///< 相机与宿主默认距离
#endif
   F32 cameraMaxDist;               ///< Maximum distance from eye
   F32 cameraMinDist;               ///< Minumumistance from eye
   /// @}

   /// @name Camera FOV
   ///
   /// These are specified in degrees.
   /// @{
#ifdef TGE_RPG /// TGE_Move
   F32 cameraDefaultPitch;           ///< 相机与宿主仰角
   F32 cameraDefaultYaw;            ///< 相机与宿主偏向角
#endif

   F32 cameraDefaultFov;            ///< Default FOV.
   F32 cameraMinFov;                ///< Min FOV allowed.
   F32 cameraMaxFov;                ///< Max FOV allowed.
   /// @}

   /// @name Data initialized on preload
   /// @{

   Resource<TSShape> shape;         ///< Shape handle
   U32 mCRC;
   bool computeCRC;

   S32 eyeNode;                         ///< Shape's eye node index
   S32 cameraNode;                      ///< Shape's camera node index
   S32 shadowNode;                      ///< Move shadow center as this node moves
   S32 mountPointNode[NumMountPoints];  ///< Node index of mountPoint
   S32 debrisDetail;                    ///< Detail level used to generate debris
   S32 damageSequence;                  ///< Damage level decals
   S32 hulkSequence;                    ///< Destroyed hulk

   bool              canControl;             // can this object be controlled?
   bool              canObserve;             // may look at object in commander map?
   bool              observeThroughObject;   // observe this object through its camera transform and default fov

   /// @name HUD
   ///
   /// @note This may be only semi-functional.
   /// @{

   enum {
      NumHudRenderImages      = 8,
   };

   StringTableEntry  hudImageNameFriendly[NumHudRenderImages];
   StringTableEntry  hudImageNameEnemy[NumHudRenderImages];
   TextureHandle     hudImageFriendly[NumHudRenderImages];
   TextureHandle     hudImageEnemy[NumHudRenderImages];

   bool              hudRenderCenter[NumHudRenderImages];
   bool              hudRenderModulated[NumHudRenderImages];
   bool              hudRenderAlways[NumHudRenderImages];
   bool              hudRenderDistance[NumHudRenderImages];
   bool              hudRenderName[NumHudRenderImages];
   /// @}

   /// @name Collision Data
   /// @{
   Vector<S32>   collisionDetails;  ///< Detail level used to collide with.
                                    ///
                                    /// These are detail IDs, see TSShape::findDetail()
   Vector<Box3F> collisionBounds;   ///< Detail level bounding boxes.

   Vector<S32>   LOSDetails;        ///< Detail level used to perform line-of-sight queries against.
                                    ///
                                    /// These are detail IDs, see TSShape::findDetail()
   /// @}

   /// @name Shadow Settings
   ///
   /// These are set by derived classes, not by script file.
   /// They control when shadows are rendered (and when generic shadows are substituted)
   ///
   /// @{

   F32 genericShadowLevel;
   F32 noShadowLevel;
   /// @}

   /// @name Misc. Settings
   /// @{
   bool emap;                       ///< Enable environment mapping?
   bool firstPersonOnly;            ///< Do we allow only first person view of this image?
   bool useEyePoint;                ///< Do we use this object's eye point to view from?
   bool aiAvoidThis;                ///< If set, the AI's will try to walk around this object...
                                    ///
                                    ///  @note There isn't really any AI code that can take advantage of this.
   bool isInvincible;               ///< If set, object cannot take damage (won't show up with damage bar either)
   bool renderWhenDestroyed;        ///< If set, will not render this object when destroyed.

   bool inheritEnergyFromMount;

   /// @}

   bool preload(bool server, char errorBuffer[256]);
   void computeAccelerator(U32 i);
   S32  findMountPoint(U32 n);

   /// @name Infrastructure
   /// The derived class should provide the following:
   /// @{
   DECLARE_CONOBJECT(ShapeBaseData);
   ShapeBaseData();
   ~ShapeBaseData();
   static void initPersistFields();
   virtual void packData(BitStream* stream);
   virtual void unpackData(BitStream* stream);
   /// @}
};


//----------------------------------------------------------------------------

/// ShapeBase is the renderable shape from which most of the scriptable objects
/// are derived, including the player, vehicle and items classes.  ShapeBase
/// provides basic shape loading, audio channels, and animation as well as damage
/// (and damage states), energy, and the ability to mount images and objects.
///
/// @nosubgrouping
class ShapeBase : public GameBase
{
   typedef GameBase Parent;
   friend class ShapeBaseConvex;
   friend class ShapeBaseImageData;
   friend void physicalZoneFind(SceneObject*, void *);

public:
   enum PublicConstants {
      ThreadSequenceBits = 6,
      MaxSequenceIndex = (1 << ThreadSequenceBits) - 1,
      EnergyLevelBits = 5,
      DamageLevelBits = 6,
      DamageStateBits = 2,
      // The thread and image limits should not be changed without
      // also changing the ShapeBaseMasks enum values declared
      // further down.
      MaxSoundThreads =  4,            ///< Should be a power of 2
      MaxScriptThreads = 4,            ///< Should be a power of 2
#ifdef TGE_RPG
		MaxMountedImages = RPG::EQUIP_SLOTNUM,            ///< Should be a power of 2
#else
      MaxMountedImages = 4,            ///< Should be a power of 2
#endif
      MaxImageEmitters = 3,
      NumImageBits = 3,
      ShieldNormalBits = 8,
      CollisionTimeoutValue = 250,      ///< Timeout in ms.
      //MaxSkinModifiers = 8,	//Skin modifier
   };

   /// This enum indexes into the sDamageStateName array
   enum DamageState {
      Enabled,
      Disabled,
      Destroyed,
      NumDamageStates,
      NumDamageStateBits = 2,   ///< Should be log2 of the number of states.
   };

private:
   ShapeBaseData*    mDataBlock;                ///< Datablock
   //GameConnection*   mControllingClient;        ///< Controlling client
   ShapeBase*        mControllingObject;        ///< Controlling object
   bool              mTrigger[MaxTriggerKeys];  ///< What triggers are set, if any.

   /// @name Scripted Sound
   /// @{
   struct Sound {
      bool play;                    ///< Are we playing this sound?
      SimTime timeout;              ///< Time until we stop playing this sound.
      AudioProfile* profile;        ///< Profile on server
      AUDIOHANDLE sound;            ///< Handle on client
   };
   Sound mSoundThread[MaxSoundThreads];
   /// @}

   /// @name Scripted Animation Threads
   /// @{

   struct Thread {
      /// State of the animation thread.
      enum State {
         Play, Stop, Pause
      };
      TSThread* thread; ///< Pointer to 3space data.
      U32 state;        ///< State of the thread
                        ///
                        ///  @see Thread::State
      S32 sequence;     ///< The animation sequence which is running in this thread.
      U32 sound;        ///< Handle to sound.
      bool atEnd;       ///< Are we at the end of this thread?
      bool forward;     ///< Are we playing the thread forward? (else backwards)
   };
   Thread mScriptThread[MaxScriptThreads];

   /// @}

   /// @name Invincibility
   /// @{
   F32 mInvincibleCount;
   F32 mInvincibleTime;
   F32 mInvincibleSpeed;
   F32 mInvincibleDelta;
   F32 mInvincibleEffect;
   F32 mInvincibleFade;
   bool mInvincibleOn;
   /// @}

public:

	//Skin modifier
	///@name Skin modifier
	///@{
   // Skin Modifiers
   //struct SkinModifier
   //{
   //   StringHandle skinName;
   //   StringHandle maskName;
   //   StringHandle printName;
   //};
   //SkinModifier mSkinModifiers[MaxSkinModifiers];
   //U8 mSkinModMaskBits;
	TSSkinMan	m_skinMan;
   ///@}

protected:


   /// @name Mounted Images
   /// @{

   /// An image mounted on a shapebase.
   struct MountedImage {
      ShapeBaseImageData* dataBlock;
      ShapeBaseImageData::StateData *state;
      ShapeBaseImageData* nextImage;
      StringHandle skinNameHandle;
      StringHandle nextSkinNameHandle;

      /// @name State
      ///
      /// Variables tracking the state machine
      /// representing this specific mounted image.
      /// @{

      bool loaded;                  ///< Is the image loaded?
      bool nextLoaded;              ///< Is the next state going to result in the image being loaded?
      F32 delayTime;                ///< Time till next state.
      U32 fireCount;                ///< Fire skip count.
                                    ///
                                    /// This is incremented every time the triggerDown bit is changed,
                                    /// so that the engine won't be too confused if the player toggles the
                                    /// trigger a bunch of times in a short period.
                                    ///
                                    /// @note The network deals with this variable at 3-bit precision, so it
                                    /// can only range 0-7.
                                    ///
                                    /// @see ShapeBase::setImageState()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -