예제 #1
0
 public virtual ProtoBuf.Item Save(bool bIncludeContainer = false, bool bIncludeOwners = true)
 {
     this.dirty = false;
     ProtoBuf.Item item = Facepunch.Pool.Get <ProtoBuf.Item>();
     item.UID          = this.uid;
     item.itemid       = this.info.itemid;
     item.slot         = this.position;
     item.amount       = this.amount;
     item.flags        = (int)this.flags;
     item.removetime   = this.removeTime;
     item.locktime     = this.busyTime;
     item.instanceData = this.instanceData;
     item.worldEntity  = this.worldEnt.uid;
     item.heldEntity   = this.heldEntity.uid;
     item.skinid       = this.skin;
     item.name         = this.name;
     item.text         = this.text;
     if (this.hasCondition)
     {
         item.conditionData = Facepunch.Pool.Get <ProtoBuf.Item.ConditionData>();
         item.conditionData.maxCondition = this._maxCondition;
         item.conditionData.condition    = this._condition;
     }
     if (this.contents != null & bIncludeContainer)
     {
         item.contents = this.contents.Save();
     }
     return(item);
 }
예제 #2
0
 public static Item Load(ProtoBuf.Item load, Item created, bool isServer)
 {
     if (created == null)
     {
         created = new Item();
     }
     created.isServer = isServer;
     created.Load(load);
     if (created.info != null)
     {
         return(created);
     }
     UnityEngine.Debug.LogWarning("Item loading failed - item is invalid");
     return(null);
 }
예제 #3
0
 public virtual void Load(ProtoBuf.Item load)
 {
     if (this.info == null || this.info.itemid != load.itemid)
     {
         this.info = ItemManager.FindItemDefinition(load.itemid);
     }
     this.uid            = load.UID;
     this.name           = load.name;
     this.text           = load.text;
     this.amount         = load.amount;
     this.position       = load.slot;
     this.busyTime       = load.locktime;
     this.removeTime     = load.removetime;
     this.flags          = (Item.Flag)load.flags;
     this.worldEnt.uid   = load.worldEntity;
     this.heldEntity.uid = load.heldEntity;
     if (this.instanceData != null)
     {
         this.instanceData.ShouldPool = true;
         this.instanceData.ResetToPool();
         this.instanceData = null;
     }
     this.instanceData = load.instanceData;
     if (this.instanceData != null)
     {
         this.instanceData.ShouldPool = false;
     }
     this.skin = load.skinid;
     if (this.info == null || this.info.itemid != load.itemid)
     {
         this.info = ItemManager.FindItemDefinition(load.itemid);
     }
     if (this.info == null)
     {
         return;
     }
     this._condition    = 0f;
     this._maxCondition = 0f;
     if (load.conditionData != null)
     {
         this._condition    = load.conditionData.condition;
         this._maxCondition = load.conditionData.maxCondition;
     }
     else if (this.info.condition.enabled)
     {
         this._condition    = this.info.condition.max;
         this._maxCondition = this.info.condition.max;
     }
     if (load.contents != null)
     {
         if (this.contents == null)
         {
             this.contents = new ItemContainer();
             if (this.isServer)
             {
                 this.contents.ServerInitialize(this, load.contents.slots);
             }
         }
         this.contents.Load(load.contents);
     }
     if (this.isServer)
     {
         this.removeTime = 0f;
         this.OnItemCreated();
     }
 }