Beispiel #1
0
 public void TakeItemMP(BoltEntity targetPlayer)
 {
     if (this.Items > 0)
     {
         base.entity.Freeze(false);
         base.state.ItemCount = (this.Items = Mathf.Max(0, this.Items - 1));
     }
     else
     {
         ItemRemoveFromPlayer itemRemoveFromPlayer;
         if (targetPlayer.isOwner)
         {
             itemRemoveFromPlayer = ItemRemoveFromPlayer.Create(GlobalTargets.OnlySelf);
         }
         else
         {
             itemRemoveFromPlayer = ItemRemoveFromPlayer.Create(targetPlayer.source);
         }
         itemRemoveFromPlayer.ItemId = this._itemid;
         itemRemoveFromPlayer.Send();
     }
 }
Beispiel #2
0
 public void TakeItemMP(BoltEntity targetPlayer, int itemId)
 {
     if (this._nextItemIndex > 0)
     {
         base.entity.Freeze(false);
         base.state.Items[--this._nextItemIndex] = (this._items[this._nextItemIndex] = -1);
     }
     else
     {
         ItemRemoveFromPlayer itemRemoveFromPlayer;
         if (targetPlayer.isOwner)
         {
             itemRemoveFromPlayer = ItemRemoveFromPlayer.Create(GlobalTargets.OnlySelf);
         }
         else
         {
             itemRemoveFromPlayer = ItemRemoveFromPlayer.Create(targetPlayer.source);
         }
         itemRemoveFromPlayer.ItemId = itemId;
         itemRemoveFromPlayer.Send();
     }
 }
Beispiel #3
0
 public void TakeItemMP(BoltConnection source, int contentType, int contentValue)
 {
     if (this._storedItemIds[contentType] == contentValue)
     {
         base.entity.Freeze(false);
         base.state.ItemCount[contentType] = 0;
     }
     else
     {
         ItemRemoveFromPlayer itemRemoveFromPlayer;
         if (source == null)
         {
             itemRemoveFromPlayer = ItemRemoveFromPlayer.Create(GlobalTargets.OnlySelf);
         }
         else
         {
             itemRemoveFromPlayer = ItemRemoveFromPlayer.Create(source);
         }
         itemRemoveFromPlayer.ItemId = contentValue;
         itemRemoveFromPlayer.Send();
     }
 }
Beispiel #4
0
 public void TakeItemMP(BoltEntity targetPlayer, int contentType)
 {
     if (this._itemsAmount[contentType] > 0)
     {
         base.entity.Freeze(false);
         base.state.ItemCount[contentType] = (this._itemsAmount[contentType] = Mathf.Max(0, this._itemsAmount[contentType] - 1));
     }
     else
     {
         ItemRemoveFromPlayer itemRemoveFromPlayer;
         if (targetPlayer.isOwner)
         {
             itemRemoveFromPlayer = ItemRemoveFromPlayer.Create(GlobalTargets.OnlySelf);
         }
         else
         {
             itemRemoveFromPlayer = ItemRemoveFromPlayer.Create(targetPlayer.source);
         }
         itemRemoveFromPlayer.ItemId = this._acceptedItems[contentType]._itemId;
         itemRemoveFromPlayer.Send();
     }
 }
Beispiel #5
0
 public override void OnEvent(DestroyPickUp evnt)
 {
     if (evnt.PickUpEntity)
     {
         if (evnt.PickUpEntity.isAttached)
         {
             if (evnt.PickUpEntity.isOwner)
             {
                 if (evnt.PickUpEntity.StateIs <ISuitcaseState>())
                 {
                     if (evnt.SibblingId >= 0)
                     {
                         ISuitcaseState state = evnt.PickUpEntity.GetState <ISuitcaseState>();
                         state.FlaresPickedUp |= 1 << evnt.SibblingId;
                     }
                     else
                     {
                         evnt.PickUpEntity.GetState <ISuitcaseState>().ClothPickedUp = true;
                     }
                 }
                 else
                 {
                     if (evnt.FakeDrop)
                     {
                         if (evnt.PickUpPlayer == LocalPlayer.Entity)
                         {
                             LocalPlayer.Inventory.FakeDrop(evnt.ItemId);
                         }
                         else
                         {
                             PlayerAddItem playerAddItem = PlayerAddItem.Create(evnt.PickUpPlayer.source);
                             playerAddItem.ItemId = evnt.ItemId;
                             playerAddItem.Amount = 1;
                             playerAddItem.Player = evnt.PickUpPlayer;
                             playerAddItem.Send();
                         }
                     }
                     PickUp componentInChildren = evnt.PickUpEntity.GetComponentInChildren <PickUp>();
                     if (!componentInChildren || !componentInChildren.TryPool())
                     {
                         BoltNetwork.Destroy(evnt.PickUpEntity);
                     }
                 }
             }
             else
             {
                 DestroyPickUp destroyPickUp = DestroyPickUp.Raise(evnt.PickUpEntity.source);
                 destroyPickUp.PickUpEntity = evnt.PickUpEntity;
                 destroyPickUp.Send();
             }
         }
     }
     else if (evnt.PickUpPlayer.isOwner)
     {
         ItemRemoveFromPlayer itemRemoveFromPlayer = ItemRemoveFromPlayer.Create(GlobalTargets.OnlySelf);
         itemRemoveFromPlayer.ItemId = itemRemoveFromPlayer.ItemId;
         itemRemoveFromPlayer.Send();
     }
     else
     {
         ItemRemoveFromPlayer itemRemoveFromPlayer2 = ItemRemoveFromPlayer.Create(evnt.PickUpPlayer.source);
         itemRemoveFromPlayer2.ItemId = itemRemoveFromPlayer2.ItemId;
         itemRemoveFromPlayer2.Send();
     }
 }