瀏覽代碼

projectile

marauder2k7 2 月之前
父節點
當前提交
1949ff9d7b
共有 2 個文件被更改,包括 19 次插入21 次删除
  1. 15 17
      Engine/source/T3D/projectile.cpp
  2. 4 4
      Engine/source/T3D/projectile.h

+ 15 - 17
Engine/source/T3D/projectile.cpp

@@ -145,7 +145,7 @@ U32 Projectile::smProjectileWarpTicks = 5;
 //
 ProjectileData::ProjectileData()
 {
-   INIT_ASSET(ProjectileShape);
+   mProjectileShapeAsset.registerRefreshNotify(this);
 
    INIT_ASSET(ProjectileSound);
 
@@ -223,7 +223,7 @@ ProjectileData::ProjectileData(const ProjectileData& other, bool temp_clone) : G
    CLONE_ASSET(ProjectileSound);
    lightDesc = other.lightDesc;
    lightDescId = other.lightDescId; // -- for pack/unpack of lightDesc ptr
-   CLONE_ASSET(ProjectileShape);// -- TSShape loads using mProjectileShapeName
+   mProjectileShapeAsset = other.mProjectileShapeAsset;// -- TSShape loads using mProjectileShapeName
    activateSeq = other.activateSeq; // -- from projectileShape sequence "activate"
    maintainSeq = other.maintainSeq; // -- from projectileShape sequence "maintain"
    particleEmitter = other.particleEmitter;
@@ -237,9 +237,7 @@ void ProjectileData::initPersistFields()
 {
    docsURL;
    addGroup("Shapes");
-      addProtectedField("projectileShapeName", TypeShapeFilename, Offset(mProjectileShapeName, ProjectileData), &_setProjectileShapeData, &defaultProtectedGetFn,
-         "@brief File path to the model of the projectile.\n\n", AbstractClassRep::FIELD_HideInInspectors);
-      INITPERSISTFIELD_SHAPEASSET(ProjectileShape, ProjectileData, "@brief The model of the projectile.\n\n");
+      INITPERSISTFIELD_SHAPEASSET_REFACTOR(ProjectileShape, ProjectileData, "@brief The model of the projectile.\n\n");
       addField("scale", TypePoint3F, Offset(scale, ProjectileData),
          "@brief Scale to apply to the projectile's size.\n\n"
          "@note This is applied after SceneObject::scale\n");
@@ -383,20 +381,20 @@ bool ProjectileData::preload(bool server, String &errorStr)
             Con::errorf(ConsoleLogEntry::General, "ProjectileData::preload: Invalid packet, bad datablockid(lightDesc): %d", lightDescId);   
    }
 
-   if (mProjectileShapeAssetId != StringTable->EmptyString())
+   if (mProjectileShapeAsset.notNull())
    {
       //If we've got a shapeAsset assigned for our projectile, but we failed to load the shape data itself, report the error
-      if (!mProjectileShape)
+      if (!getProjectileShape())
       {
-         errorStr = String::ToString("ProjectileData::load: Couldn't load shape \"%s\"", mProjectileShapeAssetId);
+         errorStr = String::ToString("ProjectileData::load: Couldn't load shape \"%s\"", _getProjectileShapeAssetId());
          return false;
       }
       else
       {
-         activateSeq = mProjectileShape->findSequence("activate");
-         maintainSeq = mProjectileShape->findSequence("maintain");
+         activateSeq = getProjectileShape()->findSequence("activate");
+         maintainSeq = getProjectileShape()->findSequence("maintain");
 
-         TSShapeInstance* pDummy = new TSShapeInstance(mProjectileShape, !server);
+         TSShapeInstance* pDummy = new TSShapeInstance(getProjectileShape(), !server);
          delete pDummy;
       }
    }
@@ -409,7 +407,7 @@ void ProjectileData::packData(BitStream* stream)
 {
    Parent::packData(stream);
 
-   PACKDATA_ASSET(ProjectileShape);
+   PACKDATA_ASSET_REFACTOR(ProjectileShape);
 
    stream->writeFlag(faceViewer);
    if(stream->writeFlag(scale.x != 1 || scale.y != 1 || scale.z != 1))
@@ -474,7 +472,7 @@ void ProjectileData::unpackData(BitStream* stream)
 {
    Parent::unpackData(stream);
 
-   UNPACKDATA_ASSET(ProjectileShape);
+   UNPACKDATA_ASSET_REFACTOR(ProjectileShape);
 
    faceViewer = stream->readFlag();
    if(stream->readFlag())
@@ -800,9 +798,9 @@ bool Projectile::onAdd()
    }
    else
    {
-      if (bool(mDataBlock->mProjectileShape))
+      if (bool(mDataBlock->getProjectileShape()))
       {
-         mProjectileShape = new TSShapeInstance(mDataBlock->mProjectileShape, isClientObject());
+         mProjectileShape = new TSShapeInstance(mDataBlock->getProjectileShape(), isClientObject());
 
          if (mDataBlock->activateSeq != -1)
          {
@@ -841,8 +839,8 @@ bool Projectile::onAdd()
       processAfter(mSourceObject);
 
    // Setup our bounding box
-   if (bool(mDataBlock->mProjectileShape) == true)
-      mObjBox = mDataBlock->mProjectileShape->mBounds;
+   if (bool(mDataBlock->getProjectileShape()) == true)
+      mObjBox = mDataBlock->getProjectileShape()->mBounds;
    else
       mObjBox = Box3F(Point3F(0, 0, 0), Point3F(0, 0, 0));
 

+ 4 - 4
Engine/source/T3D/projectile.h

@@ -63,7 +63,7 @@ class Projectile;
 
 //--------------------------------------------------------------------------
 /// Datablock for projectiles.  This class is the base class for all other projectiles.
-class ProjectileData : public GameBaseData
+class ProjectileData : public GameBaseData, protected AssetPtrCallback
 {
    typedef GameBaseData Parent;
 
@@ -71,8 +71,7 @@ protected:
    bool onAdd() override;
 
 public:
-   DECLARE_SHAPEASSET(ProjectileData, ProjectileShape, onShapeChanged);
-   DECLARE_ASSET_SETGET(ProjectileData, ProjectileShape);
+   DECLARE_SHAPEASSET_REFACTOR(ProjectileData, ProjectileShape)
 
    /// Set to true if it is a billboard and want it to always face the viewer, false otherwise
    bool faceViewer;
@@ -154,7 +153,8 @@ public:
    ProjectileData(const ProjectileData&, bool = false);
    bool allowSubstitutions() const override { return true; }
 
-   void onShapeChanged()
+protected:
+   void onAssetRefreshed(AssetPtrBase* pAssetPtrBase) override
    {
       reloadOnLocalClient();
    }