📄 shapebase.h
字号:
bool triggerDown; ///< Is the trigger down?
bool ammo; ///< Do we have ammo?
///
/// May be true based on either energy OR ammo.
bool target; ///< Have we acquired a targer?
bool wet; ///< Is the weapon wet?
/// @}
/// @name 3space
///
/// Handles to threads and shapeinstances in the 3space system.
/// @{
///
TSShapeInstance* shapeInstance;
TSThread *ambientThread;
TSThread *visThread;
TSThread *animThread;
TSThread *flashThread;
TSThread *spinThread;
/// @}
/// @name Effects
///
/// Variables relating to lights, sounds, and particles.
/// @{
SimTime lightStart; ///< Starting time for light flashes.
LightInfo mLight; ///< Passed to the LightManager; filled out with the above information.
///
/// registerLights() is responsible for performing
/// the calculations that prepare mLight.
bool animLoopingSound; ///< Are we playing a looping sound?
AUDIOHANDLE animSound; ///< Handle to the current image sound.
/// Represent the state of a specific particle emitter on the image.
struct ImageEmitter {
S32 node;
F32 time;
SimObjectPtr<ParticleEmitter> emitter;
};
ImageEmitter emitter[MaxImageEmitters];
/// @}
void registerImageLights(LightManager * lightManager, bool lightingScene, const Point3F &objectPosition, U32 startTime);
//
MountedImage();
~MountedImage();
};
MountedImage mMountedImageList[MaxMountedImages];
/// @}
/// @name Render settings
/// @{
TSShapeInstance* mShapeInstance;
Convex * mConvexList;
Shadow * mShadow;
bool mGenerateShadow;
StringHandle mSkinNameHandle;
StringHandle mShapeNameHandle; ///< Name sent to client
/// @}
/// @name Physical Properties
/// @{
F32 mEnergy; ///< Current enery level.
F32 mRechargeRate; ///< Energy recharge rate (in units/tick).
bool mChargeEnergy; ///< Are we currently charging?
/// @note Currently unused.
F32 mMass; ///< Mass.
F32 mOneOverMass; ///< Inverse of mass.
/// @note This is used to optimize certain physics calculations.
/// @}
/// @name Physical Properties
///
/// Properties for the current object, which are calculated
/// based on the container we are in.
///
/// @see ShapeBase::updateContainer()
/// @see ShapeBase::mContainer
/// @{
F32 mDrag; ///< Drag.
F32 mBuoyancy; ///< Buoyancy factor.
U32 mLiquidType; ///< Type of liquid (if any) we are in.
F32 mLiquidHeight; ///< Height of liquid around us (from 0..1).
F32 mWaterCoverage; ///< Percent of this object covered by water
Point3F mAppliedForce;
F32 mGravityMod;
/// @}
F32 mDamageFlash;
F32 mWhiteOut;
bool mFlipFadeVal;
U32 mLightTime;
/// Last shield direction (cur. unused)
Point3F mShieldNormal;
/// Mounted objects
struct MountInfo {
ShapeBase* list; ///< Objects mounted on this object
ShapeBase* object; ///< Object this object is mounted on.
ShapeBase* link; ///< Link to next object mounted to this object's mount
U32 node; ///< Node point we are mounted to.
} mMount;
public:
/// @name Collision Notification
/// This is used to keep us from spamming collision notifications. When
/// a collision occurs, we add to this list; then we don't notify anyone
/// of the collision until the CollisionTimeout expires (which by default
/// occurs in 1/10 of a second).
///
/// @see notifyCollision(), queueCollision()
/// @{
struct CollisionTimeout {
CollisionTimeout* next;
ShapeBase* object;
U32 objectNumber;
SimTime expireTime;
VectorF vector;
};
CollisionTimeout* mTimeoutList;
static CollisionTimeout* sFreeTimeoutList;
/// Go through all the items in the collision queue and call onCollision on them all
/// @see onCollision
void notifyCollision();
/// This gets called when an object collides with this object
/// @param object Object colliding with this object
/// @param vec Vector along which collision occured
virtual void onCollision(ShapeBase* object, VectorF vec);
/// Add a collision to the queue of collisions waiting to be handled @see onCollision
/// @param object Object collision occurs with
/// @param vec Vector along which collision occurs
void queueCollision(ShapeBase* object, const VectorF& vec);
/// @}
protected:
/// @name Damage
/// @{
F32 mDamage;
F32 mRepairRate;
F32 mRepairReserve;
bool mRepairDamage;
DamageState mDamageState;
TSThread *mDamageThread;
TSThread *mHulkThread;
VectorF damageDir;
bool blowApart;
/// @}
/// @name Cloaking
/// @{
bool mCloaked;
F32 mCloakLevel;
TextureHandle mCloakTexture;
bool mHidden; ///< in/out of world
/// @}
/// @name Fading
/// @{
bool mFadeOut;
bool mFading;
F32 mFadeVal;
F32 mFadeElapsedTime;
F32 mFadeTime;
F32 mFadeDelay;
/// @}
/// @name Control info
/// @{
F32 mCameraFov; ///< Camera FOV(in degrees)
bool mIsControlled; ///< Client side controlled flag
#ifdef TGE_RPG /// TGE_Move
F32 m_fCameraDist; /// 相机与我的距离
Point3F m_rotCamera; /// 相机的转向,只用x(pitch)、z(yaw)
//U32 m_cameraTimer; /// 相机计时器,当视线阻挡时,需要
#endif
/// @}
static U32 sLastRenderFrame;
U32 mLastRenderFrame;
F32 mLastRenderDistance;
U32 mSkinHash;
/// This recalculates the total mass of the object, and all mounted objects
void updateMass();
/// @name Image Manipulation
/// @{
/// Utility function to call script functions which have to do with ShapeBase
/// objects.
/// @param imageSlot Image Slot id
/// @param function Function
void scriptCallback(U32 imageSlot,const char* function);
/// Assign a ShapeBaseImage to an image slot
/// @param imageSlot Image Slot ID
/// @param imageData ShapeBaseImageData to assign
/// @param skinNameHandle Skin texture name
/// @param loaded Is the image loaded?
/// @param ammo Does the image have ammo?
/// @param triggerDown Is the trigger on this image down?
/// @param target Does the image have a target?
virtual void setImage(U32 imageSlot, ShapeBaseImageData* imageData, StringHandle &skinNameHandle,
bool loaded = true, bool ammo = false, bool triggerDown = false,
bool target = false);
/// Clear out an image slot
/// @param imageSlot Image slot id
void resetImageSlot(U32 imageSlot);
/// Get the firing action state of the image
/// @param imageSlot Image slot id
U32 getImageFireState(U32 imageSlot);
/// Sets the state of the image
/// @param imageSlot Image slot id
/// @param state State id
/// @param force Force image to state or let it finish then change
void setImageState(U32 imageSlot, U32 state, bool force = false);
/// Advance animation on a image
/// @param imageSlot Image slot id
/// @param dt Change in time since last animation update
void updateImageAnimation(U32 imageSlot, F32 dt);
/// Advance state of image
/// @param imageSlot Image slot id
/// @param dt Change in time since last state update
void updateImageState(U32 imageSlot,F32 dt);
/// Start up the particle emitter for the this shapebase
/// @param image Mounted image
/// @param state State of shape base image
void startImageEmitter(MountedImage &image,ShapeBaseImageData::StateData &state);
/// Get light information for a mounted image
/// @param imageSlot Image slot id
Light* getImageLight(U32 imageSlot);
/// @}
/// Prune out non looping sounds from the sound manager which have expired
void updateServerAudio();
/// Updates the audio state of the supplied sound
/// @param st Sound
void updateAudioState(Sound& st);
/// Recalculates the spacial sound based on the current position of the object
/// emitting the sound.
void updateAudioPos();
/// Update bouyency and drag properties
void updateContainer();
/// @name Events
/// @{
virtual void onDeleteNotify(SimObject*);
virtual void onImageRecoil(U32 imageSlot,ShapeBaseImageData::StateData::RecoilState);
virtual void ejectShellCasing( U32 imageSlot );
virtual void updateDamageLevel();
virtual void updateDamageState();
virtual void blowUp();
virtual void onMount(ShapeBase* obj,S32 node);
virtual void onUnmount(ShapeBase* obj,S32 node);
virtual void onImpact(SceneObject* obj, VectorF vec);
virtual void onImpact(VectorF vec);
/// @}
public:
ShapeBase();
~ShapeBase();
TSShapeInstance* getShapeInstance() { return mShapeInstance; }
/// @name Network state masks
/// @{
///
enum ShapeBaseMasks {
NameMask = Parent::NextFreeMask,
DamageMask = Parent::NextFreeMask << 1,
NoWarpMask = Parent::NextFreeMask << 2,
MountedMask = Parent::NextFreeMask << 3,
CloakMask = Parent::NextFreeMask << 4,
ShieldMask = Parent::NextFreeMask << 5,
InvincibleMask = Parent::NextFreeMask << 6,
SkinMask = Parent::NextFreeMask << 7,
SkinModMask = Parent::NextFreeMask << 8,//Skin modifier
SoundMaskN = Parent::NextFreeMask << 9, ///< Extends + MaxSoundThreads bits
ThreadMaskN = SoundMaskN << MaxSoundThreads, ///< Extends + MaxScriptThreads bits
ImageMaskN = ThreadMaskN << MaxScriptThreads, ///< Extends + MaxMountedImage bits
NextFreeMask = ImageMaskN << MaxMountedImages
};
enum BaseMaskConstants {
SoundMask = (SoundMaskN << MaxSoundThreads) - SoundMaskN,
ThreadMask = (ThreadMaskN << MaxScriptThreads) - ThreadMaskN,
ImageMask = (ImageMaskN << MaxMountedImages) - ImageMaskN
};
/// @}
static bool gRenderEnvMaps; ///< Global flag which turns on or off all environment maps
static F32 sWhiteoutDec;
static F32 sDamageFlashDec;
/// @name Initialization
/// @{
bool onAdd();
void onRemove();
void onSceneRemove();
static void consoleInit();
bool onNewDataBlock(GameBaseData* dptr);
/// @}
/// @name Name & Skin tags
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -