public override void Process(EquipmentAddItem packet)
        {
            GameObject gameObject = SerializationHelper.GetGameObject(packet.ItemBytes);

            Pickupable           pickupable  = gameObject.RequireComponent <Pickupable>();
            GameObject           owner       = GuidHelper.RequireObjectFrom(packet.OwnerGuid);
            Optional <Equipment> opEquipment = EquipmentHelper.GetBasedOnOwnersType(owner);

            if (opEquipment.IsPresent())
            {
                Equipment     equipment     = opEquipment.Get();
                InventoryItem inventoryItem = new InventoryItem(pickupable);
                inventoryItem.container = equipment;
                inventoryItem.item.Reparent(equipment.tr);

                Dictionary <string, InventoryItem> itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment");
                itemsBySlot[packet.Slot] = inventoryItem;

                equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), true });
                Equipment.SendEquipmentEvent(pickupable, EQUIP_EVENT_TYPE_ID, owner, packet.Slot);
                equipment.ReflectionCall("NotifyEquip", false, false, new object[] { packet.Slot, inventoryItem });
            }
            else
            {
                Log.Error("Could not find equipment type for " + gameObject.name);
            }
        }
        public IMineDepositResult TryMine(IPropDepositModule deposit)
        {
            if (deposit is null)
            {
                throw new ArgumentNullException(nameof(deposit));
            }

            var requiredToolTags = deposit.GetToolTags();
            var hasAllTags       = EquipmentHelper.HasAllTags(_tool.Scheme.Tags, requiredToolTags);

            if (!hasAllTags)
            {
                throw new InvalidOperationException("Попытка выполнить добычу ресурса не подходящим инструментом.");
            }

            var isSuccessfulMining = _mineDepositMethodRandomSource.RollSuccess(deposit.Difficulty);

            if (isSuccessfulMining)
            {
                deposit.Mine();

                return(new SuccessMineDepositResult());
            }
            else
            {
                return(new FailureMineDepositResult());
            }
        }
Пример #3
0
        public override void Process(ModuleRemoved packet)
        {
            GameObject           owner       = NitroxIdentifier.RequireObjectFrom(packet.OwnerId);
            GameObject           item        = NitroxIdentifier.RequireObjectFrom(packet.ItemId);
            Pickupable           pickupable  = item.RequireComponent <Pickupable>();
            Optional <Equipment> opEquipment = EquipmentHelper.GetBasedOnOwnersType(owner);

            if (opEquipment.IsPresent())
            {
                Equipment equipment = opEquipment.Get();

                Dictionary <string, InventoryItem> itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment");
                InventoryItem inventoryItem = itemsBySlot[packet.Slot];
                itemsBySlot[packet.Slot] = null;

                equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), false });
                Equipment.SendEquipmentEvent(pickupable, UNEQUIP_EVENT_TYPE_ID, owner, packet.Slot);
                equipment.ReflectionCall("NotifyUnequip", false, false, new object[] { packet.Slot, inventoryItem });
            }
            else
            {
                Log.Error("Could not find equipment type for " + owner.name);
            }

            UnityEngine.Object.Destroy(item);
        }
Пример #4
0
            // Quest Conditions
            protected override void OnCompleteWithSuccess()
            {
                AddLog(OnQuestSucceededLogText);

                foreach (EquipmentCustomIndex index in Enum.GetValues(typeof(EquipmentCustomIndex)))
                {
                    EquipmentIndex i = (EquipmentIndex)index;

                    try
                    {
                        if (!Hero.MainHero.BattleEquipment.GetEquipmentFromSlot(i).IsEmpty)
                        {
                            PartyBase.MainParty.ItemRoster.AddToCounts(Hero.MainHero.BattleEquipment.GetEquipmentFromSlot(i).Item, 1);
                        }
                    }
                    catch (Exception) { }

                    try
                    {
                        if (!Hero.MainHero.CivilianEquipment.GetEquipmentFromSlot(i).IsEmpty)
                        {
                            PartyBase.MainParty.ItemRoster.AddToCounts(Hero.MainHero.CivilianEquipment.GetEquipmentFromSlot(i).Item, 1);
                        }
                    }
                    catch (Exception) { }
                }

                EquipmentHelper.AssignHeroEquipmentFromEquipment(Hero.MainHero, _stolenBattleEquipment);
                EquipmentHelper.AssignHeroEquipmentFromEquipment(Hero.MainHero, _stolenCivilianEquipment);

                RemoveTrackedObject(QuestGiver);
            }
Пример #5
0
        public override void Process(ModuleAdded packet)
        {
            EquippedItemData      equippedItemData = packet.EquippedItemData;
            GameObject            gameObject       = SerializationHelper.GetGameObject(equippedItemData.SerializedData);
            Optional <GameObject> opGameObject     = NitroxEntity.GetObjectFrom(equippedItemData.ContainerId);

            if (!opGameObject.HasValue)
            {
                throw new Exception("Could not find equipment container for " + gameObject.name);
            }
            Pickupable           pickupable  = gameObject.RequireComponent <Pickupable>();
            GameObject           owner       = opGameObject.Value;
            Optional <Equipment> opEquipment = EquipmentHelper.FindEquipmentComponent(owner);

            if (!opEquipment.HasValue)
            {
                throw new Exception("Could not find equipment type for " + gameObject.name);
            }

            Equipment     equipment     = opEquipment.Value;
            InventoryItem inventoryItem = new(pickupable);

            inventoryItem.container = equipment;
            inventoryItem.item.Reparent(equipment.tr);

            Dictionary <string, InventoryItem> itemsBySlot = equipment.equipment;

            itemsBySlot[equippedItemData.Slot] = inventoryItem;

            equipment.UpdateCount(pickupable.GetTechType(), true);
            Equipment.SendEquipmentEvent(pickupable, EQUIP_EVENT_TYPE_ID, owner, equippedItemData.Slot);
            equipment.NotifyEquip(equippedItemData.Slot, inventoryItem);
        }
    private void RemoveArtifactSet_Click(object sender, RoutedEventArgs e)
    {
        if (User.Instance.CurrentHero.ArtifactSets.Count > 1)
        {
            var result = AlertBox.Show("Are you sure you want to delete selected artifact set?");

            if (result == MessageBoxResult.No)
            {
                return;
            }

            if (!EquipmentHelper.CanArtifactSetsBeChanged())
            {
                AlertBox.Show("Artifact Sets cannot be changed while in combat or questing", MessageBoxButton.OK);
                return;
            }

            var removedSetId = User.Instance.CurrentHero.CurrentArtifactSetId;

            var firstId   = User.Instance.CurrentHero.ArtifactSets.Min(x => x.Id);
            var firstName = User.Instance.CurrentHero.ArtifactSets.FirstOrDefault(x => x.Id == firstId)?.Name;

            var oldGrid = LogicalTreeHelper.FindLogicalNode(ArtifactsPanel, "ArtifactSetsGrid") as Grid;
            var artifactSetsComboBox = LogicalTreeHelper.FindLogicalNode(oldGrid, "ArtifactSetsComboBox") as ComboBox;
            artifactSetsComboBox.SelectedItem = firstName;

            User.Instance.CurrentHero.ArtifactSets.RemoveAt(removedSetId);

            RefreshWholeArtifactsPanel();
        }
        else
        {
            AlertBox.Show("You cannot delete the only Artifact Set - you must always have at least one.", MessageBoxButton.OK);
        }
    }
    private void ArtifactSetsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if (_artifactSetsComboBoxSelectionHandled)
        {
            if (!EquipmentHelper.CanArtifactSetsBeChanged())
            {
                AlertBox.Show("Artifact Sets cannot be changed while in combat or questing", MessageBoxButton.OK);

                var comboBox = sender as ComboBox;
                _artifactSetsComboBoxSelectionHandled = false;
                comboBox.SelectedItem = e.RemovedItems[0];

                return;
            }

            var artifactSetName = e.AddedItems[0]?.ToString();

            var artifactSetId = User.Instance.CurrentHero.ArtifactSets.FirstOrDefault(x => x.Name == artifactSetName).Id;

            EquipmentHelper.SwitchArtifactSet(artifactSetId);

            // Refresh the entire panel.
            RefreshWholeArtifactsPanel();
            ArtifactsScrollViewer.ScrollToTop();
        }

        _artifactSetsComboBoxSelectionHandled = true;
    }
Пример #8
0
        private static Equipment GetEquipedTool(IEquipmentModule equipmentModule, string[] requiredToolTags)
        {
            if (!requiredToolTags.Any())
            {
                // В этом методе предполагается, что наличие тегов проверено до вызова.
                throw new ArgumentException("Требуется не пустой набор тегов.", nameof(requiredToolTags));
            }

            foreach (var equipment in equipmentModule)
            {
                if (equipment is null)
                {
                    // Если для добычи указаны какие-либо теги, а ничего не экипировано,
                    // то такая экипировака не подходит.
                    continue;
                }

                var hasAllTags = EquipmentHelper.HasAllTags(equipment.Scheme.Tags, requiredToolTags);
                if (hasAllTags)
                {
                    // This equipment has all required tags.
                    return(equipment);
                }
            }

            return(null);
        }
Пример #9
0
        public override void Process(ModuleRemoved packet)
        {
            GameObject           owner       = NitroxEntity.RequireObjectFrom(packet.OwnerId);
            Optional <Equipment> opEquipment = EquipmentHelper.FindEquipmentComponent(owner);

            if (!opEquipment.HasValue)
            {
                Log.Error("Could not find equipment type for " + owner.name);
                return;
            }

            GameObject item       = NitroxEntity.RequireObjectFrom(packet.ItemId);
            Pickupable pickupable = item.RequireComponent <Pickupable>();
            Equipment  equipment  = opEquipment.Value;
            Dictionary <string, InventoryItem> itemsBySlot = equipment.equipment;
            InventoryItem inventoryItem = itemsBySlot[packet.Slot];

            itemsBySlot[packet.Slot] = null;

            equipment.UpdateCount(pickupable.GetTechType(), false);
            Equipment.SendEquipmentEvent(pickupable, UNEQUIP_EVENT_TYPE_ID, owner, packet.Slot);
            equipment.NotifyUnequip(packet.Slot, inventoryItem);

            UnityEngine.Object.Destroy(item);
        }
Пример #10
0
        public void GiveWeapon(string weaponId)
        {
            var weapon    = MBObjectManager.Instance.GetObject <ItemObject>(weaponId);
            var equipment = new Equipment();

            equipment.AddEquipmentToSlotWithoutAgent(EquipmentIndex.Weapon1, new EquipmentElement(weapon));

            EquipmentHelper.AssignHeroEquipmentFromEquipment(ToTwHero(), equipment);
        }
Пример #11
0
        public void GiveBodyArmor(string bodyArmorId)
        {
            var armor     = MBObjectManager.Instance.GetObject <ItemObject>(bodyArmorId);
            var equipment = new Equipment();

            equipment.AddEquipmentToSlotWithoutAgent(EquipmentIndex.Body, new EquipmentElement(armor));

            EquipmentHelper.AssignHeroEquipmentFromEquipment(ToTwHero(), equipment);
        }
Пример #12
0
 private void ApplyShouldUndress()
 {
     if (CampaignState.CurrentGameStarted())
     {
         EquipmentHelper.AssignHeroEquipmentFromEquipment(new Hero(GameData.Instance.GameContext.Heroes.Player).ToTwHero(), new Equipment(true));
     }
     else
     {
         GameData.Instance.GameContext.Heroes.Player.Equipments = new List <IEquipments>();
     }
 }
Пример #13
0
        public static TimeRecordLite GetTimeRecords(int id, DbAppContext context, IConfiguration configuration)
        {
            HetRentalAgreement agreement = context.HetRentalAgreement.AsNoTracking()
                                           .Include(x => x.Equipment)
                                           .ThenInclude(y => y.DistrictEquipmentType)
                                           .ThenInclude(z => z.EquipmentType)
                                           .Include(x => x.Project)
                                           .Include(x => x.HetTimeRecord)
                                           .First(x => x.RentalAgreementId == id);

            // get the max hours for this equipment type
            float? hoursYtd      = 0.0F;
            int    maxHours      = 0;
            string equipmentCode = "";

            if (agreement.Equipment?.EquipmentId != null &&
                agreement.Equipment.DistrictEquipmentType?.EquipmentType != null)
            {
                maxHours = Convert.ToInt32(agreement.Equipment.DistrictEquipmentType.EquipmentType.IsDumpTruck ?
                                           configuration.GetSection("MaximumHours:DumpTruck").Value :
                                           configuration.GetSection("MaximumHours:Default").Value);

                int equipmentId = agreement.Equipment.EquipmentId;

                hoursYtd = EquipmentHelper.GetYtdServiceHours(equipmentId, context);

                equipmentCode = agreement.Equipment.EquipmentCode;
            }

            // get the project info
            string projectName   = "";
            string projectNumber = "";

            if (agreement.Project != null)
            {
                projectName   = agreement.Project.Name;
                projectNumber = agreement.Project.ProvincialProjectNumber;
            }

            TimeRecordLite timeRecord = new TimeRecordLite
            {
                TimeRecords = new List <HetTimeRecord>()
            };

            timeRecord.TimeRecords.AddRange(agreement.HetTimeRecord);
            timeRecord.EquipmentCode           = equipmentCode;
            timeRecord.ProjectName             = projectName;
            timeRecord.ProvincialProjectNumber = projectNumber;
            timeRecord.HoursYtd     = hoursYtd;
            timeRecord.MaximumHours = maxHours;

            return(timeRecord);
        }
Пример #14
0
        /// <summary>
        /// Get an Owner record
        /// </summary>
        /// <param name="id"></param>
        /// <param name="context"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static HetOwner GetRecord(int id, DbAppContext context, IConfiguration configuration)
        {
            // get equipment status types
            int?statusIdArchived = StatusHelper.GetStatusId(HetEquipment.StatusArchived, "equipmentStatus", context);

            if (statusIdArchived == null)
            {
                throw new ArgumentException("Status Code not found");
            }

            // get owner record
            HetOwner owner = context.HetOwner.AsNoTracking()
                             .Include(x => x.OwnerStatusType)
                             .Include(x => x.LocalArea.ServiceArea.District.Region)
                             .Include(x => x.HetEquipment)
                             .ThenInclude(y => y.LocalArea.ServiceArea.District.Region)
                             .Include(x => x.HetEquipment)
                             .ThenInclude(y => y.DistrictEquipmentType)
                             .ThenInclude(z => z.EquipmentType)
                             .Include(x => x.HetEquipment)
                             .ThenInclude(y => y.Owner)
                             .ThenInclude(c => c.PrimaryContact)
                             .Include(x => x.HetEquipment)
                             .ThenInclude(y => y.EquipmentStatusType)
                             .Include(x => x.HetEquipment)
                             .ThenInclude(y => y.HetEquipmentAttachment)
                             .Include(x => x.HetContact)
                             .Include(x => x.PrimaryContact)
                             .FirstOrDefault(a => a.OwnerId == id);

            if (owner != null)
            {
                // remove any archived equipment
                owner.HetEquipment = owner.HetEquipment.Where(e => e.EquipmentStatusTypeId != statusIdArchived).ToList();

                // populate the "Status" description
                owner.Status = owner.OwnerStatusType.OwnerStatusTypeCode;

                foreach (HetEquipment equipment in owner.HetEquipment)
                {
                    equipment.IsHired         = EquipmentHelper.IsHired(id, context);
                    equipment.NumberOfBlocks  = EquipmentHelper.GetNumberOfBlocks(equipment, configuration);
                    equipment.HoursYtd        = EquipmentHelper.GetYtdServiceHours(id, context);
                    equipment.Status          = equipment.EquipmentStatusType.EquipmentStatusTypeCode;
                    equipment.EquipmentNumber = int.Parse(Regex.Match(equipment.EquipmentCode, @"\d+").Value);
                }

                // HETS-1115 - Do not allow changing seniority affecting entities if an active request exists
                owner.ActiveRentalRequest = RentalRequestStatus(id, context);
            }

            return(owner);
        }
        public override void Process(EquipmentRemoveItem packet)
        {
            Optional <GameObject> opOwner = GuidHelper.GetObjectFrom(packet.OwnerGuid);

            if (opOwner.IsPresent())
            {
                GameObject            owner  = opOwner.Get();
                Optional <GameObject> opItem = GuidHelper.GetObjectFrom(packet.ItemGuid);

                if (opItem.IsPresent())
                {
                    GameObject item = opItem.Get();

                    Pickupable pickupable = item.GetComponent <Pickupable>();

                    if (pickupable != null)
                    {
                        Optional <Equipment> opEquipment = EquipmentHelper.GetBasedOnOwnersType(owner);

                        if (opEquipment.IsPresent())
                        {
                            Equipment equipment = opEquipment.Get();

                            Dictionary <string, InventoryItem> itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment");
                            InventoryItem inventoryItem = itemsBySlot[packet.Slot];
                            itemsBySlot[packet.Slot] = null;

                            equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), false });
                            Equipment.SendEquipmentEvent(pickupable, UNEQUIP_EVENT_TYPE_ID, owner, packet.Slot);
                            equipment.ReflectionCall("NotifyUnequip", false, false, new object[] { packet.Slot, inventoryItem });
                        }
                        else
                        {
                            Console.WriteLine("Could not find equipment type for " + owner.name);
                        }
                    }
                    else
                    {
                        Console.WriteLine("item did not have a pickupable script attached!");
                    }

                    UnityEngine.Object.Destroy(item);
                }
                else
                {
                    Console.WriteLine("Could not find item with guid " + packet.ItemGuid);
                }
            }
            else
            {
                Console.WriteLine("Could not locate equipment owner with guid: " + packet.OwnerGuid);
            }
        }
Пример #16
0
        public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem)
        {
            int totalEquippedItemsDone = 0;

            using (packetSender.Suppress <ItemContainerAdd>())
            {
                foreach (EquippedItemData equippedItem in packet.EquippedItems)
                {
                    waitScreenItem.SetProgress(totalEquippedItemsDone, packet.EquippedItems.Count);

                    GameObject gameObject = SerializationHelper.GetGameObject(equippedItem.SerializedData);
                    NitroxEntity.SetNewId(gameObject, equippedItem.ItemId);

                    Pickupable            pickupable   = gameObject.RequireComponent <Pickupable>();
                    Optional <GameObject> opGameObject = NitroxEntity.GetObjectFrom(equippedItem.ContainerId);

                    if (opGameObject.HasValue)
                    {
                        GameObject owner = opGameObject.Value;

                        Optional <Equipment> opEquipment = EquipmentHelper.FindEquipmentComponent(owner);

                        if (opEquipment.HasValue)
                        {
                            Equipment     equipment     = opEquipment.Value;
                            InventoryItem inventoryItem = new(pickupable);
                            inventoryItem.container = equipment;
                            inventoryItem.item.Reparent(equipment.tr);

                            Dictionary <string, InventoryItem> itemsBySlot = equipment.equipment;
                            itemsBySlot[equippedItem.Slot] = inventoryItem;

                            equipment.UpdateCount(pickupable.GetTechType(), true);
                            Equipment.SendEquipmentEvent(pickupable, 0, owner, equippedItem.Slot);
                            equipment.NotifyEquip(equippedItem.Slot, inventoryItem);
                        }
                        else
                        {
                            Log.Info("Could not find equipment type for " + gameObject.name);
                        }
                    }
                    else
                    {
                        Log.Info("Could not find Container for " + gameObject.name);
                    }

                    totalEquippedItemsDone++;
                    yield return(null);
                }
            }

            Log.Info("Recieved initial sync with " + totalEquippedItemsDone + " pieces of equipped items");
        }
Пример #17
0
        /// <summary>
        /// Equip diver with adequate equipment for dive
        /// - Hope your eyes won't bleed on this one
        /// </summary>
        /// <param name="diver">Diver that we're equipping</param>
        /// <param name="dive">Dive for which we're equipping diver</param>
        public void EquipDiver(Diver diver, Dive dive)
        {
            // Equip with basic equipment
            if (EquipmentHelper.IsBasicEquipment(this))
            {
                LendEquipment(dive, diver);
            }

            // Equip with dry suit
            else if (dive.temperature < Constants.TEMPERATURE_BOUNDARY && EquipmentHelper.IsDrySuit(this) && !diver.CheckIfDiverNeedUndersuit())
            {
                LendEquipment(dive, diver);
            }

            // Equip with undersuit
            else if (EquipmentHelper.IsUndersuit(this) && diver.CheckIfDiverNeedUndersuit())
            {
                LendEquipment(dive, diver);
            }

            // Equip with wet suit
            else if (dive.temperature >= Constants.TEMPERATURE_BOUNDARY && EquipmentHelper.IsWetSuit(this))
            {
                LendEquipment(dive, diver);
            }

            // Equip with hood if needed
            else if (dive.temperature >= 15 && EquipmentHelper.IsHood(this) && diver.CheckIfDiverNeedHood())
            {
                LendEquipment(dive, diver);
            }

            // Equip with equipment for night dive
            else if (dive.isNightDive && needForNightDive == Constants.EQUIPMENT_NEEDED && diver.CheckIfDiverHasSuperPower(Constants.NIGHT_DIVE))
            {
                LendEquipment(dive, diver);
            }

            // Equip with equipment for photographers
            else if (dive.numOfPhotographers > 0 && diver.CheckIfDiverHasSuperPower(Constants.PHOTOGRAPHER) && needForRecording == Constants.EQUIPMENT_NEEDED)
            {
                LendEquipment(dive, diver);
            }

            // Additional equipment
            else if (EquipmentHelper.IsAdditionalEquipment(this) && temperature != "#" && dive.temperature < 20 ||
                     EquipmentHelper.IsAdditionalEquipment(this) && temperature == "#")
            {
                LendEquipment(dive, diver);
            }
        }
Пример #18
0
        internal void CECaptorStripVictim(Hero captive)
        {
            if (captive == null)
            {
                return;
            }
            Equipment randomElement = new Equipment(false);

            ItemObject itemObjectBody = captive.IsFemale
                ? MBObjectManager.Instance.GetObject <ItemObject>("burlap_sack_dress")
                : MBObjectManager.Instance.GetObject <ItemObject>("tattered_rags");

            randomElement.AddEquipmentToSlotWithoutAgent(EquipmentIndex.Body, new EquipmentElement(itemObjectBody));
            Equipment randomElement2 = new Equipment(true);

            randomElement2.FillFrom(randomElement, false);

            if (CESettings.Instance != null && CESettings.Instance.EventCaptorGearCaptives)
            {
                CECampaignBehavior.AddReturnEquipment(captive, captive.BattleEquipment, captive.CivilianEquipment);
            }



            foreach (EquipmentCustomIndex index in Enum.GetValues(typeof(EquipmentCustomIndex)))
            {
                EquipmentIndex i = (EquipmentIndex)index;

                try
                {
                    if (!captive.BattleEquipment.GetEquipmentFromSlot(i).IsEmpty)
                    {
                        PartyBase.MainParty.ItemRoster.AddToCounts(captive.BattleEquipment.GetEquipmentFromSlot(i).Item, 1);
                    }
                }
                catch (Exception) { }

                try
                {
                    if (!captive.CivilianEquipment.GetEquipmentFromSlot(i).IsEmpty)
                    {
                        PartyBase.MainParty.ItemRoster.AddToCounts(captive.CivilianEquipment.GetEquipmentFromSlot(i).Item, 1);
                    }
                }
                catch (Exception) { }
            }

            EquipmentHelper.AssignHeroEquipmentFromEquipment(captive, randomElement);
            EquipmentHelper.AssignHeroEquipmentFromEquipment(captive, randomElement2);
        }
Пример #19
0
 public void EquipItem(IEquipmentModel equipment_)
 {
     foreach (AbstractEquipmentHolder holder in equipmentHolders)
     {
         _newType = EquipmentHelper.GetEquipType(equipment_.Type);
         if (holder.EquipType != _newType)
         {
             continue;
         }
         holder.UnequipItem();
         holder.EquipItem(equipment_);
         break;
     }
 }
Пример #20
0
        private void ConsequenceStrip(Companion companion, Hero hero)
        {
            if (companion.MultipleRestrictedListOfConsequences.Contains(RestrictedListOfConsequences.Strip))
            {
                if (hero == null)
                {
                    return;
                }
                Equipment randomElement = new Equipment(false);

                ItemObject itemObjectBody = hero.IsFemale
                    ? MBObjectManager.Instance.GetObject <ItemObject>("burlap_sack_dress")
                    : MBObjectManager.Instance.GetObject <ItemObject>("tattered_rags");
                randomElement.AddEquipmentToSlotWithoutAgent(EquipmentIndex.Body, new EquipmentElement(itemObjectBody));
                Equipment randomElement2 = new Equipment(true);
                randomElement2.FillFrom(randomElement, false);

                if (CESettings.Instance != null && CESettings.Instance.EventCaptorGearCaptives)
                {
                    CECampaignBehavior.AddReturnEquipment(hero, hero.BattleEquipment, hero.CivilianEquipment);
                }

                foreach (EquipmentCustomIndex index in Enum.GetValues(typeof(EquipmentCustomIndex)))
                {
                    EquipmentIndex i = (EquipmentIndex)index;

                    try
                    {
                        if (!hero.BattleEquipment.GetEquipmentFromSlot(i).IsEmpty)
                        {
                            PartyBase.MainParty.ItemRoster.AddToCounts(hero.BattleEquipment.GetEquipmentFromSlot(i).Item, 1);
                        }
                    }
                    catch (Exception) { }

                    try
                    {
                        if (!hero.CivilianEquipment.GetEquipmentFromSlot(i).IsEmpty)
                        {
                            PartyBase.MainParty.ItemRoster.AddToCounts(hero.CivilianEquipment.GetEquipmentFromSlot(i).Item, 1);
                        }
                    }
                    catch (Exception) { }
                }

                EquipmentHelper.AssignHeroEquipmentFromEquipment(hero, randomElement);
                EquipmentHelper.AssignHeroEquipmentFromEquipment(hero, randomElement2);
            }
        }
Пример #21
0
            public void AddEquipmentToInventories(object sender, EventArgs eventArgs)
            {
                ThrottledBuilder.main.QueueDrained -= AddEquipmentToInventories;

                using (packetSender.Suppress <ItemContainerAdd>())
                {
                    foreach (EquippedItemData equippedItem in equippedItems)
                    {
                        GameObject gameObject = SerializationHelper.GetGameObject(equippedItem.SerializedData);

                        // Mark this entity as spawned by the server
                        gameObject.AddComponent <NitroxEntity>();

                        Pickupable pickupable = gameObject.RequireComponent <Pickupable>();

                        Optional <GameObject> opGameObject = GuidHelper.GetObjectFrom(equippedItem.ContainerGuid);

                        if (opGameObject.IsPresent())
                        {
                            GameObject owner = opGameObject.Get();

                            Optional <Equipment> opEquipment = EquipmentHelper.GetBasedOnOwnersType(owner);

                            if (opEquipment.IsPresent())
                            {
                                Equipment     equipment     = opEquipment.Get();
                                InventoryItem inventoryItem = new InventoryItem(pickupable);
                                inventoryItem.container = equipment;
                                inventoryItem.item.Reparent(equipment.tr);

                                Dictionary <string, InventoryItem> itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment");
                                itemsBySlot[equippedItem.Slot] = inventoryItem;

                                equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), true });
                                Equipment.SendEquipmentEvent(pickupable, 0, owner, equippedItem.Slot);
                                equipment.ReflectionCall("NotifyEquip", false, false, new object[] { equippedItem.Slot, inventoryItem });
                            }
                            else
                            {
                                Log.Info("Could not find equipment type for " + gameObject.name);
                            }
                        }
                        else
                        {
                            Log.Info("Could not find Container for " + gameObject.name);
                        }
                    }
                }
            }
Пример #22
0
        public void AddItems(List <EquippedItemData> equippedItems)
        {
            ItemsContainer container = Inventory.Get().container;

            foreach (EquippedItemData equippedItem in equippedItems)
            {
                GameObject gameObject = SerializationHelper.GetGameObject(equippedItem.SerializedData);
                NitroxEntity.SetNewId(gameObject, equippedItem.ItemId);

                Log.Info("EquipmentSlots/Modules: Received item add request " + gameObject.name + " for container " + equippedItem.ContainerId);

                Pickupable            pickupable   = gameObject.RequireComponent <Pickupable>();
                Optional <GameObject> opGameObject = NitroxEntity.GetObjectFrom(equippedItem.ContainerId);

                if (opGameObject.HasValue)
                {
                    GameObject owner = opGameObject.Value;

                    Optional <Equipment> opEquipment = EquipmentHelper.FindEquipmentComponent(owner);

                    if (opEquipment.HasValue)
                    {
                        Equipment     equipment     = opEquipment.Value;
                        InventoryItem inventoryItem = new InventoryItem(pickupable);
                        inventoryItem.container = equipment;
                        inventoryItem.item.Reparent(equipment.tr);

                        Dictionary <string, InventoryItem> itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment");
                        itemsBySlot[equippedItem.Slot] = inventoryItem;

                        equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), true });
                        Equipment.SendEquipmentEvent(pickupable, 0, owner, equippedItem.Slot);
                        equipment.ReflectionCall("NotifyEquip", false, false, new object[] { equippedItem.Slot, inventoryItem });
                    }
                    else
                    {
                        Log.Info("Could not find equipment type for " + gameObject.name);
                    }
                }
                else
                {
                    Log.Info("Could not find Container for " + gameObject.name);
                }
            }
        }
        public override void Process(InitialPlayerSync packet)
        {
            using (packetSender.Suppress <ItemContainerAdd>())
            {
                foreach (EquippedItemData equippedItem in packet.EquippedItems)
                {
                    GameObject gameObject = SerializationHelper.GetGameObject(equippedItem.SerializedData);
                    NitroxEntity.SetNewId(gameObject, equippedItem.ItemId);

                    Pickupable            pickupable   = gameObject.RequireComponent <Pickupable>();
                    Optional <GameObject> opGameObject = NitroxEntity.GetObjectFrom(equippedItem.ContainerId);

                    if (opGameObject.IsPresent())
                    {
                        GameObject owner = opGameObject.Get();

                        Optional <Equipment> opEquipment = EquipmentHelper.GetBasedOnOwnersType(owner);

                        if (opEquipment.IsPresent())
                        {
                            Equipment     equipment     = opEquipment.Get();
                            InventoryItem inventoryItem = new InventoryItem(pickupable);
                            inventoryItem.container = equipment;
                            inventoryItem.item.Reparent(equipment.tr);

                            Dictionary <string, InventoryItem> itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment");
                            itemsBySlot[equippedItem.Slot] = inventoryItem;

                            equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), true });
                            Equipment.SendEquipmentEvent(pickupable, 0, owner, equippedItem.Slot);
                            equipment.ReflectionCall("NotifyEquip", false, false, new object[] { equippedItem.Slot, inventoryItem });
                        }
                        else
                        {
                            Log.Info("Could not find equipment type for " + gameObject.name);
                        }
                    }
                    else
                    {
                        Log.Info("Could not find Container for " + gameObject.name);
                    }
                }
            }
        }
Пример #24
0
        public void AddItems(List <EquippedItemData> equippedItems)
        {
            ItemsContainer container = Inventory.Get().container;

            foreach (EquippedItemData equippedItem in equippedItems)
            {
                GameObject gameObject = SerializationHelper.GetGameObject(equippedItem.SerializedData);
                Pickupable pickupable = gameObject.RequireComponent <Pickupable>();

                Optional <GameObject> opGameObject = GuidHelper.GetObjectFrom(equippedItem.ContainerGuid);

                if (opGameObject.IsPresent())
                {
                    GameObject owner = opGameObject.Get();

                    Optional <Equipment> opEquipment = EquipmentHelper.GetBasedOnOwnersType(owner);

                    if (opEquipment.IsPresent())
                    {
                        Equipment     equipment     = opEquipment.Get();
                        InventoryItem inventoryItem = new InventoryItem(pickupable);
                        inventoryItem.container = equipment;
                        inventoryItem.item.Reparent(equipment.tr);

                        Dictionary <string, InventoryItem> itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment");
                        itemsBySlot[equippedItem.Slot] = inventoryItem;

                        equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), true });
                        Equipment.SendEquipmentEvent(pickupable, 0, owner, equippedItem.Slot);
                        equipment.ReflectionCall("NotifyEquip", false, false, new object[] { equippedItem.Slot, inventoryItem });
                    }
                    else
                    {
                        Log.Info("Could not find equipment type for " + gameObject.name);
                    }
                }
                else
                {
                    Log.Info("Could not find Container for " + gameObject.name);
                }
            }
        }
Пример #25
0
        /// <summary>
        /// Get an Owner record
        /// </summary>
        /// <param name="id"></param>
        /// <param name="context"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static HetOwner GetRecord(int id, DbAppContext context, IConfiguration configuration)
        {
            HetOwner owner = context.HetOwner.AsNoTracking()
                             .Include(x => x.OwnerStatusType)
                             .Include(x => x.LocalArea.ServiceArea.District.Region)
                             .Include(x => x.HetEquipment)
                             .ThenInclude(y => y.LocalArea.ServiceArea.District.Region)
                             .Include(x => x.HetEquipment)
                             .ThenInclude(y => y.DistrictEquipmentType)
                             .ThenInclude(z => z.EquipmentType)
                             .Include(x => x.HetEquipment)
                             .ThenInclude(y => y.Owner)
                             .ThenInclude(c => c.PrimaryContact)
                             .Include(x => x.HetEquipment)
                             .ThenInclude(y => y.EquipmentStatusType)
                             .Include(x => x.HetEquipment)
                             .ThenInclude(y => y.HetEquipmentAttachment)
                             .Include(x => x.HetContact)
                             .Include(x => x.PrimaryContact)
                             .FirstOrDefault(a => a.OwnerId == id);

            if (owner != null)
            {
                // remove any archived equipment
                owner.HetEquipment = owner.HetEquipment.Where(e => e.EquipmentStatusType.EquipmentStatusTypeCode != HetEquipment.StatusArchived).ToList();

                // populate the "Status" description
                owner.Status = owner.OwnerStatusType.OwnerStatusTypeCode;

                foreach (HetEquipment equipment in owner.HetEquipment)
                {
                    equipment.IsHired         = EquipmentHelper.IsHired(id, context);
                    equipment.NumberOfBlocks  = EquipmentHelper.GetNumberOfBlocks(equipment, configuration);
                    equipment.HoursYtd        = EquipmentHelper.GetYtdServiceHours(id, context);
                    equipment.Status          = equipment.EquipmentStatusType.EquipmentStatusTypeCode;
                    equipment.EquipmentNumber = int.Parse(Regex.Match(equipment.EquipmentCode, @"\d+").Value);
                }
            }

            return(owner);
        }
Пример #26
0
        /// <summary>
        /// Update diver equipment status
        /// FULLY EQUIPED       - basic equipment + all additional equipment
        /// PARTIALLY EQUIPED   - basic equipment
        /// NOT EQUIPED         - without basic equipment
        /// </summary>
        public void UpdateEquipmentStatus(Dive dive)
        {
            int basicEquipmentCounter = 0;

            // Check if user have all basic equipment
            foreach (ConcreteEquipment equipment in equipmentList)
            {
                if (EquipmentHelper.IsBasicEquipment(equipment))
                {
                    basicEquipmentCounter++;
                }
            }

            // Basic equipment
            if (basicEquipmentCounter == Constants.NUM_OF_BASIC_EQUIPMENT && equipmentList.Count() == Constants.NUM_OF_BASIC_EQUIPMENT)
            {
                equipmentStatus = Constants.PARTIALLY_EQUIPED;
            }

            // Diver is not adequate equiped for dive
            else if (basicEquipmentCounter < Constants.NUM_OF_BASIC_EQUIPMENT)
            {
                equipmentStatus = Constants.NOT_EQUIPED;
            }

            // Basic + additional equipment
            else if (
                // If it's cold dive then check if diver is adequate equipped for cold dive
                (dive.temperature < Constants.TEMPERATURE_BOUNDARY && EquipmentHelper.IsDiverAdequatEquippedForColdDive(equipmentList)) ||

                // If it's dive with temp above 15 and diver is adequate equipped for that dive
                (dive.temperature >= Constants.TEMPERATURE_BOUNDARY && EquipmentHelper.IsDiverAdequateEquippedForWarmDive(equipmentList)) &&

                // If it's night dive then check if diver is adequate equipped for night dive
                ((dive.isNightDive && EquipmentHelper.IsDiverAdequateEquippedForNightDive(EquipmentList)) || !dive.isNightDive)
                )
            {
                equipmentStatus = Constants.FULLY_EQUIPED;
            }
        }
Пример #27
0
        /// <summary>
        /// Recalculates seniority with the new sorting rule (sorting by equipment code) for the district equipment types that have the same seniority and received date
        /// </summary>
        /// <param name="context"></param>
        /// <param name="seniorityScoringRules"></param>
        /// <param name="connectionString"></param>
        public static void RecalculateSeniorityList(PerformContext context, string seniorityScoringRules, string connectionString)
        {
            // open a connection to the database
            DbAppContext dbContext = new DbAppContext(connectionString);

            // get equipment status
            int?equipmentStatusId = StatusHelper.GetStatusId(HetEquipment.StatusApproved, "equipmentStatus", dbContext);

            if (equipmentStatusId == null)
            {
                throw new ArgumentException("Status Code not found");
            }

            context.WriteLine("Recalculation Started");

            var progress = context.WriteProgressBar();

            progress.SetValue(0);

            var equipments = dbContext.HetEquipment.AsNoTracking()
                             .Where(x => x.EquipmentStatusTypeId == equipmentStatusId)
                             .GroupBy(x => new { x.LocalAreaId, x.DistrictEquipmentTypeId, x.Seniority, x.ReceivedDate })
                             .Where(x => x.Count() > 1)
                             .Select(x => new { x.Key.LocalAreaId, x.Key.DistrictEquipmentTypeId })
                             .Distinct()
                             .ToList();

            var count = 0;

            foreach (var equipment in equipments)
            {
                EquipmentHelper.RecalculateSeniority(equipment.LocalAreaId, equipment.DistrictEquipmentTypeId, dbContext, seniorityScoringRules);
                progress.SetValue(Convert.ToInt32(++count / equipments.Count * 100));
                context.WriteLine($"Processed {count} / {equipments.Count}");
            }

            progress.SetValue(100);

            context.WriteLine("Recalculation Finished");
        }
Пример #28
0
        /// <summary>
        /// Get rental request record
        /// </summary>
        /// <param name="id"></param>
        /// <param name="context"></param>
        public static HetRentalRequest GetRecord(int id, DbAppContext context)
        {
            HetRentalRequest request = context.HetRentalRequest.AsNoTracking()
                                       .Include(x => x.RentalRequestStatusType)
                                       .Include(x => x.LocalArea.ServiceArea.District.Region)
                                       .Include(x => x.Project)
                                       .ThenInclude(c => c.PrimaryContact)
                                       .Include(x => x.Project)
                                       .ThenInclude(c => c.ProjectStatusType)
                                       .Include(x => x.HetRentalRequestAttachment)
                                       .Include(x => x.DistrictEquipmentType)
                                       .Include(x => x.HetRentalRequestRotationList)
                                       .ThenInclude(y => y.Equipment)
                                       .ThenInclude(z => z.EquipmentStatusType)
                                       .FirstOrDefault(a => a.RentalRequestId == id);

            if (request != null)
            {
                request.Status = request.RentalRequestStatusType.RentalRequestStatusTypeCode;

                // calculate the Yes Count based on the RentalRequestList
                request.YesCount = CalculateYesCount(request);

                // calculate YTD hours for the equipment records
                if (request.HetRentalRequestRotationList != null)
                {
                    foreach (HetRentalRequestRotationList rotationList in request.HetRentalRequestRotationList)
                    {
                        if (rotationList.Equipment != null)
                        {
                            rotationList.Equipment.HoursYtd = EquipmentHelper.GetYtdServiceHours(rotationList.Equipment.EquipmentId, context);
                        }
                    }
                }
            }

            return(request);
        }
Пример #29
0
        public override void Process(ModuleAdded packet)
        {
            EquippedItemData equippedItemData = packet.EquippedItemData;
            GameObject       gameObject       = SerializationHelper.GetGameObject(equippedItemData.SerializedData);

            Pickupable pickupable = gameObject.RequireComponent <Pickupable>();

            Optional <GameObject> opGameObject = NitroxIdentifier.GetObjectFrom(equippedItemData.ContainerId);

            if (opGameObject.IsPresent())
            {
                GameObject           owner       = opGameObject.Get();
                Optional <Equipment> opEquipment = EquipmentHelper.GetBasedOnOwnersType(owner);

                if (opEquipment.IsPresent())
                {
                    Equipment     equipment     = opEquipment.Get();
                    InventoryItem inventoryItem = new InventoryItem(pickupable);
                    inventoryItem.container = equipment;
                    inventoryItem.item.Reparent(equipment.tr);

                    Dictionary <string, InventoryItem> itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment");
                    itemsBySlot[equippedItemData.Slot] = inventoryItem;

                    equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), true });
                    Equipment.SendEquipmentEvent(pickupable, EQUIP_EVENT_TYPE_ID, owner, equippedItemData.Slot);
                    equipment.ReflectionCall("NotifyEquip", false, false, new object[] { equippedItemData.Slot, inventoryItem });
                }
                else
                {
                    Log.Error("Could not find equipment type for " + gameObject.name);
                }
            }
            else
            {
                Log.Info("Could not find Container for " + gameObject.name);
            }
        }
Пример #30
0
    private void AddArtifactSet_Click(object sender, RoutedEventArgs e)
    {
        if (!EquipmentHelper.CanArtifactSetsBeChanged())
        {
            AlertBox.Show("Artifact Sets cannot be changed while in combat or questing", MessageBoxButton.OK);
            return;
        }

        var newId = User.Instance.CurrentHero.ArtifactSets.Max(x => x.Id) + 1;

        User.Instance.CurrentHero.ArtifactSets.Add(new ArtifactSet
        {
            Id   = newId,
            Name = "Artifact Set " + newId
        });

        RefreshWholeArtifactsPanel();

        var oldGrid = LogicalTreeHelper.FindLogicalNode(ArtifactsPanel, "ArtifactSetsGrid") as Grid;
        var artifactSetsComboBox = LogicalTreeHelper.FindLogicalNode(oldGrid, "ArtifactSetsComboBox") as ComboBox;

        artifactSetsComboBox.SelectedItem = "Artifact Set " + newId;
    }