/// <summary> /// 根据PartType修改配件信息 /// </summary> /// <param name="attach"></param> /// <param name="type"></param> /// <param name="id"></param> /// <returns></returns> public static WeaponPartsStruct ModifyPartItem(WeaponPartsStruct attach, EWeaponPartType type, int id) { switch (type) { case EWeaponPartType.LowerRail: attach.LowerRail = id; break; case EWeaponPartType.UpperRail: attach.UpperRail = id; break; case EWeaponPartType.Muzzle: attach.Muzzle = id; break; case EWeaponPartType.Magazine: attach.Magazine = id; break; case EWeaponPartType.Stock: attach.Stock = id; break; } return(attach); }
/// <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); }
private void Prepare(WeaponPartsStruct attachments) { Reset(); _attachmentList.Add(attachments.UpperRail); _attachmentList.Add(attachments.LowerRail); _attachmentList.Add(attachments.Muzzle); _attachmentList.Add(attachments.Magazine); _attachmentList.Add(attachments.Stock); for (var i = 0; i < _attachmentList.Count; i++) { if (_attachmentList[i] < 1) { continue; } var modifiedInfos = _attachConfigManager.GetModifyInfos(_attachmentList[i]); if (null == modifiedInfos) { continue; } foreach (var info in modifiedInfos) { if (_attachAttributeDic[info.Type].HasValue) { _attachAttributeDic[info.Type] += info.Val; } else { _attachAttributeDic[info.Type] = info.Val; } } } }
public static void RefreshWeaponPartModels(ICharacterAppearance appearance, int weaponId, WeaponPartsStruct oldParts, WeaponPartsStruct parts, EWeaponSlotType slot) { var weaponConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(weaponId); if (null == weaponConfig) { return; } if (!((EWeaponType_Config)weaponConfig.Type).MayHasPart()) { Logger.WarnFormat("weapon type {0} has no attachment by default ", weaponConfig.Type); return; } var pos = slot.ToWeaponInPackage(); // var oldArr = oldParts.ToAniLocation(); var newArr = parts.ToAniLocation(); for (WeaponPartLocation tmp = WeaponPartLocation.None + 1; tmp < WeaponPartLocation.EndOfTheWorld; tmp++) { if (newArr[(int)tmp] > 0) { appearance.MountAttachment(pos, tmp, newArr[(int)tmp]); } else { appearance.UnmountAttachment(pos, tmp); } } }
/// <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); }
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="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); }
public static void CombineDefaultParts(ref WeaponPartsStruct result, int weaponId) { var defaultParts = SingletonManager.Get <WeaponResourceConfigManager>().GetDefaultWeaponAttachments(weaponId); foreach (var part in defaultParts) { if (part < 1) { continue; } var partCfg = SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(part); switch ((EWeaponPartType)partCfg.Type) { case EWeaponPartType.LowerRail: result.LowerRail = result.LowerRail > 0 ? result.LowerRail : part; break; case EWeaponPartType.UpperRail: result.UpperRail = result.UpperRail > 0 ? result.UpperRail : part; break; case EWeaponPartType.Muzzle: result.Muzzle = result.Muzzle > 0 ? result.Muzzle : part; break; case EWeaponPartType.Magazine: result.Magazine = result.Magazine > 0 ? result.Magazine : part; break; case EWeaponPartType.Stock: result.Stock = result.Stock > 0 ? result.Stock : part; break; } } }
/// <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); }
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); }
public override void SetAttachment(WeaponPartsStruct attachments) { if (null != _fireLogic) { _fireLogic.SetAttachment(attachments); } _attachmentManager.ApplyAttachment(this); }
public static ExpandWeaponLogicConfig GetWeaponDataConfig(this PlayerEntity playerEntity, Contexts contexts, int weaponId, WeaponPartsStruct weaponPartsStruct, IPlayerWeaponConfigManager playerWeaponConfigManager) { return(playerWeaponConfigManager.GetWeaponLogicConfig(weaponId, weaponPartsStruct)); }
public static void ApplyParts(this WeaponBasicDataComponent comp, WeaponPartsStruct attach) { comp.LowerRail = attach.LowerRail; comp.UpperRail = attach.UpperRail; comp.Muzzle = attach.Muzzle; comp.Magazine = attach.Magazine; comp.Stock = attach.Stock; }
private static void MapAttachmentsToAttachmentDic(WeaponPartsStruct attachments, Dictionary <WeaponPartLocation, int> attachmentDic) { attachmentDic.Clear(); attachmentDic[WeaponPartLocation.LowRail] = attachments.LowerRail; attachmentDic[WeaponPartLocation.Scope] = attachments.UpperRail; attachmentDic[WeaponPartLocation.Buttstock] = attachments.Stock; attachmentDic[WeaponPartLocation.Muzzle] = attachments.Muzzle; attachmentDic[WeaponPartLocation.Magazine] = attachments.Magazine; }
// public static WeaponPartsStruct CreateParts(WeaponBasicDataComponent comp) // { // var result = new WeaponPartsStruct // { // LowerRail = comp.LowerRail, // UpperRail = comp.UpperRail, // Muzzle = comp.Muzzle, // Stock = comp.Stock, // Magazine = comp.Magazine, // }; // // CombineDefaultParts(ref result, comp.ConfigId); // return result; // } /// <summary> /// 添加装备默认配件信息 /// </summary> /// <param name="result"></param> /// <param name="weaponId"></param> public static void CombineDefaultParts(ref WeaponPartsStruct result, int weaponId) { var defaultParts = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(weaponId).DefaultParts; result.LowerRail = result.LowerRail > 0 ? result.LowerRail : defaultParts.LowerRail; result.UpperRail = result.UpperRail > 0 ? result.UpperRail : defaultParts.UpperRail; result.Muzzle = result.Muzzle > 0 ? result.Muzzle : defaultParts.Muzzle; result.Magazine = result.Magazine > 0 ? result.Magazine : defaultParts.Magazine; result.Stock = result.Stock > 0 ? result.Stock : defaultParts.Stock; }
public static int[] ToAniLocation(this WeaponPartsStruct parts) { int[] arr = new int[(int)WeaponPartLocation.EndOfTheWorld]; arr[(int)WeaponPartLocation.LowRail] = parts.LowerRail; arr[(int)WeaponPartLocation.Scope] = parts.UpperRail; arr[(int)WeaponPartLocation.Buttstock] = parts.Stock; arr[(int)WeaponPartLocation.Muzzle] = parts.Muzzle; arr[(int)WeaponPartLocation.Magazine] = parts.Magazine; return(arr); }
public void SetAttachment(WeaponPartsStruct attachments) { _attachmentManager.Prepare(attachments); _attachmentManager.ApplyAttachment(_kickbackLogic); _attachmentManager.ApplyAttachment(_spreadLogic); _attachmentManager.ApplyAttachment(_accuracyLogic); _attachmentManager.ApplyAttachment(_bulletLogic); _attachmentManager.ApplyAttachment(_soundLogic); _attachmentManager.ApplyAttachment(_weaponEffectLogic); _attachmentManager.ApplyAttachment(_bulletFactory); _attachmentManager.ApplyAttachment(this); }
private ExpandWeaponLogicConfig GetAndCacheConfig(int id, WeaponPartsStruct weaponParts) { InitCache(); Dictionary <WeaponPartsStruct, ExpandWeaponLogicConfig> partsDic; if (_configCache.TryGetValue(id, out partsDic)) { ExpandWeaponLogicConfig config; if (partsDic.TryGetValue(weaponParts, out config)) { return(config); } } Prepare(weaponParts); var weaponConfig = _weaponDataConfigManager.GetConfigById(id); if (null == weaponConfig) { Logger.ErrorFormat("WeaponConfig is null for {0}", id); return(null); } var baseConfig = weaponConfig.WeaponLogic; var targetConfig = baseConfig.Copy(); ApplyAttachment(baseConfig, targetConfig); if (!_configCache.ContainsKey(id)) { _configCache[id] = new Dictionary <WeaponPartsStruct, ExpandWeaponLogicConfig>(WeaponPartsStructComparer.Instance); } var defaultWeaponLogicCfg = targetConfig as DefaultWeaponLogicConfig; if (null != defaultWeaponLogicCfg) { var expandConfig = new ExpandWeaponLogicConfig(defaultWeaponLogicCfg); _configCache[id][weaponParts] = expandConfig; return(expandConfig); } else { var tacticWeaponLogicCfg = targetConfig as TacticWeaponLogicConfig; if (null != tacticWeaponLogicCfg) { var expandConfig = new ExpandWeaponLogicConfig(tacticWeaponLogicCfg); _configCache[id][weaponParts] = expandConfig; return(expandConfig); } } Logger.ErrorFormat("illegal weapon config for {0}", id); return(null); }
public static WeaponPartsStruct CreateParts(WeaponPartsAchive achive) { var result = new WeaponPartsStruct { LowerRail = achive.LowerRail, UpperRail = achive.UpperRail, Muzzle = achive.Muzzle, Stock = achive.Stock, Magazine = achive.Magazine, }; return(result); }
/// <summary> /// 根据PartType修改配件信息 /// </summary> /// <param name="attach"></param> /// <param name="type"></param> /// <param name="id"></param> /// <returns></returns> public static WeaponPartsStruct ModifyPartItem(WeaponPartsStruct attach, EWeaponPartType type, int id) { switch (type) { case EWeaponPartType.LowerRail: attach.LowerRail = id; break; case EWeaponPartType.UpperRail: attach.UpperRail = id; break; case EWeaponPartType.Muzzle: attach.Muzzle = id; break; case EWeaponPartType.Magazine: attach.Magazine = id; break; case EWeaponPartType.Stock: attach.Stock = id; break; case EWeaponPartType.SideRail: attach.SideRail = id; break; case EWeaponPartType.Bore: attach.Bore = id; break; case EWeaponPartType.Feed: attach.Feed = id; break; case EWeaponPartType.Trigger: attach.Trigger = id; break; case EWeaponPartType.Interlock: attach.Interlock = id; break; case EWeaponPartType.Brake: attach.Brake = id; break; } return(attach); }
public static void ApplyParts(this WeaponBasicDataComponent comp, WeaponPartsStruct attach) { comp.LowerRail = attach.LowerRail; comp.UpperRail = attach.UpperRail; comp.Muzzle = attach.Muzzle; comp.Magazine = attach.Magazine; comp.Stock = attach.Stock; comp.SideRail = attach.SideRail; comp.Bore = attach.Bore; comp.Feed = attach.Feed; comp.Trigger = attach.Trigger; comp.Interlock = attach.Interlock; comp.Brake = attach.Brake; }
public static WeaponPartsStruct CreateParts(this WeaponBasicDataComponent comp) { var result = new WeaponPartsStruct { LowerRail = comp.LowerRail, UpperRail = comp.UpperRail, Muzzle = comp.Muzzle, Stock = comp.Stock, Magazine = comp.Magazine, }; CombineDefaultParts(ref result, comp.ConfigId); return(result); }
public static WeaponPartsStruct GetParts(this WeaponInfo info) { var result = new WeaponPartsStruct { LowerRail = info.LowerRail, UpperRail = info.UpperRail, Magazine = info.Magazine, Muzzle = info.Muzzle, Stock = info.Stock, }; result = result.ApplyDefaultParts(info.Id); return(result); }
public static WeaponPartsStruct CreateParts(this WeaponScanStruct info) { var result = new WeaponPartsStruct { LowerRail = info.LowerRail, UpperRail = info.UpperRail, Magazine = info.Magazine, Muzzle = info.Muzzle, Stock = info.Stock, }; CombineDefaultParts(ref result, info.ConfigId); return(result); }
public static WeaponPartsStruct GetParts(this WeaponComponent comp) { var result = new WeaponPartsStruct { LowerRail = comp.LowerRail, UpperRail = comp.UpperRail, Muzzle = comp.Muzzle, Stock = comp.Stock, Magazine = comp.Magazine, }; result = result.ApplyDefaultParts(comp.Id); return(result); }
/// <summary> /// 添加装备默认配件信息 /// </summary> /// <param name="result"></param> /// <param name="weaponId"></param> public static void CombineDefaultParts(ref WeaponPartsStruct result, int weaponId) { var defaultParts = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(weaponId).DefaultParts; result.LowerRail = result.LowerRail > 0 ? result.LowerRail : defaultParts.LowerRail; result.UpperRail = result.UpperRail > 0 ? result.UpperRail : defaultParts.UpperRail; result.Muzzle = result.Muzzle > 0 ? result.Muzzle : defaultParts.Muzzle; result.Magazine = result.Magazine > 0 ? result.Magazine : defaultParts.Magazine; result.Stock = result.Stock > 0 ? result.Stock : defaultParts.Stock; result.SideRail = result.SideRail > 0 ? result.SideRail : defaultParts.SideRail; result.Bore = result.Bore > 0 ? result.Bore : defaultParts.Bore; result.Brake = result.Brake > 0 ? result.Brake : defaultParts.Brake; result.Feed = result.Feed > 0 ? result.Feed : defaultParts.Feed; result.Interlock = result.Interlock > 0 ? result.Interlock : defaultParts.Interlock; result.Trigger = result.Trigger > 0 ? result.Trigger : defaultParts.Trigger; }
/// <summary> /// 手雷武器替换操作:当前ConfigId必须已存在于库存,将手雷ENity替换 为当前configId /// </summary> /// <param name="Owner"></param> /// <param name="orient"></param> /// <param name="refreshParams"></param> /// <returns></returns> public override WeaponEntity ReplaceWeapon(EntityKey Owner, WeaponScanStruct orient, ref WeaponPartsRefreshStruct refreshParams) { if (bagCacheHelper.ShowCount(orient.ConfigId) == 0) { return(null); } refreshParams.lastWeaponKey = WeaponKey; ReleaseWeapon(); bagCacheHelper.SetCurr(orient.ConfigId); WeaponPartsStruct parts = orient.CreateParts(); refreshParams.weaponInfo = orient; refreshParams.slot = handledSlot; refreshParams.oldParts = new WeaponPartsStruct(); refreshParams.newParts = parts; refreshParams.armInPackage = true; return(bagCacheHelper.GetGrenadeEntity()); }
public static WeaponPartsStruct CreateParts(WeaponPartsAchive achive) { var result = new WeaponPartsStruct { LowerRail = achive.LowerRail, UpperRail = achive.UpperRail, Muzzle = achive.Muzzle, Stock = achive.Stock, Magazine = achive.Magazine, SideRail = achive.SideRail, Bore = achive.Bore, Brake = achive.Brake, Feed = achive.Feed, Interlock = achive.Interlock, Trigger = achive.Trigger }; return(result); }
public static WeaponPartsStruct CreateParts(WeaponScanStruct info) { var result = new WeaponPartsStruct { LowerRail = info.LowerRail, UpperRail = info.UpperRail, Magazine = info.Magazine, Muzzle = info.Muzzle, Stock = info.Stock, SideRail = info.SideRail, Bore = info.Bore, Brake = info.Brake, Feed = info.Feed, Interlock = info.Interlock, Trigger = info.Trigger }; CombineDefaultParts(ref result, info.ConfigId); return(result); }
/// <summary> /// release old weapon and create new one /// </summary> /// <param name="weaponSlotAgent"></param> /// <param name="Owner"></param> /// <param name="orient"></param> /// <param name="refreshParams"></param> /// <returns></returns> public override WeaponEntity ReplaceWeapon(EntityKey Owner, WeaponScanStruct orient, ref WeaponPartsRefreshStruct refreshParams) { refreshParams.lastWeaponKey = WeaponKey; ReleaseWeapon(); var newEnity = WeaponEntityFactory.CreateEntity(orient); newEnity.SetRetain(Owner); // DebugUtil.LogInUnity("add new weapon :{0}", DebugUtil.DebugColor.Blue, newEnity.entityKey.Value); if (orient.AvatarId < 1) { orient.AvatarId = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(orient.ConfigId).AvatorId; } WeaponPartsStruct parts = WeaponPartUtil.CreateParts(orient); refreshParams.weaponInfo = orient; refreshParams.slot = handledSlot; refreshParams.oldParts = new WeaponPartsStruct(); refreshParams.newParts = parts; refreshParams.armInPackage = true; return(newEnity); }