private void StartComps() { for (int i = 0; i < CompsToStart.Count; i++) { var weaponComp = CompsToStart[i]; if (weaponComp.MyCube.CubeGrid.IsPreview || CompRestricted(weaponComp)) { PlatFormPool.Return(weaponComp.Platform); weaponComp.Platform = null; CompsToStart.Remove(weaponComp); continue; } if (weaponComp.MyCube.CubeGrid.Physics == null && !weaponComp.MyCube.CubeGrid.MarkedForClose && weaponComp.MyCube.BlockDefinition.HasPhysics) { continue; } QuickDisableGunsCheck = true; if (weaponComp.Platform.State == MyWeaponPlatform.PlatformState.Fresh) { if (weaponComp.MyCube.MarkedForClose) { CompsToStart.Remove(weaponComp); continue; } if (!GridToInfoMap.ContainsKey(weaponComp.MyCube.CubeGrid)) { continue; } if (ShieldApiLoaded) { SApi.AddAttacker(weaponComp.MyCube.EntityId); } IdToCompMap[weaponComp.MyCube.EntityId] = weaponComp; weaponComp.MyCube.Components.Add(weaponComp); CompsToStart.Remove(weaponComp); } else { Log.Line($"comp didn't match CompsToStart condition, removing"); CompsToStart.Remove(weaponComp); } } CompsToStart.ApplyRemovals(); }
internal void PurgeAll() { FutureEvents.Purge((int)Tick); PurgeTerminalSystem(); foreach (var reports in Reporter.ReportData.Values) { foreach (var report in reports) { report.Clean(); Reporter.ReportPool.Return(report); } reports.Clear(); } Reporter.ReportData.Clear(); Reporter.ReportPool.Clean(); PacketsToClient.Clear(); PacketsToServer.Clear(); foreach (var suit in (PacketType[])Enum.GetValues(typeof(PacketType))) { foreach (var pool in PacketPools.Values) { pool.Clean(); } PacketPools.Clear(); } foreach (var item in _effectedCubes) { var cubeid = item.Key; var blockInfo = item.Value; var functBlock = blockInfo.FunctBlock; var cube = blockInfo.CubeBlock; if (cube == null || cube.MarkedForClose) { _effectPurge.Enqueue(cubeid); continue; } functBlock.EnabledChanged -= ForceDisable; functBlock.Enabled = blockInfo.FirstState; cube.SetDamageEffect(false); _effectPurge.Enqueue(cubeid); } while (_effectPurge.Count != 0) { _effectedCubes.Remove(_effectPurge.Dequeue()); } Av.Glows.Clear(); Av.AvShotPool.Clean(); DeferedUpBlockTypeCleanUp(true); BlockTypeCleanUp.Clear(); foreach (var map in GridToFatMap.Keys) { RemoveGridFromMap(map); } GridToFatMap.Clear(); FatMapPool.Clean(); DirtyGridsTmp.Clear(); foreach (var structure in WeaponPlatforms.Values) { foreach (var system in structure.WeaponSystems) { foreach (var ammo in system.Value.WeaponAmmoTypes) { ammo.AmmoDef.Const.PrimeEntityPool?.Clean(); } } structure.WeaponSystems.Clear(); } WeaponPlatforms.Clear(); foreach (var gridToMap in GridToBlockTypeMap) { foreach (var map in gridToMap.Value) { map.Value.ClearImmediate(); ConcurrentListPool.Return(map.Value); } gridToMap.Value.Clear(); BlockTypePool.Return(gridToMap.Value); } GridToBlockTypeMap.Clear(); foreach (var playerGrids in PlayerEntityIdInRange) { playerGrids.Value.Clear(); } PlayerEntityIdInRange.Clear(); DirtyGrids.Clear(); DsUtil.Purge(); DsUtil2.Purge(); _effectActive = false; ShootingWeapons.Clear(); AcquireTargets.Clear(); RemoveEffectsFromGrid.Clear(); WeaponAmmoPullQueue.Clear(); AmmoToPullQueue.Clear(); Hits.Clear(); AllArmorBaseDefinitions.Clear(); HeavyArmorBaseDefinitions.Clear(); AllArmorBaseDefinitions.Clear(); AcquireTargets.Clear(); ChargingWeapons.Clear(); LargeBlockSphereDb.Clear(); SmallBlockSphereDb.Clear(); AnimationsToProcess.Clear(); _subTypeIdToWeaponDefs.Clear(); WeaponDefinitions.Clear(); SlimsSortedList.Clear(); _destroyedSlims.Clear(); _destroyedSlimsClient.Clear(); _slimHealthClient.Clear(); _slimsSet.Clear(); _turretDefinitions.Clear(); foreach (var comp in CompsToStart) { PlatFormPool.Return(comp.Platform); comp.Platform = null; } foreach (var readd in CompReAdds) { PlatFormPool.Return(readd.Comp.Platform); readd.Comp.Platform = null; } foreach (var comp in CompsDelayed) { PlatFormPool.Return(comp.Platform); comp.Platform = null; } PlatFormPool.Clean(); CompsToStart.ClearImmediate(); CompsDelayed.Clear(); CompReAdds.Clear(); GridAiPool.Clean(); Av.RipMap.Clear(); foreach (var mess in Av.KeensBrokenParticles) { Av.KeenMessPool.Return(mess); } Av.KeensBrokenParticles.Clear(); foreach (var av in Av.AvShots) { av.GlowSteps.Clear(); Av.AvShotPool.Return(av); } Av.AvShotPool.Clean(); Av.AvBarrels1.Clear(); Av.AvBarrels2.Clear(); Av.AvShots.Clear(); Av.HitSounds.Clear(); foreach (var errorpkt in ClientSideErrorPktList) { errorpkt.Packet.CleanUp(); } ClientSideErrorPktList.Clear(); GridEffectPool.Clean(); GridEffectsPool.Clean(); BlockTypePool.Clean(); ConcurrentListPool.Clean(); GroupInfoPool.Clean(); TargetInfoPool.Clean(); Projectiles.Clean(); WeaponCoreBlockDefs.Clear(); VanillaIds.Clear(); VanillaCoreIds.Clear(); WeaponCoreFixedBlockDefs.Clear(); WeaponCoreTurretBlockDefs.Clear(); foreach (var p in Projectiles.ProjectilePool) { p.AmmoEffect?.Stop(); } Projectiles.ShrapnelToSpawn.Clear(); Projectiles.ShrapnelPool.Clean(); Projectiles.FragmentPool.Clean(); Projectiles.ActiveProjetiles.ApplyChanges(); Projectiles.ActiveProjetiles.Clear(); Projectiles.ProjectilePool.Clear(); Projectiles.HitEntityPool.Clean(); Projectiles.CleanUp.Clear(); Projectiles.VirtInfoPool.Clean(); DbsToUpdate.Clear(); GridTargetingAIs.Clear(); DsUtil = null; DsUtil2 = null; SlimsSortedList = null; Enforced = null; StallReporter = null; Proccessor = null; Physics = null; Camera = null; Projectiles = null; TrackingAi = null; UiInput = null; TargetUi = null; Placer = null; WheelUi = null; TargetGps = null; SApi.Unload(); SApi = null; Api = null; ApiServer = null; Reporter = null; WeaponDefinitions = null; AnimationsToProcess = null; ProjectileTree.Clear(); ProjectileTree = null; Av = null; HudUi = null; AllDefinitions = null; SoundDefinitions = null; ActiveCockPit = null; ActiveControlBlock = null; ControlledEntity = null; }
internal void PurgeAll() { PurgedAll = true; FutureEvents.Purge((int)Tick); foreach (var comp in CompsToStart) { if (comp?.Platform != null) { CloseComps(comp.MyCube); } } foreach (var readd in CompReAdds) { if (!readd.Ai.Closed) { readd.Ai.AiForceClose(); } if (readd.Comp?.Platform != null) { CloseComps(readd.Comp.MyCube); } } foreach (var comp in CompsDelayed) { if (comp?.Platform != null) { CloseComps(comp.MyCube); } } foreach (var gridAi in DelayedAiClean) { if (!gridAi.Closed) { gridAi.AiForceClose(); } } PlatFormPool.Clean(); CompsToStart.ClearImmediate(); DelayedAiClean.ClearImmediate(); CompsDelayed.Clear(); CompReAdds.Clear(); GridAiPool.Clean(); PurgeTerminalSystem(this); HudUi.Purge(); TerminalMon.Purge(); foreach (var reports in Reporter.ReportData.Values) { foreach (var report in reports) { report.Clean(); Reporter.ReportPool.Return(report); } reports.Clear(); } Reporter.ReportData.Clear(); Reporter.ReportPool.Clean(); PacketsToClient.Clear(); PacketsToServer.Clear(); AcqManager.Clean(); CleanSounds(true); foreach (var e in Emitters) { e.StopSound(true); } foreach (var e in Av.HitEmitters) { e.StopSound(true); } foreach (var e in Av.FireEmitters) { e.StopSound(true); } foreach (var e in Av.TravelEmitters) { e.StopSound(true); } Emitters.Clear(); Av.HitEmitters.Clear(); Av.FireEmitters.Clear(); Av.TravelEmitters.Clear(); foreach (var item in EffectedCubes) { var cubeid = item.Key; var blockInfo = item.Value; var functBlock = blockInfo.FunctBlock; if (functBlock == null || functBlock.MarkedForClose) { _effectPurge.Enqueue(cubeid); continue; } functBlock.EnabledChanged -= ForceDisable; functBlock.Enabled = blockInfo.FirstState; functBlock.SetDamageEffect(false); if (HandlesInput) { functBlock.AppendingCustomInfo -= blockInfo.AppendCustomInfo; } _effectPurge.Enqueue(cubeid); } while (_effectPurge.Count != 0) { EffectedCubes.Remove(_effectPurge.Dequeue()); } Av.Glows.Clear(); Av.AvShotPool.Clean(); DeferedUpBlockTypeCleanUp(true); BlockTypeCleanUp.Clear(); foreach (var map in GridToInfoMap.Keys) { RemoveGridFromMap(map); } GridToInfoMap.Clear(); GridMapPool.Clean(); DirtyGridsTmp.Clear(); foreach (var structure in WeaponPlatforms.Values) { foreach (var system in structure.WeaponSystems) { system.Value.PreFirePairs.Clear(); system.Value.FireWhenDonePairs.Clear(); system.Value.FirePerShotPairs.Clear(); system.Value.RotatePairs.Clear(); system.Value.ReloadPairs.Clear(); foreach (var ammo in system.Value.AmmoTypes) { ammo.AmmoDef.Const.PrimeEntityPool?.Clean(); ammo.AmmoDef.Const.HitDefaultSoundPairs.Clear(); ammo.AmmoDef.Const.HitVoxelSoundPairs.Clear(); ammo.AmmoDef.Const.HitShieldSoundPairs.Clear(); ammo.AmmoDef.Const.HitFloatingSoundPairs.Clear(); ammo.AmmoDef.Const.HitPlayerSoundPairs.Clear(); ammo.AmmoDef.Const.TravelSoundPairs.Clear(); ammo.AmmoDef.Const.CustomSoundPairs.Clear(); } } structure.WeaponSystems.Clear(); } WeaponPlatforms.Clear(); foreach (var gridToMap in GridToBlockTypeMap) { foreach (var map in gridToMap.Value) { ConcurrentListPool.Return(map.Value); } gridToMap.Value.Clear(); BlockTypePool.Return(gridToMap.Value); } GridToBlockTypeMap.Clear(); foreach (var playerGrids in PlayerEntityIdInRange) { playerGrids.Value.Clear(); } PlayerEntityIdInRange.Clear(); DirtyGridInfos.Clear(); DsUtil.Purge(); DsUtil2.Purge(); ShootingWeapons.Clear(); WeaponToPullAmmo.Clear(); AmmoToPullQueue.Clear(); ChargingWeaponsIndexer.Clear(); WeaponsToRemoveAmmoIndexer.Clear(); ChargingWeapons.Clear(); Hits.Clear(); HomingWeapons.Clear(); GridToMasterAi.Clear(); Players.Clear(); IdToCompMap.Clear(); AllArmorBaseDefinitions.Clear(); HeavyArmorBaseDefinitions.Clear(); AllArmorBaseDefinitions.Clear(); AcquireTargets.Clear(); LargeBlockSphereDb.Clear(); SmallBlockSphereDb.Clear(); AnimationsToProcess.Clear(); _subTypeIdToWeaponDefs.Clear(); WeaponDefinitions.Clear(); SlimsSortedList.Clear(); _destroyedSlims.Clear(); _destroyedSlimsClient.Clear(); _slimHealthClient.Clear(); _slimsSet.Clear(); _turretDefinitions.Clear(); _tmpNearByBlocks.Clear(); foreach (var av in Av.AvShots) { av.GlowSteps.Clear(); Av.AvShotPool.Return(av); } Av.AvShotPool.Clean(); Av.AvBarrels1.Clear(); Av.AvBarrels2.Clear(); Av.AvShots.Clear(); Av.HitSounds.Clear(); foreach (var errorpkt in ClientSideErrorPkt) { errorpkt.Packet.CleanUp(); } ClientSideErrorPkt.Clear(); GridEffectPool.Clean(); GridEffectsPool.Clean(); BlockTypePool.Clean(); ConcurrentListPool.Clean(); TargetInfoPool.Clean(); PacketObjPool.Clean(); InventoryMoveRequestPool.Clean(); WeaponCoreBlockDefs.Clear(); VanillaIds.Clear(); VanillaCoreIds.Clear(); WeaponCoreFixedBlockDefs.Clear(); WeaponCoreTurretBlockDefs.Clear(); VoxelCaches.Clear(); ArmorCubes.Clear(); foreach (var p in Projectiles.ProjectilePool) { p.Info?.AvShot?.AmmoEffect?.Stop(); } Projectiles.ShrapnelToSpawn.Clear(); Projectiles.ShrapnelPool.Clean(); Projectiles.FragmentPool.Clean(); Projectiles.ActiveProjetiles.Clear(); Projectiles.ProjectilePool.Clear(); Projectiles.HitEntityPool.Clean(); Projectiles.VirtInfoPool.Clean(); DbsToUpdate.Clear(); GridTargetingAIs.Clear(); DsUtil = null; DsUtil2 = null; SlimsSortedList = null; Settings = null; StallReporter = null; TerminalMon = null; Physics = null; Camera = null; Projectiles = null; TrackingAi = null; UiInput = null; TargetUi = null; Placer = null; TargetGps = null; SApi.Unload(); SApi = null; Api = null; ApiServer = null; Reporter = null; WeaponDefinitions = null; AnimationsToProcess = null; ProjectileTree.Clear(); ProjectileTree = null; Av = null; HudUi = null; AllDefinitions = null; SoundDefinitions = null; ActiveCockPit = null; ActiveControlBlock = null; ControlledEntity = null; TmpStorage = null; }
internal void Timings() { _paused = false; Tick = (uint)(Session.ElapsedPlayTime.TotalMilliseconds * TickTimeDiv); Tick10 = Tick % 10 == 0; Tick20 = Tick % 20 == 0; Tick60 = Tick % 60 == 0; Tick120 = Tick % 120 == 0; Tick180 = Tick % 180 == 0; Tick300 = Tick % 300 == 0; Tick600 = Tick % 600 == 0; Tick1800 = Tick % 1800 == 0; Tick3600 = Tick % 3600 == 0; if (Tick60) { if (Av.ExplosionCounter - 5 >= 0) { Av.ExplosionCounter -= 5; } else { Av.ExplosionCounter = 0; } } if (++SCount == 60) { SCount = 0; } if (Count++ == 119) { Count = 0; UiBkOpacity = MyAPIGateway.Session.Config.UIBkOpacity; UiOpacity = MyAPIGateway.Session.Config.UIOpacity; CheckAdminRights(); } LCount++; if (LCount == 129) { LCount = 0; } if (!GameLoaded) { if (FirstLoop) { if (!MiscLoaded) { MiscLoaded = true; } InitRayCast(); GameLoaded = true; } else if (!FirstLoop) { FirstLoop = true; foreach (var t in AllDefinitions) { var name = t.Id.SubtypeName; var contains = name.Contains("BlockArmor"); if (contains) { AllArmorBaseDefinitions.Add(t); if (name.Contains("HeavyBlockArmor")) { HeavyArmorBaseDefinitions.Add(t); } } } } } if (!PlayersLoaded && KeenFuckery()) { PlayersLoaded = true; } if (ShieldMod && !ShieldApiLoaded && SApi.Load()) { ShieldApiLoaded = true; } }
private void BeforeStartInit() { MpActive = MyAPIGateway.Multiplayer.MultiplayerActive; IsServer = MyAPIGateway.Multiplayer.IsServer; DedicatedServer = MyAPIGateway.Utilities.IsDedicated; IsCreative = MyAPIGateway.Session.CreativeMode || MyAPIGateway.Session.SessionSettings.InfiniteAmmo; IsClient = !IsServer && !DedicatedServer && MpActive; HandlesInput = !IsServer || IsServer && !DedicatedServer; IsHost = IsServer && !DedicatedServer && MpActive; MpServer = IsHost || DedicatedServer; if (IsServer || DedicatedServer) { MyAPIGateway.Multiplayer.RegisterMessageHandler(ServerPacketId, ProccessServerPacket); } else { MyAPIGateway.Multiplayer.RegisterMessageHandler(ClientPacketId, ClientReceivedPacket); MyAPIGateway.Multiplayer.RegisterMessageHandler(StringPacketId, StringReceived); } if (DamageHandler) { Session.DamageSystem.RegisterBeforeDamageHandler(int.MinValue, BeforeDamageHandler); } if (IsServer) { MyVisualScriptLogicProvider.PlayerDisconnected += PlayerDisconnected; MyVisualScriptLogicProvider.PlayerRespawnRequest += PlayerConnected; } if (HandlesInput) { MyAPIGateway.Utilities.MessageEntered += ChatMessageSet; } var env = MyDefinitionManager.Static.EnvironmentDefinition; if (env.LargeShipMaxSpeed > MaxEntitySpeed) { MaxEntitySpeed = env.LargeShipMaxSpeed; } else if (env.SmallShipMaxSpeed > MaxEntitySpeed) { MaxEntitySpeed = env.SmallShipMaxSpeed; } if (MpActive) { SyncDist = MyAPIGateway.Session.SessionSettings.SyncDistance; SyncDistSqr = SyncDist * SyncDist; SyncBufferedDistSqr = SyncDistSqr + 250000; } else { SyncDist = MyAPIGateway.Session.SessionSettings.ViewDistance; SyncDistSqr = SyncDist * SyncDist; SyncBufferedDistSqr = (SyncDist + 500) * (SyncDist + 500); } Physics = MyAPIGateway.Physics; Camera = MyAPIGateway.Session.Camera; TargetGps = MyAPIGateway.Session.GPS.Create("WEAPONCORE", "", Vector3D.MaxValue, true, false); CheckDirtyGridInfos(); ApiServer.Load(); GenerateButtonMap(); Settings = new CoreSettings(this); LocalVersion = ModContext.ModId == "WeaponCore"; CounterKeenLogMessage(); if (ShieldMod && !ShieldApiLoaded && SApi.Load()) { ShieldApiLoaded = true; ShieldHash = MyStringHash.GetOrCompute("DefenseShield"); } if (!CompsToStart.IsEmpty) { StartComps(); } EarlyInitControls(this); }
internal void Timings() { _paused = false; Tick++; Tick10 = Tick % 10 == 0; Tick20 = Tick % 20 == 0; Tick60 = Tick % 60 == 0; Tick120 = Tick % 120 == 0; Tick180 = Tick % 180 == 0; Tick300 = Tick % 300 == 0; Tick600 = Tick % 600 == 0; Tick1800 = Tick % 1800 == 0; Tick3600 = Tick % 3600 == 0; if (Tick60) { if (Av.ExplosionCounter - 5 >= 0) { Av.ExplosionCounter -= 5; } else { Av.ExplosionCounter = 0; } } if (++SCount == 60) { SCount = 0; } if (++AwakeCount == AwakeBuckets) { AwakeCount = 0; } if (++AsleepCount == AsleepBuckets) { AsleepCount = 0; } if (Count++ == 119) { Count = 0; UiBkOpacity = MyAPIGateway.Session.Config.UIBkOpacity; UiOpacity = MyAPIGateway.Session.Config.UIOpacity; CheckAdminRights(); if (IsServer && MpActive && (AuthLogging || ConnectedAuthors.Count > 0)) { AuthorDebug(); } if (IsServer && PbActivate && !PbApiInited) { Api.PbInit(); } if (HandlesInput && !ClientCheck && Tick > 1200) { if (IsClient) { if (ServerVersion != ModContext.ModName) { var message = $"::WeaponCore Version Mismatch:: Server:{ServerVersion} - Client:{ModContext.ModName} - Unexpected behavior may occur."; MyAPIGateway.Utilities.ShowNotification(message, 10000, "Red"); } } if (!string.IsNullOrEmpty(PlayerMessage)) { MyAPIGateway.Utilities.ShowNotification(PlayerMessage, 10000, "White"); } ClientCheck = true; } } LCount++; if (LCount == 129) { LCount = 0; } if (!GameLoaded) { if (FirstLoop) { if (!MiscLoaded) { MiscLoaded = true; } InitRayCast(); GameLoaded = true; if (LocalVersion) { Log.Line($"Local WeaponCore Detected"); } } else if (!FirstLoop) { FirstLoop = true; foreach (var t in AllDefinitions) { var name = t.Id.SubtypeName; if (name.Contains("BlockArmor")) { AllArmorBaseDefinitions.Add(t); if (name.Contains("HeavyBlockArmor")) { HeavyArmorBaseDefinitions.Add(t); } } } } } if (!PlayersLoaded && KeenFuckery()) { PlayersLoaded = true; } if (ShieldMod && !ShieldApiLoaded && SApi.Load()) { ShieldApiLoaded = true; ShieldHash = MyStringHash.GetOrCompute("DefenseShield"); } if (WaterMod && !WaterApiLoaded && !Settings.ClientWaiting && WApi.Waters != null) { WaterApiLoaded = true; WApiReceiveData(); } }
private void DamageShield(HitEntity hitEnt, ProInfo info) { var shield = hitEnt.Entity as IMyTerminalBlock; if (shield == null || !hitEnt.HitPos.HasValue) { return; } info.ObjectsHit++; var damageScale = 1; var fallOff = info.AmmoDef.Const.FallOffScaling && info.DistanceTraveled > info.AmmoDef.DamageScales.FallOff.Distance; if (info.AmmoDef.Const.VirtualBeams) { damageScale *= info.WeaponCache.Hits; } var damageType = info.AmmoDef.DamageScales.Shields.Type; var energy = damageType == ShieldDef.ShieldType.Energy; var heal = damageType == ShieldDef.ShieldType.Heal; var shieldByPass = info.AmmoDef.DamageScales.Shields.Type == ShieldDef.ShieldType.Bypass; var areaEffect = info.AmmoDef.AreaEffect; var detonateOnEnd = info.AmmoDef.AreaEffect.Detonation.DetonateOnEnd && areaEffect.AreaEffect != AreaEffectType.Disabled && !shieldByPass; var areaDamage = areaEffect.AreaEffect != AreaEffectType.Disabled ? areaEffect.AreaEffectDamage * (areaEffect.AreaEffectRadius * 0.5f) : 0; var scaledDamage = (((info.BaseDamagePool * damageScale) + areaDamage) * info.AmmoDef.Const.ShieldModifier) * info.AmmoDef.Const.ShieldBypassMod; if (fallOff) { var fallOffMultipler = MathHelperD.Clamp(1.0 - ((info.DistanceTraveled - info.AmmoDef.DamageScales.FallOff.Distance) / (info.AmmoDef.Const.MaxTrajectory - info.AmmoDef.DamageScales.FallOff.Distance)), info.AmmoDef.DamageScales.FallOff.MinMultipler, 1); scaledDamage *= fallOffMultipler; } var detonateDamage = detonateOnEnd ? (areaEffect.Detonation.DetonationDamage * (areaEffect.Detonation.DetonationRadius * 0.5f)) * info.AmmoDef.Const.ShieldModifier : 0; var combinedDamage = (float)(scaledDamage + detonateDamage); if (heal) { combinedDamage *= -1; } var hit = SApi.PointAttackShieldExt(shield, hitEnt.HitPos.Value, info.Target.FiringCube.EntityId, combinedDamage, energy, info.AmmoDef.AmmoGraphics.ShieldHitDraw); if (hit.HasValue) { if (heal) { info.BaseDamagePool = 0; return; } var objHp = hit.Value; if (info.EwarActive) { info.BaseHealthPool -= 1; } else if (objHp > 0) { if (!shieldByPass) { info.BaseDamagePool = 0; } else { info.BaseDamagePool *= info.AmmoDef.Const.ShieldBypassMod; } } else { info.BaseDamagePool = (objHp * -1); } if (info.AmmoDef.Mass <= 0) { return; } var speed = info.AmmoDef.Trajectory.DesiredSpeed > 0 ? info.AmmoDef.Trajectory.DesiredSpeed : 1; ApplyProjectileForce((MyEntity)shield.CubeGrid, hitEnt.HitPos.Value, hitEnt.Intersection.Direction, info.AmmoDef.Mass * speed); } }