Example #1
0
        public void DeleteWeaponPart(EWeaponSlotType slot, EWeaponPartType part)
        {
            if (slot == EWeaponSlotType.None)
            {
                return;
            }
            var weaponComp = GetWeaponComponentBySlot(slot);

            if (null == weaponComp)
            {
                Logger.ErrorFormat("error : weaponcompent in slot {0} is null", slot);
                return;
            }
            var weapon    = GetWeaponComponentBySlot(slot);
            var lastParts = weapon.GetParts();

            if (null != weaponComp)
            {
                var parts = WeaponPartsUtil.ModifyParts(
                    weaponComp.GetParts(),
                    part,
                    UniversalConsts.InvalidIntId);
                weaponComp.ApplyParts(parts);
            }

            if (slot == CurWeaponSlot)
            {
                RefreshCurrentWeaponAttachmentLogic();
            }

            var newParts = WeaponPartsUtil.ModifyParts(lastParts, part, UniversalConsts.InvalidIntId);

            newParts = newParts.ApplyDefaultParts(weapon.Id);
            RefreshWeaponPartsModel(weapon.Id, slot, lastParts, newParts);
        }
Example #2
0
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="part"></param>
        public void DeleteSlotWeaponPart(EWeaponSlotType slot, EWeaponPartType part)
        {
            if (slot == EWeaponSlotType.None)
            {
                return;
            }
            WeaponEntity entity = GetWeaponAgent(slot).Entity;

            if (entity == null)
            {
                throw new ExWeaponNotFoundException("{0} slot weapon not found", slot);
                return;
            }

            WeaponPartsStruct lastParts = entity.weaponBasicData.GetParts();
            var parts = WeaponPartsUtil.ModifyParts(
                entity.weaponBasicData.GetParts(), part,
                UniversalConsts.InvalidIntId);

            entity.weaponBasicData.ApplyParts(parts);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            var newParts = WeaponPartsUtil.ModifyParts(lastParts, part, UniversalConsts.InvalidIntId);

            newParts = newParts.ApplyDefaultParts(entity.weaponBasicData.ConfigId);
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = entity.ToWeaponScan();
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = newParts;
            RefreshModelWeaponParts(refreshData);
        }
Example #3
0
        public EFuncResult SetWeaponPart(EWeaponSlotType slot, int id)
        {
            if (slot == EWeaponSlotType.None)
            {
                return(EFuncResult.Exception);
            }

            var weaponComp = GetWeaponComponentBySlot(slot);

            if (weaponComp.Id < 1)
            {
                Logger.ErrorFormat("set attachment failed : no weapon in slot {0}", slot);
                return(EFuncResult.Exception);
            }
            var lastParts = weaponComp.GetParts();
            var weaponCfg = _newWeaponConfigManager.GetConfigById(weaponComp.Id);

            if (null == weaponCfg)
            {
                return(EFuncResult.Exception);
            }

            var realAttachId = BagUtility.GetRealAttachmentId(id, weaponCfg.Id);
            var match        = SingletonManager.Get <WeaponPartsConfigManager>().IsPartMatchWeapon(realAttachId, weaponCfg.Id);

            if (!match)
            {
                return(EFuncResult.Failed);
            }

            if (WeaponValid(weaponComp))
            {
                var attachments = WeaponPartsUtil.ModifyParts(
                    weaponComp.GetParts(),
                    SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(realAttachId),
                    realAttachId);
                weaponComp.ApplyParts(attachments);
            }
            else
            {
                Logger.ErrorFormat("No weapon in slot {0}", slot);
            }

            if (slot == CurWeaponSlot)
            {
                RefreshCurrentWeaponAttachmentLogic();
            }

            RefreshWeaponPartsModel(weaponComp.Id,
                                    slot,
                                    lastParts,
                                    weaponComp.GetParts());
            return(EFuncResult.Success);
        }
Example #4
0
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool SetSlotWeaponPart(EWeaponSlotType slot, int id)
        {
            WeaponEntity entity = GetWeaponAgent(slot).Entity;

            if (entity == null)
            {
                throw new ExWeaponNotFoundException("{0} slot weapon not found", slot);
                return(false);
            }
            NewWeaponConfigItem wpConfig  = SingletonManager.Get <WeaponConfigManager>().GetConfigById(entity.weaponBasicData.ConfigId);
            WeaponPartsStruct   lastParts = entity.weaponBasicData.GetParts();
            int  realAttachId             = BagUtility.GetRealAttachmentId(id, wpConfig.Id);
            bool match = SingletonManager.Get <WeaponPartsConfigManager>().IsPartMatchWeapon(realAttachId, wpConfig.Id);

            if (!match)
            {
                return(false);
            }
            var attachments = WeaponPartsUtil.ModifyParts(
                entity.weaponBasicData.GetParts(),
                SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(realAttachId),
                realAttachId);

            entity.weaponBasicData.ApplyParts(attachments);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = entity.ToWeaponScan();
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = entity.weaponBasicData.GetParts();
            RefreshModelWeaponParts(refreshData);
            return(true);
        }
Example #5
0
 public void RefreshWeaponPartsModel(int weaponId, EWeaponSlotType slot, WeaponPartsStruct oldAttachment, WeaponPartsStruct newAttachments)
 {
     WeaponPartsUtil.RefreshWeaponPartModels(_playerEntity.appearanceInterface.Appearance, weaponId, oldAttachment, newAttachments, slot);
 }
 public void ModelRefreshWeaponParts(int weaponId, EWeaponSlotType slot, WeaponPartsStruct oldAttachment, WeaponPartsStruct newAttachments)
 {
     WeaponPartsUtil.RefreshWeaponPartModels(RelatedAppearence.Appearance, weaponId, oldAttachment, newAttachments, slot);
 }