浏览代码

Merge branch 'item-networking' of https://github.com/eightyeight/Torque3D into eightyeight-item-networking

David Wyand 13 年之前
父节点
当前提交
d38eb17056
共有 2 个文件被更改,包括 20 次插入2 次删除
  1. 17 2
      Engine/source/T3D/item.cpp
  2. 3 0
      Engine/source/T3D/item.h

+ 17 - 2
Engine/source/T3D/item.cpp

@@ -1276,11 +1276,26 @@ DefineEngineMethod( Item, getLastStickyNormal, const char *, (),,
 
 //----------------------------------------------------------------------------
 
+bool Item::_setStatic(void *object, const char *index, const char *data)
+{
+   Item *i = static_cast<Item*>(object);
+   i->mAtRest = dAtob(data);
+   i->setMaskBits(InitialUpdateMask | PositionMask);
+   return true;
+}
+
+bool Item::_setRotate(void *object, const char *index, const char *data)
+{
+   Item *i = static_cast<Item*>(object);
+   i->setMaskBits(InitialUpdateMask | RotationMask);
+   return true;
+}
+
 void Item::initPersistFields()
 {
    addGroup("Misc");	
-   addField("static",      TypeBool, Offset(mStatic, Item), "If true, the object is not moving in the world (and will not be updated through the network).\n");
-   addField("rotate",      TypeBool, Offset(mRotate, Item), "If true, the object will automatically rotate around its Z axis.\n");
+   addProtectedField("static", TypeBool, Offset(mStatic, Item), &_setStatic, &defaultProtectedGetFn, "If true, the object is not moving in the world.\n");
+   addProtectedField("rotate", TypeBool, Offset(mRotate, Item), &_setRotate, &defaultProtectedGetFn, "If true, the object will automatically rotate around its Z axis.\n");
    endGroup("Misc");
 
    Parent::initPersistFields();

+ 3 - 0
Engine/source/T3D/item.h

@@ -150,6 +150,9 @@ class Item: public ShapeBase
    void buildConvex(const Box3F& box, Convex* convex);
    void onDeleteNotify(SimObject*);
 
+   static bool _setStatic(void *object, const char *index, const char *data);
+   static bool _setRotate(void *object, const char *index, const char *data);
+
   protected:
    void _updatePhysics();
    void prepRenderImage(SceneRenderState *state);