예제 #1
0
        public void AddIngrendient_Actual(int ingredientNum, bool local, BoltConnection from = null)
        {
            Craft_Structure.BuildIngredients buildIngredients = this._requiredIngredients[ingredientNum];
            ReceipeIngredient receipeIngredient = this._presentIngredients[ingredientNum];
            int num = 0;

            for (int i = 0; i < this._requiredIngredients.Count; i++)
            {
                num += this._requiredIngredients[i]._amount - this._presentIngredients[i]._amount;
            }
            if (receipeIngredient._amount >= buildIngredients._amount || (num == 1 && (this._lockBuild || (this.CustomLockCheck != null && this.CustomLockCheck()))))
            {
                if (BoltNetwork.isRunning && from && !Cheats.Creative)
                {
                    PlayerAddItem playerAddItem = PlayerAddItem.Create(from);
                    playerAddItem.ItemId = buildIngredients._itemID;
                    playerAddItem.Amount = 1;
                    playerAddItem.Send();
                }
                this.UpdateNetworkIngredients();
                return;
            }
            receipeIngredient._amount++;
            this.UpdateNeededRenderers();
            BuildMission.AddNeededToBuildMission(receipeIngredient._itemID, -1, false);
            if (BoltNetwork.isRunning)
            {
                this.UpdateNetworkIngredients();
            }
            this.CheckNeeded();
        }
예제 #2
0
 public override void OnEvent(PlayerAddItem evnt)
 {
     if (BoltNetwork.isServer && evnt.Player != null && evnt.Player != LocalPlayer.Entity)
     {
         PlayerAddItem playerAddItem = PlayerAddItem.Create(evnt.Player.source);
         playerAddItem.ItemId             = evnt.ItemId;
         playerAddItem.Amount             = evnt.Amount;
         playerAddItem.ActiveBonus        = evnt.ActiveBonus;
         playerAddItem.ActiveBonusValue   = evnt.ActiveBonusValue;
         playerAddItem.IntVal1            = evnt.IntVal1;
         playerAddItem.FloatVal1          = evnt.FloatVal1;
         playerAddItem.ItemPropertiesType = evnt.ItemPropertiesType;
         playerAddItem.Send();
     }
     else
     {
         int num = (evnt.Amount <= 1) ? 1 : evnt.Amount;
         if (!LocalPlayer.Inventory.AddItem(evnt.ItemId, num, false, false, ItemProperties.CreateFrom(evnt)))
         {
             for (int i = 0; i < num; i++)
             {
                 LocalPlayer.Inventory.FakeDrop(evnt.ItemId, null);
             }
         }
     }
 }
예제 #3
0
 public override void OnEvent(StealItem evnt)
 {
     if (BoltNetwork.isServer && evnt.robbed != LocalPlayer.Entity)
     {
         StealItem stealItem = StealItem.Create(evnt.robbed.source);
         stealItem.thief  = evnt.thief;
         stealItem.robbed = evnt.robbed;
         stealItem.Send();
     }
     else if (evnt.robbed == LocalPlayer.Entity)
     {
         if (!LocalPlayer.Inventory.IsRightHandEmpty())
         {
             ItemStorageProxy component = LocalPlayer.Inventory.RightHand._held.GetComponent <ItemStorageProxy>();
             if (component)
             {
                 for (int i = 0; i < component._storage.UsedSlots.Count; i++)
                 {
                     PlayerAddItem playerAddItem = PlayerAddItem.Create(GlobalTargets.OnlyServer);
                     playerAddItem.Player = evnt.thief;
                     playerAddItem.ItemId = component._storage.UsedSlots[i]._itemId;
                     playerAddItem.Amount = component._storage.UsedSlots[i]._amount;
                     playerAddItem.Send();
                 }
                 component._storage.Close();
                 component._storage.UsedSlots.Clear();
                 component._storage.UpdateContentVersion();
                 component.CheckContentVersion();
             }
             else
             {
                 PlayerAddItem playerAddItem = PlayerAddItem.Create(GlobalTargets.OnlyServer);
                 playerAddItem.Player = evnt.thief;
                 playerAddItem.ItemId = LocalPlayer.Inventory.RightHand._itemId;
                 playerAddItem.Send();
                 LocalPlayer.Inventory.UnequipItemAtSlot(Item.EquipmentSlot.RightHand, false, false, false);
             }
         }
     }
     else if (evnt.robbed.source == LocalPlayer.Entity.source)
     {
         ItemStorage component2 = evnt.robbed.GetComponent <ItemStorage>();
         if (component2)
         {
             for (int j = 0; j < component2.UsedSlots.Count; j++)
             {
                 PlayerAddItem playerAddItem2 = PlayerAddItem.Create(GlobalTargets.OnlyServer);
                 playerAddItem2.Player = evnt.thief;
                 playerAddItem2.ItemId = component2.UsedSlots[j]._itemId;
                 playerAddItem2.Amount = component2.UsedSlots[j]._amount;
                 playerAddItem2.Send();
             }
             BoltNetwork.Destroy(component2.gameObject);
         }
     }
 }
예제 #4
0
 public void AddItemMP(BoltConnection source)
 {
     if (this.Items < this.ItemsRender.Length)
     {
         base.state.ItemCount = (this.Items = Mathf.Min(this.Items + 1, this.ItemsRender.Length));
         base.entity.Freeze(false);
     }
     else
     {
         PlayerAddItem playerAddItem = PlayerAddItem.Create(source);
         playerAddItem.ItemId = this._itemid;
         playerAddItem.Send();
     }
 }
예제 #5
0
 public void AddItemMP(BoltConnection source)
 {
     if (base.state.ItemCount < this.LogRender.Length)
     {
         base.state.ItemCount = Mathf.Min(base.state.ItemCount + 1, this.LogRender.Length);
         this.RefreshMassAndDrag();
     }
     else
     {
         PlayerAddItem playerAddItem = PlayerAddItem.Create(source);
         playerAddItem.ItemId = this._itemId;
         playerAddItem.Send();
     }
 }
예제 #6
0
 public override void OnEvent(PlayerAddItem evnt)
 {
     if (BoltNetwork.isServer && evnt.Player != null && evnt.Player != LocalPlayer.Entity)
     {
         PlayerAddItem playerAddItem = PlayerAddItem.Create(evnt.Player.source);
         playerAddItem.ItemId = evnt.ItemId;
         playerAddItem.Amount = evnt.Amount;
         playerAddItem.Send();
     }
     else
     {
         int num = (evnt.Amount <= 1) ? 1 : evnt.Amount;
         if (!LocalPlayer.Inventory.AddItem(evnt.ItemId, num, false, false, (WeaponStatUpgrade.Types)(-2)))
         {
             for (int i = 0; i < num; i++)
             {
                 LocalPlayer.Inventory.FakeDrop(evnt.ItemId);
             }
         }
     }
 }
예제 #7
0
 public void AddItemMP(MultiHolder.ContentTypes type, BoltConnection source)
 {
     if ((this._contentTypeActual == MultiHolder.ContentTypes.Log || this._contentTypeActual == MultiHolder.ContentTypes.None) && type == MultiHolder.ContentTypes.Log)
     {
         if (type == MultiHolder.ContentTypes.None)
         {
             this._contentActual = 0;
         }
         if (base.entity.isOwner)
         {
             this._contentTypeActual = MultiHolder.ContentTypes.Log;
             if (this._contentActual < this.LogRender.Length)
             {
                 this._contentActual = Mathf.Min(this._contentActual + 1, this.LogRender.Length);
             }
             else
             {
                 PlayerAddItem playerAddItem = PlayerAddItem.Create(source);
                 playerAddItem.ItemId = this.LogItemId;
                 playerAddItem.Send();
             }
             this.RefreshMassAndDrag();
         }
         else
         {
             ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(base.entity.source);
             itemHolderAddItem.Target      = base.entity;
             itemHolderAddItem.ContentType = 1;
             itemHolderAddItem.Send();
         }
     }
     if ((this._contentTypeActual == MultiHolder.ContentTypes.Rock || this._contentTypeActual == MultiHolder.ContentTypes.None) && type == MultiHolder.ContentTypes.Rock)
     {
         if (type == MultiHolder.ContentTypes.None)
         {
             this._contentActual = 0;
         }
         if (base.entity.isOwner)
         {
             this._contentTypeActual = MultiHolder.ContentTypes.Rock;
             if (this._contentActual < this.RockRender.Length)
             {
                 this._contentActual = Mathf.Min(this._contentActual + 1, this.RockRender.Length);
             }
             else
             {
                 PlayerAddItem playerAddItem2 = PlayerAddItem.Create(source);
                 playerAddItem2.ItemId = this.RockItemId;
                 playerAddItem2.Send();
             }
             this.RefreshMassAndDrag();
         }
         else
         {
             ItemHolderAddItem itemHolderAddItem2 = ItemHolderAddItem.Create(base.entity.source);
             itemHolderAddItem2.ContentType = 3;
             itemHolderAddItem2.Target      = base.entity;
             itemHolderAddItem2.Send();
         }
     }
     if ((this._contentTypeActual == MultiHolder.ContentTypes.Stick || this._contentTypeActual == MultiHolder.ContentTypes.None) && type == MultiHolder.ContentTypes.Stick)
     {
         if (type == MultiHolder.ContentTypes.None)
         {
             this._contentActual = 0;
         }
         if (base.entity.isOwner)
         {
             this._contentTypeActual = MultiHolder.ContentTypes.Stick;
             if (this._contentActual < this.StickRender.Length)
             {
                 this._contentActual = Mathf.Min(this._contentActual + 1, this.StickRender.Length);
             }
             else
             {
                 PlayerAddItem playerAddItem3 = PlayerAddItem.Create(source);
                 playerAddItem3.ItemId = this.StickItemId;
                 playerAddItem3.Send();
             }
             this.RefreshMassAndDrag();
         }
         else
         {
             ItemHolderAddItem itemHolderAddItem3 = ItemHolderAddItem.Create(base.entity.source);
             itemHolderAddItem3.ContentType = 4;
             itemHolderAddItem3.Target      = base.entity;
             itemHolderAddItem3.Send();
         }
     }
 }
예제 #8
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();
     }
 }
예제 #9
0
 public override void OnEvent(StealItem evnt)
 {
     if (BoltNetwork.isServer && evnt.robbed != LocalPlayer.Entity)
     {
         StealItem stealItem = StealItem.Create(evnt.robbed.source);
         stealItem.thief  = evnt.thief;
         stealItem.robbed = evnt.robbed;
         stealItem.Send();
     }
     else if (evnt.robbed == LocalPlayer.Entity)
     {
         if (!LocalPlayer.Inventory.IsRightHandEmpty())
         {
             ItemStorageProxy component = LocalPlayer.Inventory.RightHand._held.GetComponent <ItemStorageProxy>();
             if (component)
             {
                 for (int i = 0; i < component._storage.UsedSlots.Count; i++)
                 {
                     PlayerAddItem playerAddItem = PlayerAddItem.Create(GlobalTargets.OnlyServer);
                     playerAddItem.Player = evnt.thief;
                     playerAddItem.ItemId = component._storage.UsedSlots[i]._itemId;
                     playerAddItem.Amount = component._storage.UsedSlots[i]._amount;
                     component._storage.UsedSlots[i]._properties.Fill(playerAddItem);
                     playerAddItem.Send();
                     Item item = ItemDatabase.ItemById(playerAddItem.ItemId);
                     if (item.MatchType(Item.Types.Weapon))
                     {
                         EventRegistry.Achievements.Publish(TfEvent.Achievements.SharedWeapon, null);
                     }
                     else if (item.MatchType(Item.Types.Edible))
                     {
                         EventRegistry.Achievements.Publish(TfEvent.Achievements.SharedEdible, null);
                     }
                 }
                 component._storage.Close();
                 component._storage.UsedSlots.Clear();
                 component._storage.UpdateContentVersion();
                 component.CheckContentVersion();
             }
             else
             {
                 PlayerAddItem playerAddItem = PlayerAddItem.Create(GlobalTargets.OnlyServer);
                 playerAddItem.Player = evnt.thief;
                 playerAddItem.ItemId = LocalPlayer.Inventory.RightHand._itemId;
                 LocalPlayer.Inventory.RightHand.Properties.Fill(playerAddItem);
                 playerAddItem.Send();
                 LocalPlayer.Inventory.UnequipItemAtSlot(Item.EquipmentSlot.RightHand, false, false, false);
             }
         }
     }
     else if (evnt.robbed.source == LocalPlayer.Entity.source)
     {
         ItemStorage component2 = evnt.robbed.GetComponent <ItemStorage>();
         if (component2)
         {
             for (int j = 0; j < component2.UsedSlots.Count; j++)
             {
                 PlayerAddItem playerAddItem2 = PlayerAddItem.Create(GlobalTargets.OnlyServer);
                 playerAddItem2.Player = evnt.thief;
                 playerAddItem2.ItemId = component2.UsedSlots[j]._itemId;
                 playerAddItem2.Amount = component2.UsedSlots[j]._amount;
                 playerAddItem2.Send();
             }
             BoltNetwork.Destroy(component2.gameObject);
         }
     }
 }