private void CallOnIdle(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd) { foreach (var fireIdle in _idles) { fireIdle.OnIdle(weaponBaseAgent, cmd); } }
private void CallOnFrame(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd) { foreach (var frame in _frames) { frame.OnFrame(weaponBaseAgent, cmd); } }
private void CallAfterFires(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd) { foreach (var afterfire in _afterFireProcessors) { afterfire.OnAfterFire(weaponBaseAgent, cmd); } }
public void OnAfterFire(WeaponBaseAgent heldBaseAgent, WeaponSideCmd cmd) { if (heldBaseAgent.BaseComponent.RealFireModel != (int)EFireMode.Burst) { return; } var runTimeComponent = heldBaseAgent.RunTimeComponent; runTimeComponent.NeedAutoBurstShoot = false; var config = heldBaseAgent.DefaultFireModeLogicCfg; runTimeComponent.BurstShootCount += 1; float intervalFactor = 1 - heldBaseAgent.GetAttachedAttributeByType(WeaponAttributeType.AttackInterval) / 100; if (runTimeComponent.BurstShootCount < config.BurstCount) { runTimeComponent.NextAttackTimestamp = cmd.UserCmd.RenderTime + Mathf.CeilToInt(config.BurstAttackInnerInterval * intervalFactor); runTimeComponent.NeedAutoBurstShoot = true; runTimeComponent.IsPrevCmdFire = true; } else { runTimeComponent.NextAttackTimestamp = cmd.UserCmd.RenderTime + Mathf.CeilToInt(config.BurstAttackInterval * intervalFactor); runTimeComponent.BurstShootCount = 0; } if (heldBaseAgent.BaseComponent.Bullet == 0) { runTimeComponent.BurstShootCount = 0; } }
private float CalculateRotationDegree(WeaponBaseAgent agent, ShakeInfoStruct dirShakeArgs) { switch (agent.WeaponConfigAssy.NewWeaponCfg.Type) { case 1: return(dirShakeArgs.UpBase * 1.5f); case 2: return(dirShakeArgs.UpBase * 2f); case 3: return(dirShakeArgs.UpBase * 1.3f); case 4: return(dirShakeArgs.UpBase * 1.5f); case 5: return(dirShakeArgs.UpBase * 2f); case 6: return(dirShakeArgs.UpBase); default: return(0); } }
protected override void Update(WeaponBaseAgent heldBaseAgent, WeaponSideCmd cmd) { var config = heldBaseAgent.FixedSpreadLogicCfg; var runTimeComponent = heldBaseAgent.RunTimeComponent; FireSpreadFormula.ApplyFixedFinalSpread(config.Value, config.SpreadScale, runTimeComponent); }
private void CallBeforeFires(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd) { foreach (var beforeFire in _beforeFireProcessors) { beforeFire.OnBeforeFire(weaponBaseAgent, cmd); } }
//以当前0.5X+10速度衰减 public virtual float UpdateLen(WeaponBaseAgent agent, float len, float frameSec) { var r = len; r -= (10f + r * 0.5f) * frameSec; r = Mathf.Max(r, 0f); return(r); }
protected override void Update(WeaponBaseAgent heldBaseAgent, WeaponSideCmd cmd) { var config = heldBaseAgent.PistolSpreadLogicCfg; var weaponRuntime = heldBaseAgent.RunTimeComponent; float spreadScaleFactor = FireSpreadProvider.GetSpreadScaleFactor(config, heldBaseAgent.Owner.WeaponController()); FireSpreadFormula.ApplyPistolFinalSpread(spreadScaleFactor, config.SpreadScale, weaponRuntime); }
protected override void Update(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd) { SniperSpreadLogicConfig config = weaponBaseAgent.SniperSpreadLogicCfg; var runTimeComponent = weaponBaseAgent.RunTimeComponent; float spread = FireSpreadProvider.GetSpreadScaleFactor(config, weaponBaseAgent.Owner.WeaponController()); FireSpreadFormula.ApplyFixedFinalSpread(spread, config.SpreadScale, runTimeComponent); }
public override void OnAfterFire(WeaponBaseAgent agent, WeaponSideCmd cmd) { var weaponController = agent.Owner.WeaponController(); var config = agent.RifleShakeCfg; var shakeGroup = FireShakeProvider.GetShakeGroup(config, weaponController); var shakeInfo = FireShakeProvider.GetShakeInfo(config, weaponController, shakeGroup); CalcBaseShake(agent, cmd.UserCmd.Seq, shakeInfo); }
public override float UpdateLen(WeaponBaseAgent agent, float len, float frameTime) { var r = len; r -= (agent.RifleShakeCfg.FixedDecayFactor + r * agent.RifleShakeCfg.LenDecayFactor) * frameTime; r = Mathf.Max(r, 0f); return(r); }
public override void DoAction(IEventArgs args) { FreeRuleEventArgs fr = (FreeRuleEventArgs)args; IGameUnit unit = GetPlayer(args); if (unit != null) { PlayerEntity p = ((FreeData)unit).Player; int itemId = FreeUtil.ReplaceInt(weaponId, args); int index = FreeUtil.ReplaceInt(weaponKey, args); EWeaponSlotType st = FreeWeaponUtil.GetSlotType(index); WeaponBaseAgent agent = null; if (index == 0) { agent = p.WeaponController().HeldWeaponAgent; } else { agent = p.WeaponController().GetWeaponAgent(st); } if (agent != null && agent.IsValid() && !FreeUtil.ReplaceBool(replace, args)) { return; } var scan = WeaponUtil.CreateScan(itemId); if (FreeUtil.ReplaceBool(fullAmmo, args)) { var weaponAllConfig = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(itemId); scan.Bullet = weaponAllConfig.PropertyCfg.Bullet; scan.ReservedBullet = weaponAllConfig.PropertyCfg.Bulletmax; } if (index == 0) { p.WeaponController().PickUpWeapon(scan); } else { p.WeaponController().ReplaceWeaponToSlot(st, scan); if (p.stateInterface.State.CanDraw() && p.WeaponController().HeldSlotType == EWeaponSlotType.None) { p.WeaponController().TryArmWeaponImmediately(st); } } SimpleProto message = new SimpleProto(); message.Key = FreeMessageConstant.PlaySound; message.Ks.Add(2); message.Ins.Add((int)EAudioUniqueId.PickupWeapon); message.Bs.Add(true); FreeMessageSender.SendMessage(p, message); } }
public void OnIdle(WeaponBaseAgent agent, WeaponSideCmd cmd) { if (!cmd.IsFire) { var audioController = agent.Owner.AudioController(); if (audioController != null) { audioController.StopFireTrigger(); } DoIdle(agent.Owner.WeaponController(), cmd); } }
public void OnFrame(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd) { if (!cmd.IsFire) { weaponBaseAgent.RunTimeComponent.IsPrevCmdFire = false; var audioController = weaponBaseAgent.Owner.AudioController(); if (audioController != null) { audioController.StopFireTrigger(); } } }
public void OnBeforeFire(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd) { if (weaponBaseAgent.RifleFireCounterCfg == null) { return; } var runTimeComponent = weaponBaseAgent.RunTimeComponent; // runTimeComponent.NeedReduceContinuesShootCD = true; runTimeComponent.ContinuesShootCount = Mathf.Min(++runTimeComponent.ContinuesShootCount, weaponBaseAgent.RifleFireCounterCfg.MaxCount); runTimeComponent.ContinuesShootReduceTimestamp = cmd.UserCmd.RenderTime + weaponBaseAgent.RifleFireCounterCfg.DecreaseInitInterval; }
public static ShakeInfoStruct GetFireUpDirShakeArgs(WeaponBaseAgent heldAgent, ShakeInfo shakeInfo) { var newInfo = (ShakeInfoStruct)shakeInfo; float factor = heldAgent.GetAttachedAttributeByType(WeaponAttributeType.UpBase); if (factor != 0f) { newInfo.UpBase *= factor; } // logger.Info("Shoot Shake factor:"+factor); factor = heldAgent.GetAttachedAttributeByType(WeaponAttributeType.UpMax); if (factor != 0f) { newInfo.UpMax *= factor; } factor = heldAgent.GetAttachedAttributeByType(WeaponAttributeType.UpModifier); if (factor != 0f) { newInfo.UpModifier *= factor; } factor = heldAgent.GetAttachedAttributeByType(WeaponAttributeType.LateralBase); if (factor != 0f) { newInfo.LateralBase *= factor; } factor = heldAgent.GetAttachedAttributeByType(WeaponAttributeType.LateralMax); if (factor != 0f) { newInfo.LateralMax *= factor; } factor = heldAgent.GetAttachedAttributeByType(WeaponAttributeType.LateralModifier); if (factor != 0f) { newInfo.LateralModifier *= factor; } factor = heldAgent.GetAttachedAttributeByType(WeaponAttributeType.LateralTurnback); if (factor != 0f) { newInfo.LateralTurnback *= factor; } return(newInfo); }
public override void OnAfterFire(WeaponBaseAgent agent, WeaponSideCmd cmd) { var config = agent.FixedShakeCfg; if (null == config) { return; } var orientation = agent.Owner.WeaponController().RelatedOrientation; orientation.AccPunchPitch += config.PunchPitch; orientation.AccPunchPitchValue += config.PunchPitch * config.PunchOffsetFactor; }
public void OnIdle(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd) { var runTimeComponent = weaponBaseAgent.RunTimeComponent; if (runTimeComponent.ContinuesShootCount == 0) { var config = weaponBaseAgent.PistolAccuracyLogicCfg; if (config == null) { return; } runTimeComponent.Accuracy = config.InitAccuracy; } }
public override void OnAfterFire(WeaponBaseAgent weaponAgent, WeaponSideCmd cmd) { weaponAgent.RunTimeComponent.PullBoltFinish = false; var weaponData = weaponAgent.BaseComponent; if (weaponData.Bullet > 0) { var needActionDeal = SingletonManager.Get <WeaponResourceConfigManager>() .NeedActionDeal(weaponData.ConfigId, ActionDealEnum.Reload); SpecialFireAppearance(weaponAgent.Owner.WeaponController(), needActionDeal); } else { base.OnAfterFire(weaponAgent, cmd); } }
public void OnAfterFire(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd) { if ((EFireMode)weaponBaseAgent.BaseComponent.RealFireModel == EFireMode.Burst) { return; } var runtimeDataComponent = weaponBaseAgent.RunTimeComponent; runtimeDataComponent.IsPrevCmdFire = true; float intervalFactor = 1 - weaponBaseAgent.GetAttachedAttributeByType(WeaponAttributeType.AttackInterval) / 100; runtimeDataComponent.NextAttackTimestamp = cmd.UserCmd.RenderTime + Mathf.CeilToInt(weaponBaseAgent.CommonFireCfg.AttackInterval * intervalFactor); runtimeDataComponent.NeedAutoBurstShoot = false; runtimeDataComponent.ContinuesShootCount = 0; runtimeDataComponent.LastAttackTimestamp = cmd.UserCmd.RenderTime; }
public virtual void OnAfterFire(WeaponBaseAgent agent, WeaponSideCmd cmd) { var weaponController = agent.Owner.WeaponController(); var relatedCharState = weaponController.RelatedCharState; if (relatedCharState != null) { if (weaponController.RelatedCameraSNew.IsAiming()) { relatedCharState.SightsFire(); } else { relatedCharState.Fire(); } } }
public void OnBeforeFire(WeaponBaseAgent weaponBaseAgent, WeaponSideCmd cmd) { var runTimeComponent = weaponBaseAgent.RunTimeComponent; if (runTimeComponent.LastAttackTimestamp == 0) { } else { var config = weaponBaseAgent.PistolAccuracyLogicCfg; if (config == null) { return; } runTimeComponent.Accuracy = AccuracyFormula.GetPistolAccuracy(cmd.UserCmd.RenderTime - runTimeComponent.LastAttackTimestamp, config.AccuracyFactor, config.MinAccuracy, config.MaxAccuracy); } }
public void OnIdle(WeaponBaseAgent heldAgent, WeaponSideCmd cmd) { if (heldAgent.RifleFireCounterCfg == null) { return; } if (heldAgent.RunTimeComponent.ContinuesShootCount < 1) { return; } if (heldAgent.RunTimeComponent.ContinuesShootReduceTimestamp < cmd.UserCmd.RenderTime) { // DebugUtil.MyLog("Count -- ||DecreaseStepInterval:"+heldAgent.RifleFireCounterCfg.DecreaseStepInterval+"||"+heldAgent.RifleFireCounterCfg.DecreaseStepInterval); heldAgent.RunTimeComponent.ContinuesShootReduceTimestamp = cmd.UserCmd.RenderTime + heldAgent.RifleFireCounterCfg.DecreaseStepInterval; --heldAgent.RunTimeComponent.ContinuesShootCount; } }
public override void OnFrame(WeaponBaseAgent agent, WeaponSideCmd cmd) { var weaponController = agent.Owner.WeaponController(); ShakeGroup shakeGroup = FireShakeProvider.GetShakeGroup(agent.RifleShakeCfg, weaponController); var runTimeComponent = agent.RunTimeComponent; int frameInterval = cmd.UserCmd.FrameInterval; var orient = weaponController.RelatedOrientation; //后坐力生效时间 if (runTimeComponent.PunchDecayLeftInterval > 0) { float totalInterval = FireShakeProvider.GetDecayInterval(agent); float lastInterval = runTimeComponent.PunchDecayLeftInterval; runTimeComponent.PunchDecayLeftInterval -= frameInterval; float newInterval = runTimeComponent.PunchDecayLeftInterval; var lastPunchPitch = FireShakeFormula.EaseOutCubic(0, runTimeComponent.TargetPunchPitchDelta, (totalInterval - lastInterval) / totalInterval); var newPunchPitch = FireShakeFormula.EaseOutCubic(0, runTimeComponent.TargetPunchPitchDelta, (totalInterval - newInterval) / totalInterval); orient.AccPunchPitch += newPunchPitch - lastPunchPitch; orient.AccPunchPitchValue = orient.AccPunchPitch * shakeGroup.VPunchOffsetFactor; var deltaTime = cmd.UserCmd.RenderTime - runTimeComponent.LastRenderTimestamp; orient.AccPunchYaw += runTimeComponent.PunchYawSpeed * deltaTime; orient.AccPunchYawValue = orient.AccPunchYaw * shakeGroup.HPunchOffsetFactor; orient.FireRoll += runTimeComponent.CameraRotationSpeed * frameInterval; if (GlobalConst.EnableWeaponLog) { DebugUtil.MyLog(("orient.AccPunchPitch:" + orient.AccPunchPitch)); } } else { UpdateOrientationAttenuation(agent, cmd); } base.OnFrame(agent, cmd); }
public static bool CanDemountAttachment(ServerRoom room, FreeData fd, FreeItemInfo part, string ipStr, bool toGround) { double capacity = Math.Round(GetCapacity(fd) - GetWeight(fd), 3); float bulletWeight = 0f; WeaponBaseAgent agent = fd.Player.WeaponController().GetWeaponAgent((EWeaponSlotType)short.Parse(ipStr.Substring(1, 1))); int overBullet = 0; if (SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(WeaponPartUtil.GetWeaponFstMatchedPartId(part.id, agent.ConfigId)).Bullet > 0) { overBullet = agent.BaseComponent.Bullet - agent.WeaponConfigAssy.PropertyCfg.Bullet; if (overBullet > 0) { bulletWeight = SingletonManager.Get <GameItemConfigManager>().GetConfigById((int)agent.Caliber).Weight *overBullet; } } var partWeight = 0f; if (!toGround) { partWeight = part.weight; } if (capacity < bulletWeight + partWeight) { SimpleProto msg = FreePool.Allocate(); msg.Key = FreeMessageConstant.ChickenTip; msg.Ss.Add("word79"); FreeMessageSender.SendMessage(fd.Player, msg); return(false); } if (overBullet > 0) { agent.BaseComponent.Bullet = agent.WeaponConfigAssy.PropertyCfg.Bullet; CarryClipUtil.AddClip(overBullet, (int)agent.Caliber, fd, room.ContextsWrapper.FreeArgs); fd.Player.WeaponController().SetReservedBullet(agent.Caliber, CarryClipUtil.GetClipCount((int)agent.Caliber, fd, room.ContextsWrapper.FreeArgs)); } return(true); }
public bool IsCanFire(PlayerWeaponController controller, IWeaponCmd weaponCmd) { WeaponBaseAgent weaponAgent = controller.HeldWeaponAgent; if (weaponCmd.RenderTime < weaponAgent.RunTimeComponent.NextAttackTimestamp) { return(false); } if (weaponAgent.BaseComponent.Bullet <= 0) { controller.ShowTip(ETipType.FireWithNoBullet); return(false); } EFireMode currentMode = (EFireMode)weaponAgent.BaseComponent.RealFireModel; if (currentMode == EFireMode.Manual) { if (weaponAgent.RunTimeComponent.IsPrevCmdFire) { return(false); } else { return(true); } } else if (currentMode == EFireMode.Auto) { return(true); } else if (currentMode == EFireMode.Burst) { return(true); // _config.BurstCount; } else { return(false); } }
private void UpdateAccurcy(WeaponBaseAgent weaponBaseAgent) { var config = weaponBaseAgent.BaseAccuracyLogicCfg; if (config == null) { return; } var runTimeComponent = weaponBaseAgent.RunTimeComponent; int accuracyDivisor = config.AccuracyDivisor; //除数因子 if (accuracyDivisor != -1) { runTimeComponent.Accuracy = AccuracyFormula.GetCommonAccuracy(config.MaxInaccuracy, runTimeComponent.ContinuesShootCount, config.AccuracyDivisor, config.AccuracyOffset); } else { runTimeComponent.Accuracy = 0; } }
protected void UpdateOrientationAttenuation(WeaponBaseAgent agent, WeaponSideCmd cmd) { var orientation = agent.Owner.WeaponController().RelatedOrientation; var punchYaw = orientation.AccPunchYaw; var punchPitch = orientation.AccPunchPitch; var frameSec = cmd.UserCmd.FrameInterval / 1000f; //获取向量长度 var puntchLength = Mathf.Sqrt(punchYaw * punchYaw + punchPitch * punchPitch); if (puntchLength > 0) { punchYaw = punchYaw / puntchLength; punchPitch = punchPitch / puntchLength; puntchLength = UpdateLen(agent, puntchLength, frameSec); //UpdateLen: AccPunchYaw =>AccPunchYaw orientation.AccPunchYaw = punchYaw * puntchLength; orientation.AccPunchPitch = punchPitch * puntchLength; var factor = GePuntchFallbackFactor(agent.Owner.WeaponController()); //GePuntchFallbackFactor : AccPunchYaw => AccPunchPitch orientation.AccPunchYawValue = orientation.AccPunchYaw * factor; orientation.AccPunchPitchValue = orientation.AccPunchPitch * factor; } var rotateYaw = orientation.FireRoll; if (rotateYaw != 0) { var rotatePos = rotateYaw >= 0; rotateYaw -= rotateYaw * cmd.UserCmd.FrameInterval / FireShakeProvider.GetDecayInterval(agent); if ((rotatePos && rotateYaw < 0) || (!rotatePos && rotateYaw > 0)) { rotateYaw = 0; } orientation.FireRoll = rotateYaw; } }
public virtual bool IsCanFire(PlayerWeaponController controller, WeaponSideCmd cmd) { WeaponBaseAgent weaponAgent = controller.HeldWeaponAgent; if (cmd.UserCmd.RenderTime < weaponAgent.RunTimeComponent.NextAttackTimestamp) { return(false); } if (weaponAgent.BaseComponent.Bullet <= 0) { controller.ShowTip(ETipType.FireWithNoBullet); if (cmd.FiltedInput(EPlayerInput.IsLeftAttack) && controller.AudioController != null) { controller.AudioController.PlayEmptyFireAudio(); } return(false); } EFireMode currentMode = (EFireMode)weaponAgent.BaseComponent.RealFireModel; switch (currentMode) { case EFireMode.Manual: return(!weaponAgent.RunTimeComponent.IsPrevCmdFire); case EFireMode.Auto: return(true); case EFireMode.Burst: return(!weaponAgent.RunTimeComponent.IsPrevCmdFire || weaponAgent.RunTimeComponent.NeedAutoBurstShoot); default: return(false); } }