public bool SetWeaponPartByPartId(EWeaponSlotType slot, int matchedPartId)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.CanApplyPart)
            {
                return(false);
            }
            WeaponPartsStruct lastParts = agent.PartsScan;
            bool match = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(agent.ConfigId).IsPartMatchWeapon(matchedPartId);

            if (!match)
            {
                return(false);
            }
            var attachments = WeaponPartUtil.ModifyPartItem(lastParts,
                                                            SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(matchedPartId), matchedPartId);

            agent.BaseComponent.ApplyParts(attachments);
            if (slot == HeldSlotType && processHelper.FilterRefreshWeapon())
            {
                ApperanceRefreshABreath(HeldWeaponAgent.BreathFactor);
            }
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = agent.PartsScan;
            RefreshWeaponModelAndParts(refreshData);
            DebugUtil.MyLog("Set Weapon part:" + refreshData, DebugUtil.DebugColor.Green);
            return(true);
        }
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name                          ="slot"></param>
        /// <param name                          ="partType"></param>
        public void DeleteWeaponPart(EWeaponSlotType slot, EWeaponPartType partType)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.IsValid())
            {
                return;
            }
            WeaponPartsStruct lastParts = agent.BaseComponent.CreateParts();
            var parts = WeaponPartUtil.ModifyPartItem(
                agent.BaseComponent.CreateParts(), partType,
                UniversalConsts.InvalidIntId);

            agent.BaseComponent.ApplyParts(parts);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            var newParts = WeaponPartUtil.ModifyPartItem(lastParts, partType, UniversalConsts.InvalidIntId);

            WeaponPartUtil.CombineDefaultParts(ref newParts, agent.BaseComponent.ConfigId);
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = newParts;
            RefreshModelWeaponParts(refreshData);
        }
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool SetWeaponPart(EWeaponSlotType slot, int id)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.IsValid())
            {
                return(false);
            }
            WeaponPartsStruct lastParts = agent.BaseComponent.CreateParts();
            int  realAttachId           = WeaponUtil.GetRealAttachmentId(id, agent.ResConfig.Id);
            bool match = SingletonManager.Get <WeaponPartsConfigManager>().IsPartMatchWeapon(realAttachId, agent.ResConfig.Id);

            if (!match)
            {
                return(false);
            }
            var attachments = WeaponPartUtil.ModifyPartItem(
                agent.BaseComponent.CreateParts(),
                SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(realAttachId),
                realAttachId);

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

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = agent.BaseComponent.CreateParts();
            RefreshModelWeaponParts(refreshData);
            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name ="slot"></param>
        /// <param name ="partType"></param>
        public void DeleteWeaponPart(EWeaponSlotType slot, EWeaponPartType partType)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.IsValid())
            {
                return;
            }
            WeaponPartsStruct lastParts = agent.PartsScan;
            var newParts = WeaponPartUtil.ModifyPartItem(lastParts, partType, 0);

            agent.BaseComponent.ApplyParts(newParts);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = newParts;
            RefreshModelWeaponParts(refreshData);
            DebugUtil.MyLog("Delete Weapon part:" + refreshData, DebugUtil.DebugColor.Green);
        }
Beispiel #5
0
        public bool SetWeaponPartByPartId(EWeaponSlotType slot, int matchedPartId)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.IsValid())
            {
                return(false);
            }
            WeaponPartsStruct lastParts = agent.PartsScan;
            bool match = SingletonManager.Get <WeaponPartsConfigManager>().IsPartMatchWeapon(matchedPartId, agent.ResConfig.Id);

            if (!match)
            {
                return(false);
            }
            var attachments = WeaponPartUtil.ModifyPartItem(lastParts,
                                                            SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(matchedPartId), matchedPartId);

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

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = agent.PartsScan;
            RefreshModelWeaponParts(refreshData);
            DebugUtil.MyLog("Set Weapon part:" + refreshData, DebugUtil.DebugColor.Green);
            return(true);
        }
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name ="slot"></param>
        /// <param name ="partType"></param>
        public void DeleteWeaponPart(EWeaponSlotType slot, EWeaponPartType partType)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.IsValid())
            {
                return;
            }
            WeaponPartsStruct lastParts = agent.PartsScan;
            var defaultParts            = agent.WeaponConfigAssy.DefaultParts;
            int newPart = 0; //移除配件后装备默认配件

            switch (partType)
            {
            case EWeaponPartType.LowerRail:
                newPart = defaultParts.LowerRail;
                break;

            case EWeaponPartType.UpperRail:
                newPart = defaultParts.UpperRail;
                break;

            case EWeaponPartType.Muzzle:
                newPart = defaultParts.Muzzle;
                break;

            case EWeaponPartType.Magazine:
                newPart = defaultParts.Magazine;
                break;

            case EWeaponPartType.Stock:
                newPart = defaultParts.Stock;
                break;

            case EWeaponPartType.SideRail:
                newPart = defaultParts.SideRail;
                break;

            case EWeaponPartType.Bore:
                newPart = defaultParts.Bore;
                break;

            case EWeaponPartType.Interlock:
                newPart = defaultParts.Interlock;
                break;

            case EWeaponPartType.Feed:
                newPart = defaultParts.Feed;
                break;

            case EWeaponPartType.Brake:
                newPart = defaultParts.Brake;
                break;

            case EWeaponPartType.Trigger:
                newPart = defaultParts.Trigger;
                break;

            default:
                break;
            }
            if (newPart <= 0)
            {
                newPart = 0;
            }
            var newParts = WeaponPartUtil.ModifyPartItem(lastParts, partType, newPart);

            agent.BaseComponent.ApplyParts(newParts);
            if (slot == HeldSlotType)
            {
                if (processHelper.FilterRefreshWeapon())
                {
                    ApperanceRefreshABreath(HeldWeaponAgent.BreathFactor);
                }
            }
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = newParts;
            RefreshWeaponModelAndParts(refreshData);
            DebugUtil.MyLog("Delete Weapon part:" + refreshData, DebugUtil.DebugColor.Green);
        }