private void PrepEmpBlast()
        {
            var stackCount   = 0;
            var warHeadSize  = 0;
            var warHeadYield = 0d;
            var epiCenter    = Vector3D.Zero;

            WarHeadBlast empChild;

            while (EmpStore.TryDequeue(out empChild))
            {
                if (empChild.CustomData.Contains("@EMP"))
                {
                    stackCount++;
                    warHeadSize  = empChild.WarSize;
                    warHeadYield = empChild.Yield;
                    epiCenter   += empChild.Position;
                }
            }

            if (stackCount == 0)
            {
                EmpWork.EventComplete();
                return;
            }
            epiCenter /= stackCount;
            var rangeCap = MathHelper.Clamp(stackCount * warHeadYield, warHeadYield, SyncDist);

            _warHeadGridHits.Clear();
            _pruneWarGrids.Clear();

            var sphere = new BoundingSphereD(epiCenter, rangeCap);

            MyGamePruningStructure.GetAllTopMostEntitiesInSphere(ref sphere, _pruneWarGrids);

            foreach (var ent in _pruneWarGrids)
            {
                var grid = ent as MyCubeGrid;
                if (grid != null)
                {
                    ShieldGridComponent sComp;
                    grid.Components.TryGet(out sComp);
                    if (sComp?.DefenseShields != null && sComp.DefenseShields.NotFailed)
                    {
                        continue;
                    }

                    var gridCenter = grid.PositionComp.WorldVolume.Center;
                    var testDir    = Vector3D.Normalize(gridCenter - epiCenter);
                    var impactPos  = gridCenter + (testDir * -grid.PositionComp.WorldVolume.Radius);

                    IHitInfo hitInfo;
                    MyAPIGateway.Physics.CastRay(epiCenter, impactPos, out hitInfo, CollisionLayers.DefaultCollisionLayer);
                    if (hitInfo?.HitEntity == null)
                    {
                        _warHeadGridHits.Add(grid);
                    }
                }
            }

            EmpWork.StoreEmpBlast(epiCenter, warHeadSize, warHeadYield, stackCount, rangeCap);
        }
Beispiel #2
0
        private void Timings()
        {
            Tick     = (uint)(Session.ElapsedPlayTime.TotalMilliseconds * TickTimeDiv);
            Tick20   = Tick % 20 == 0;
            Tick30   = Tick % 30 == 0;
            Tick60   = Tick % 60 == 0;
            Tick60   = Tick % 60 == 0;
            Tick180  = Tick % 180 == 0;
            Tick300  = Tick % 300 == 0;
            Tick600  = Tick % 600 == 0;
            Tick1800 = Tick % 1800 == 0;

            if (_count++ == 59)
            {
                _count = 0;
                _lCount++;
                if (_lCount == 10)
                {
                    _lCount = 0;
                    _eCount++;
                    if (_eCount == 10)
                    {
                        _eCount        = 0;
                        _previousEntId = -1;
                    }
                }
            }
            if (!GameLoaded)
            {
                if (!MiscLoaded)
                {
                    if (SessionReady && GlobalProtect.Count > 0 && (IsServer || !IsServer && ClientLoadCount++ > 60))
                    {
                        UtilsStatic.GetDefinitons();
                        if (!IsServer)
                        {
                            Players.TryAdd(MyAPIGateway.Session.Player.IdentityId, MyAPIGateway.Session.Player);
                        }
                        Api.Init();
                        MiscLoaded = true;
                        GameLoaded = true;
                    }
                }

                if (MiscLoaded && !WarHeadLoaded && WarTerminalReset != null)
                {
                    WarTerminalReset.ShowInTerminal = true;
                    WarTerminalReset = null;
                    WarHeadLoaded    = true;
                    GameLoaded       = true;
                }
            }

            if (EmpWork.EventRunning && EmpWork.Computed)
            {
                EmpWork.EventComplete();
            }

            if (Tick20)
            {
                Scale();
                EntSlotTick = Tick % (180 / EntSlotScaler) == 0;
                if (EntSlotTick)
                {
                    LoadBalancer();
                }
            }
            else
            {
                EntSlotTick = false;
            }
        }
Beispiel #3
0
        private void Timings()
        {
            _newFrame = true;
            Tick      = (uint)(Session.ElapsedPlayTime.TotalMilliseconds * TickTimeDiv);
            Tick20    = Tick % 20 == 0;
            Tick60    = Tick % 60 == 0;
            Tick60    = Tick % 60 == 0;
            Tick180   = Tick % 180 == 0;
            Tick600   = Tick % 600 == 0;
            Tick1800  = Tick % 1800 == 0;

            if (_count++ == 59)
            {
                _count = 0;
                _lCount++;
                if (_lCount == 10)
                {
                    _lCount = 0;
                    _eCount++;
                    if (_eCount == 10)
                    {
                        _eCount = 0;
                    }
                }
            }
            if (!GameLoaded && Tick > 100)
            {
                if (!WarHeadLoaded && WarTerminalReset != null)
                {
                    WarTerminalReset.ShowInTerminal = true;
                    WarTerminalReset = null;
                    WarHeadLoaded    = true;
                }

                if (!MiscLoaded)
                {
                    MiscLoaded = true;
                    UtilsStatic.GetDefinitons();
                    if (!IsServer)
                    {
                        Players.TryAdd(MyAPIGateway.Session.Player.IdentityId, MyAPIGateway.Session.Player);
                    }
                }
                GameLoaded = true;
            }

            if (EmpWork.EventRunning && EmpWork.Computed)
            {
                EmpWork.EventComplete();
            }

            if (Tick20)
            {
                Scale();
                EntSlotTick = Tick % (180 / EntSlotScaler) == 0;
                if (EntSlotTick)
                {
                    LoadBalancer();
                }
            }
            else
            {
                EntSlotTick = false;
            }
        }