/// <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); }
public WeaponBaseAgent(Func <EntityKey> in_holdExtractor, Func <EntityKey> in_emptyExtractor, EWeaponSlotType slot, GrenadeCacheHandler grenadeHandler) { weaponKeyExtractor = in_holdExtractor; emptyKeyExtractor = in_emptyExtractor; handledSlot = slot; }
public static void BindCustomizeWeaponKey(this WeaponBagContainer bagContainer, EntityKey entityKey) { for (EWeaponSlotType i = EWeaponSlotType.None; i < EWeaponSlotType.Length; i++) { bagContainer[i].Remove(entityKey); } }
public bool ReplaceWeaponToSlot(EWeaponSlotType slotType, WeaponInfo weaponInfo) { WeaponInfo lastWp; return(ReplaceWeaponToSlot(slotType, weaponInfo, true, out lastWp)); // return lastWp; }
public virtual void OnWeaponPickup(IPlayerWeaponProcessor controller, EWeaponSlotType slot) { if (controller.AudioController != null) { controller.AudioController.PlaySimpleAudio(EAudioUniqueId.PikcupWeapon); } }
private bool ReplaceCommonWeapon(EWeaponSlotType slotType, WeaponScanStruct orient, int bagIndex) { // if (vertify) if (!processHelper.FilterVailed(orient, slotType)) { return(false); } bool refreshAppearance = true; logger.InfoFormat("replace weapon:{0}: ", orient); //特殊全局性武器只取武器背包第0个索引值 var weaponAgent = GetWeaponAgent(slotType); WeaponPartsRefreshStruct refreshParams = new WeaponPartsRefreshStruct(); WeaponEntity newEntity = weaponAgent.ReplaceWeapon(Owner, orient, ref refreshParams); if (newEntity == null) { return(false); } SyncBagWeapon(slotType, newEntity.entityKey.Value); if (refreshAppearance) { RefreshModelWeaponParts(refreshParams); } return(true); }
public override void DoAction(IEventArgs args) { FreeRuleEventArgs fr = (FreeRuleEventArgs)args; IGameUnit unit = GetPlayer(args); if (unit != null) { PlayerEntity p = ((FreeData)unit).Player; int index = FreeUtil.ReplaceInt(weaponKey, args); EWeaponSlotType currentSlot = p.GetBagLogicImp().GetCurrentWeaponSlot(); if (index > 0) { currentSlot = FreeWeaponUtil.GetSlotType(index); } Debug.LogFormat("remove weapon: " + index); p.playerAction.Logic.DropWeapon(currentSlot); //SimpleProto message = new SimpleProto(); //message.Key = FreeMessageConstant.ChangeAvatar; //message.Ins.Add((int)currentSlot); //message.Ks.Add(6); //p.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message); } }
public static void WeaponToHand(PlayerEntity player, EWeaponSlotType slot) { var pos = WeaponInPackage.EndOfTheWorld; switch (slot) { case EWeaponSlotType.PrimeWeapon: pos = WeaponInPackage.PrimaryWeaponOne; break; case EWeaponSlotType.SecondaryWeapon: pos = WeaponInPackage.PrimaryWeaponTwo; break; case EWeaponSlotType.PistolWeapon: pos = WeaponInPackage.SideArm; break; case EWeaponSlotType.MeleeWeapon: pos = WeaponInPackage.MeleeWeapon; break; case EWeaponSlotType.ThrowingWeapon: pos = WeaponInPackage.ThrownWeapon; break; case EWeaponSlotType.TacticWeapon: pos = WeaponInPackage.TacticWeapon; break; default: break; } player.appearanceInterface.Appearance.MountWeaponToHand(pos); }
public override void Drop(PlayerEntity player, EWeaponSlotType slot, IUserCmd cmd) { if (slot == EWeaponSlotType.ThrowingWeapon) { DoDropGrenade(player, slot, cmd); } }
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 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 Err_WeaponLogicErrCode OnWpDrop(EWeaponSlotType in_slot) { return(OnWpProcess(in_slot, (WeaponSlotBaseHandler controller) => { return controller.OnDrop(); })); }
public static int?GetWeaponInSlot(this PlayerEntity playerEntity, EWeaponSlotType slot) { var weaponBag = playerEntity.GetWeaponBagComponent((EWeaponBagIndex)playerEntity.bagState.CurBag); if (null != weaponBag) { switch (slot) { case EWeaponSlotType.PrimeWeapon: return(weaponBag.PrimeWeapon); case EWeaponSlotType.SecondaryWeapon: return(weaponBag.SecondaryWeapon); case EWeaponSlotType.PistolWeapon: return(weaponBag.PistolWeapon); case EWeaponSlotType.MeleeWeapon: return(weaponBag.MeleeWeapon); case EWeaponSlotType.ThrowingWeapon: return(weaponBag.ThrowingWeapon); case EWeaponSlotType.TacticWeapon: return(weaponBag.TacticWeapon); } } return(null); }
//TODO 保证背包索引和槽位都合法的情况下,一定有武器 public static bool HasWeapon(this PlayerEntity playerEntity, EWeaponSlotType slot) { return(slot > EWeaponSlotType.None && playerEntity.bagState.CurBag > (int)EWeaponBagIndex.None && playerEntity.bagState.CurBag < (int)EWeaponBagIndex.Length && slot < EWeaponSlotType.Length); }
public void RemoveWeapon(EWeaponSlotType slot) { if (_weaponBagLogic.RemoveWeapon(slot)) { OnInterrupt(); } }
/// <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 int GetReservedBullet(Entity entity, EWeaponSlotType slot) { var playerEntity = entity as PlayerEntity; var weaponComp = playerEntity.GetWeaponComponentBySlot(slot); return(weaponComp.ReservedBullet); }
/// <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 void SetReservedBullet(EWeaponSlotType slot, int count) { if (slot.IsSlotWithBullet()) { ModeController.SetReservedBullet(this, slot, count); } }
public int GetReservedBullet(Entity entity, EWeaponSlotType slot) { var playerEntity = entity as PlayerEntity; var caliber = GetCaliber(playerEntity, slot); return(GetReservedBullet(playerEntity, caliber)); }
public bool ReplaceWeaponToSlot(EWeaponSlotType slotType, WeaponInfo weaponInfo, bool vertify = true) { WeaponInfo lastWp; return(ReplaceWeaponToSlot(slotType, weaponInfo, vertify, out lastWp)); // return lastWp; }
public int SetReservedBullet(Entity playerEntity, EWeaponSlotType slot, int count) { var player = playerEntity as PlayerEntity; var caliber = GetCaliber(playerEntity, slot); return(SetReservedBullet(playerEntity, caliber, count)); }
public bool ReplaceWeaponToSlot(EWeaponSlotType slotType, WeaponInfo weaponInfo, bool vertify, out WeaponInfo lastWp) { lastWp = WeaponInfo.Empty; if (vertify) { if (slotType == EWeaponSlotType.None) { return(false); } var weaonCfg = SingletonManager.Get <WeaponConfigManager>().GetConfigById(weaponInfo.Id); if (weaonCfg == null) { return(false); } } var errCode = _weaponBagLogic.AddWeaponToSlot(slotType, weaponInfo, out lastWp); if (errCode == Util.Err_WeaponLogicErrCode.Sucess) { _slotAuxiliary.OnWpStuffEnd(slotType, lastWp.Id); return(true); } else { throw new System.Exception("Add weapon to slot failed"); } return(false); }
public void OnPickup(Entity playerEntity, EWeaponSlotType slot) { var player = playerEntity as PlayerEntity; Logger.DebugFormat("{0} OnPickup", player.entityKey.Value); LockPlayerBag(player); }
public static int Slot2Index(EWeaponSlotType slotType) { switch (slotType) { case EWeaponSlotType.None: return(0); case EWeaponSlotType.PrimeWeapon: case EWeaponSlotType.SecondaryWeapon: return(1); case EWeaponSlotType.PistolWeapon: return(2); case EWeaponSlotType.MeleeWeapon: return(3); case EWeaponSlotType.ThrowingWeapon: return(4); case EWeaponSlotType.TacticWeapon: return(7); default: Logger.ErrorFormat("slot {0} is illegal", slotType); return(0); } }
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 static WeaponInPackage ToWeaponInPackage(this EWeaponSlotType slot) { switch (slot) { case EWeaponSlotType.PrimeWeapon: return(WeaponInPackage.PrimaryWeaponOne); case EWeaponSlotType.SecondaryWeapon: return(WeaponInPackage.PrimaryWeaponTwo); case EWeaponSlotType.PistolWeapon: return(WeaponInPackage.SideArm); case EWeaponSlotType.MeleeWeapon: return(WeaponInPackage.MeleeWeapon); case EWeaponSlotType.ThrowingWeapon: return(WeaponInPackage.ThrownWeapon); case EWeaponSlotType.TacticWeapon: return(WeaponInPackage.TacticWeapon); default: return(WeaponInPackage.ThrownWeapon); } }
/// <summary> /// wewapon from body to hand /// </summary> public virtual Err_WeaponLogicErrCode OnSwitchIn(EWeaponSlotType from, System.Action <EWeaponSlotType, int> onSameSpeciesSwitch) { var slot = _weapon.GetSlotType(); if (_weapon.Id < 1) { if (Logger.IsDebugEnabled) { Logger.DebugFormat("no weapon in slot {0}", slot); } return(Err_WeaponLogicErrCode.Err_IdNotExisted); } if (slot == from) { // 如果要切换到的位置和当前位置一致不作处理 return(Err_WeaponLogicErrCode.Err_SameWeaponPosition); } // 如果切换到的位置有枪,设置当前武器 if (_weapon.Id > 0) { _playerWeaponActionLogic.DrawWeapon(slot); return(Err_WeaponLogicErrCode.Sucess); // Core.Audio.GameAudioMedium.PerformOnGunSwitch(_weapon.Id); // _playerSoundManager.PlayOnce(XmlConfig.EPlayerSoundType.ChangeWeapon); } return(Err_WeaponLogicErrCode.Err_Default); }
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); }
public static WeaponInPackage ToWeaponInPackage(this EWeaponSlotType slot) { switch (slot) { case EWeaponSlotType.PrimeWeapon1: return(WeaponInPackage.PrimaryWeaponOne); case EWeaponSlotType.PrimeWeapon2: return(WeaponInPackage.PrimaryWeaponTwo); case EWeaponSlotType.SubWeapon: return(WeaponInPackage.SideArm); case EWeaponSlotType.MeleeWeapon: return(WeaponInPackage.MeleeWeapon); case EWeaponSlotType.GrenadeWeapon: return(WeaponInPackage.ThrownWeapon); case EWeaponSlotType.TacticWeapon: return(WeaponInPackage.TacticWeapon); default: Logger.ErrorFormat("slot {0} is illegal for weapon ", slot); return(WeaponInPackage.ThrownWeapon); } }