public void DropItems(BaseEntity initiator = null) { if (inventory != null && inventory.itemList != null && inventory.itemList.Count != 0 && dropChance != 0f) { DropUtil.DropItems(inventory, GetDropPosition(), dropChance); } }
public static long GetDropNum(int ruleId, int level, ref int itemId) { List <DiaoLuo> dropsByRuleId = DropUtil.GetDropsByRuleId(ruleId); if (dropsByRuleId.get_Count() == 0) { return(0L); } DiaoLuo diaoLuo = dropsByRuleId.get_Item(0); if (diaoLuo.dropType == 1) { return(0L); } if (diaoLuo.dropType == 2) { int groupId = diaoLuo.goodsId; List <Zu> list = DataReader <Zu> .DataList.FindAll((Zu a) => a.groupId == groupId); for (int i = 0; i < list.get_Count(); i++) { if (level >= list.get_Item(i).minLv&& level <= list.get_Item(i).maxLv) { itemId = list.get_Item(i).itemId; return(list.get_Item(i).Num); } } } return(0L); }
public XDict <int, long> GetRewardItems(int id) { XDict <int, long> xDict = new XDict <int, long>(); List <DiaoLuo> dropsByRuleId = DropUtil.GetDropsByRuleId(id); if (dropsByRuleId == null || dropsByRuleId.get_Count() <= 0) { return(xDict); } for (int i = 0; i < dropsByRuleId.get_Count(); i++) { DiaoLuo dataDropCfg = dropsByRuleId.get_Item(i); int id2 = dataDropCfg.id; if (!xDict.ContainsKey(dataDropCfg.goodsId)) { if (dataDropCfg.dropType == 1) { xDict.Add(dataDropCfg.goodsId, dataDropCfg.maxNum); } else if (dataDropCfg.dropType == 2) { int carrer = EntityWorld.Instance.EntSelf.TypeID; Zu zu = DataReader <Zu> .DataList.Find((Zu a) => a.groupId == dataDropCfg.goodsId && a.profession == carrer); if (zu != null) { xDict.Add(zu.itemId, dataDropCfg.maxNum); } } } } return(xDict); }
private static void Remove(BasePlayer player) { RaycastHit hit; BaseEntity entity = Physics.Raycast(player.eyes.HeadRay(), out hit, 3.0f, colliderRemovable) ? hit.GetEntity() : null; if (entity == null) { player.ChatMessage("<color=#d00>ERROR</color> No valid entity, or entyity is too far."); return; } if (!player.CanBuild()) { player.ChatMessage("<color=#d00>ERROR</color> No building priviliges."); return; } if (entity.OwnerID != player.userID && !HasFriend(entity.OwnerID, player.userID)) { player.ChatMessage($"<color=#d00>ERROR</color> You are not the owner of this entity."); return; } if (entity is StorageContainer && (entity as StorageContainer).inventory.itemList.Count > 0) { DropUtil.DropItems((entity as StorageContainer).inventory, entity.transform.position, 1f); } entity.Kill(BaseNetworkable.DestroyMode.Gib); }
private void SetRewards(ChongWuRenWuPinZhi dataRWPZ, PetTaskInfo pti) { this.m_lblTaskReward.set_text(string.Empty); if (dataRWPZ.drop.get_Count() > 0) { int templateId = 0; long dropNum = DropUtil.GetDropNum(dataRWPZ.drop.get_Item(0), EntityWorld.Instance.EntSelf.Lv, ref templateId); this.m_lblTaskReward.set_text(string.Format("奖励: 人物经验+{0}", Utils.GetItemNum(templateId, dropNum))); } List <int> itemIds = new List <int>(); List <long> itemNums = new List <long>(); if (pti.rewards.get_Count() > 0) { this.m_itemId = pti.rewards.get_Item(0).cfgId; itemIds.Add(pti.rewards.get_Item(0).cfgId); itemNums.Add(pti.rewards.get_Item(0).count); } this.mItemListPool.Create(itemIds.get_Count(), delegate(int index) { if (index < this.mItemListPool.Items.get_Count() && index < itemIds.get_Count() && index < itemNums.get_Count()) { ItemShow.SetItem(this.mItemListPool.Items.get_Item(index), itemIds.get_Item(index), itemNums.get_Item(index), false, UINodesManager.T2RootOfSpecial, 14000); } }); }
void OnDestroy() { Base.InitializeHealth(Base.health / HealthModificator, Base.MaxHealth() / HealthModificator); Base.locomotion.gallopSpeed /= SpeedModificator; Base.locomotion.trotSpeed /= SpeedModificator; Base.locomotion.acceleration /= SpeedModificator; DropUtil.DropItems(inventory, transform.position); SaveNpcList.Remove(owner.owner.userID.ToString()); RustAI.ServerInit(); }
private void OnPlayerAttack(BasePlayer attacker, HitInfo info) { if (attacker == null || info?.HitEntity == null) { return; } if (attacker.IsNpc || !attacker.userID.IsSteamId()) { return; } if (!info.HitEntity.ShortPrefabName.Contains("barrel")) { return; } if (configData.lootContainerSettings.ContainsKey(info.HitEntity.ShortPrefabName) && !configData.lootContainerSettings[info.HitEntity.ShortPrefabName]) { return; } var barrel = info.HitEntity as LootContainer; if (barrel?.net?.ID == null) { return; } var barrelID = barrel.net.ID; if (!entityPlayers.ContainsKey(barrelID)) { entityPlayers.Add(barrelID, new HashSet <ulong> { attacker.userID }); } else { entityPlayers[barrelID].Add(attacker.userID); } if (!lootDestroyTimer.ContainsKey(barrelID)) { lootDestroyTimer.Add(barrelID, timer.Once(configData.timeBeforeLootEmpty, () => { if (barrel?.inventory?.itemList == null) { return; } DropUtil.DropItems(barrel.inventory, barrel.transform.position); barrel.RemoveMe(); })); } EmptyJunkPile(barrel); }
public void OnDrop(PointerEventData eventData) { previousItemSlot = ItemDragHandler.PreviousItemSlot; if (previousItemSlot == null || !previousItemSlot.IsItemDroppable) { return; } Item draggedItem = previousItemSlot.GetItem(); DropUtil.DropItem(_player.transform.Find("BulletSpawn").transform, draggedItem); Debug.Log("Dropped Item " + draggedItem.ToString()); previousItemSlot.SetItemAndReload(new NullItem()); }
public void PopItemsBackToInventory() { Debug.Log(_fallbackInventory.ItemSlots.Count); foreach (ItemSlot slot in _mergeInventory.ItemSlots) { Item slotItem = slot.GetItem(); if (!(slotItem is NullItem) && !_fallbackInventory.AddItem(slotItem)) { DropUtil.DropItem(GameObject.FindGameObjectWithTag("Player").transform.Find("BulletSpawn").transform, slot.GetItem()); } slot.SetItemAndReload(new NullItem()); } }
private void OnLootEntityEnd(BasePlayer player, BaseEntity entity) { if (entity == null || player == null) { return; } if (Trade != null && Trade.Call <bool>("IsTradeBox", entity)) { return; } if (entity.net == null) { return; } var entityId = entity.net.ID; var loot = entity.GetComponent <LootContainer>(); if (loot == null || LootContainer.spawnType.AIRDROP.Equals(loot.SpawnType) && !_emptyAirdrop || LootContainer.spawnType.CRASHSITE.Equals(loot.SpawnType) && !_emptyCrashsite) { return; } var originalValue = 0; if (lootEntity.TryGetValue(entityId, out originalValue)) { if (loot.inventory.itemList.Count < originalValue) { if (loot.inventory.itemList.Count == 0) { return; } if (Slap != null && _slapPlayer) { Slap.Call("SlapPlayer", player.IPlayer); } timer.Once(_timeBeforeLootDespawn, () => { if (loot == null) { return; } DropUtil.DropItems(loot?.inventory, loot.transform.position); BaseNetworkable.serverEntities.Find(entityId)?.Kill(); }); } lootEntity.Remove(entityId); } }
private void OnLootEntityEnd(BasePlayer player, LootContainer lootContainer) { if (lootContainer?.net == null || player == null) { return; } if (lootContainer?.inventory?.itemList == null) { return; } var entityID = lootContainer.net.ID; if (lootContainer.inventory.itemList.Count <= 0) { if (lootEntities.ContainsKey(entityID)) { lootEntities.Remove(entityID); } if (entityPlayers.ContainsKey(entityID)) { entityPlayers[entityID].Remove(player.userID); } return; } if (lootEntities.ContainsKey(entityID) && entityPlayers.ContainsKey(entityID)) { if (lootContainer.inventory.itemList.Count < lootEntities[entityID]) { if (!lootDestroyTimer.ContainsKey(entityID)) { lootDestroyTimer.Add(entityID, timer.Once(configData.timeBeforeLootEmpty, () => { if (lootContainer?.inventory?.itemList == null) { return; } DropUtil.DropItems(lootContainer.inventory, lootContainer.transform.position); lootContainer.RemoveMe(); })); } } else { entityPlayers[entityID].Remove(player.userID); } lootEntities.Remove(entityID); EmptyJunkPile(lootContainer); } }
public void DropItems() { if (this.inventory == null || this.inventory.itemList == null || (this.inventory.itemList.Count == 0 || (double)this.dropChance == 0.0)) { return; } if (this.ShouldDropItemsIndividually() || this.inventory.itemList.Count == 1) { DropUtil.DropItems(this.inventory, this.GetDropPosition(), 1f); } else { Object.op_Inequality((Object)this.inventory.Drop("assets/prefabs/misc/item drop/item_drop.prefab", this.GetDropPosition(), ((Component)this).get_transform().get_rotation()), (Object)null); } }
public void DropItems() { if (this.inventory == null || this.inventory.itemList == null || this.inventory.itemList.Count == 0) { return; } if (this.dropChance == 0f) { return; } if (this.ShouldDropItemsIndividually() || this.inventory.itemList.Count == 1) { DropUtil.DropItems(this.inventory, this.GetDropPosition(), 1f); return; } }
void ItemSpawner(BaseEntity heldEntity, Vector3 dropPosition) { if (heldEntity != null) { Item weapon = ItemManager.CreateByItemID(heldEntity.GetItem().info.itemid); if (weapon != null) { weapon.condition = Random.Range(1f, 100f); ItemContainer container = new ItemContainer(); container.Insert(weapon); DropUtil.DropItems(container, dropPosition); heldWeapon = heldEntity.ShortPrefabName; AmmoAssigner(heldWeapon); } } }
private void OnDestroy() { DropUtil.DropItems(inventory, transform.position); owner.npcAi = null; if (entity.health <= 0) { return; } entity.InitializeHealth(entity.Health() / healthModifier, entity.MaxHealth() / healthModifier); entity.AttackDamage /= attackModifier; entity.Stats.TurnSpeed /= speedModifier; entity.Stats.Speed /= speedModifier; }
void OnDestroy() { DropUtil.DropItems(inventory, transform.position); SaveNpcList.Remove(owner.owner.userID); RustAI.ServerInit(); if (Base.health <= 0) { return; } Base.enableSaving = true; BaseEntity.saveList.Add(Base); Base.InitializeHealth(Base.health / HealthModificator, Base.MaxHealth() / HealthModificator); Base.locomotion.gallopSpeed /= SpeedModificator; Base.locomotion.trotSpeed /= SpeedModificator; Base.locomotion.acceleration /= SpeedModificator; }
private void EmptyJunkPile(LootContainer lootContainer) { if (!configData.emptyJunkpile) { return; } var junkPiles = Facepunch.Pool.GetList <JunkPile>(); Vis.Entities(lootContainer.transform.position, 5f, junkPiles); if (junkPiles.Count > 0) { var junkPile = junkPiles[0]; if (junkPile?.net?.ID != null) { var junkPileID = junkPile.net.ID; if (!lootDestroyTimer.ContainsKey(junkPileID)) { lootDestroyTimer.Add(junkPileID, timer.Once(configData.timeBeforeJunkpileEmpty, () => { if (junkPile == null || junkPile.IsDestroyed) { return; } if (configData.dropNearbyLoot) { var lootContainers = Facepunch.Pool.GetList <LootContainer>(); Vis.Entities(junkPile.transform.position, 5f, lootContainers); foreach (var loot in lootContainers) { DropUtil.DropItems(loot.inventory, loot.transform.position); } Facepunch.Pool.FreeList(ref lootContainers); } junkPile.SinkAndDestroy(); })); } } } Facepunch.Pool.FreeList(ref junkPiles); }
void OnEntityKill(BaseNetworkable entity) //Removes entities from chunks { if (!initalized) { return; } if (entity is DroppedItem) { itemGrid.OnItemKilled((DroppedItem)entity); } else if (entity is DecayEntity) { itemGrid.UpdateGrid(entity); } else if (entity is PlayerCorpse) { var corpse = entity as PlayerCorpse; foreach (var container in corpse.containers) //Simplest way, I doubt people will leave 20k stone on a corpse to decay { DropUtil.DropItems(container, container.dropPosition); } } }
private void OnDeath() { enabled = false; EjectAllPlayers(); DestroyAllMounts(); Effect.server.Run(prefabExplosion, transform.position); if (container.inventory.itemList.Count > 0) { DropUtil.DropItems(container.inventory, car.transform.position + new Vector3(0f, 2f, 0f)); } plug.NextTick(() => { if (car != null && !car.IsDestroyed) { car.DieInstantly(); } Destroy(this); }); }
public void UpdateItem(int id) { this.RewardItems.get_gameObject().SetActive(true); this.id = id; this.data = DataReader <Achievement> .Get(id); AchievementItemInfo achievementItemInfo = AchievementManager.Instance.AllIdList.get_Item(id); this.state = achievementItemInfo.isAccept; if (this.data.icon > 0) { ResourceManager.SetSprite(this.Icon, GameDataUtils.GetIcon(this.data.icon)); } this.Name.set_text(GameDataUtils.GetChineseContent(this.data.name, false)); string text = GameDataUtils.GetChineseContent(this.data.introduction, false); int linkSystem = this.data.linkSystem; switch (linkSystem) { case 5: goto IL_E8; case 6: case 7: IL_C5: switch (linkSystem) { case 15: case 19: goto IL_E8; case 17: text = "配置表被删,找策划哥!(通关主线副本第X章第X节XXX)"; goto IL_158; } text = string.Format(text, this.data.size.get_Item(0)); goto IL_158; case 8: case 9: text = "配置表被删,找策划哥!(通关精英副本第X章第X节XXX)"; goto IL_158; } goto IL_C5; IL_E8: text = string.Format(text, this.data.size.get_Item(0), this.data.size.get_Item(1)); IL_158: this.NameDes.set_text(text); int num = achievementItemInfo.completeProgress.get_Item(0); if (this.data.schedule == -1) { this.ProgressText.get_gameObject().SetActive(false); } else { this.ProgressText.get_gameObject().SetActive(true); this.ProgressText.set_text(string.Concat(new object[] { string.Empty, num, "/", this.data.schedule })); } IEnumerator enumerator = this.RewardItems.GetEnumerator(); try { while (enumerator.MoveNext()) { Transform transform = (Transform)enumerator.get_Current(); Object.Destroy(transform.get_gameObject()); } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } if (this.data.dropId > 0) { List <DiaoLuoZu> itemList = DropUtil.GetItemList(this.data.dropId); for (int i = 0; i < itemList.get_Count(); i++) { DiaoLuoZu diaoLuoZu = itemList.get_Item(i); GameObject gameObject = Object.Instantiate <GameObject>(this.itemPrefab); ResourceManager.SetInstantiateUIRef(gameObject, null); gameObject.SetActive(true); gameObject.get_transform().SetParent(this.RewardItems); gameObject.get_transform().set_localScale(new Vector3(1f, 1f, 1f)); gameObject.get_transform().set_localPosition(new Vector3(0f, 0f, 0f)); gameObject.get_transform().set_localEulerAngles(new Vector3(0f, 0f, 0f)); ResourceManager.SetSprite(gameObject.get_transform().FindChild("Frame").GetComponent <Image>(), GameDataUtils.GetItemFrame(diaoLuoZu.itemId)); ResourceManager.SetSprite(gameObject.get_transform().FindChild("Icon").GetComponent <Image>(), GameDataUtils.GetIcon(DataReader <Items> .Get(diaoLuoZu.itemId).littleIcon)); gameObject.get_transform().FindChild("Num").GetComponent <Text>().set_text("x" + diaoLuoZu.maxNum.ToString()); } } this.FinishImg.get_gameObject().SetActive(false); this.RewardBtn.get_gameObject().SetActive(false); this.GotoBtn.get_gameObject().SetActive(false); if (this.data.go != -1 && this.state == 0) { this.GotoBtn.get_gameObject().SetActive(true); } else if (this.state == 1) { this.RewardBtn.get_gameObject().SetActive(true); } else if (this.state == 2) { this.FinishImg.get_gameObject().SetActive(true); this.RewardItems.get_gameObject().SetActive(false); } }