Example #1
0
 internal void Reset()
 {
     LastUpdateTime = DateTime.Now;
     LastMergeCount = 0;
     Hits.Clear();
     Hits.FireListUpdated();
 }
Example #2
0
 public static void Clear()
 {
     Hits.Clear();
     UnboundScriptBlocks.Clear();
     FileScriptBlocks.Clear();
     _index       = 0;
     _previousHit = default;
 }
Example #3
0
        public override void HitTest(Matrix4x4 transform, List <Vector2D> points)
        {
            Hits.Clear();
            double ptx, pty;

            for (int i = 0; i < points.Count; i++)
            {
                ptx = points[i].x;
                pty = points[i].y;
                Vector2D  v        = new Vector2D(ptx, pty);
                Matrix4x4 trobject = new Matrix4x4(transform);
                Vector2D  trv      = ((!trobject) * v).xy;

                double dist = Math.Sqrt(trv.x * trv.x + trv.y * trv.y);

                if (dist < 0.5)
                {
                    this.Hits.Add(i);
                }
            }
        }
Example #4
0
        public override void HitTest(Matrix4x4 transform, List <Vector2D> points)
        {
            Hits.Clear();
            double ptx, pty;

            for (int i = 0; i < points.Count; i++)
            {
                ptx = points[i].x;
                pty = points[i].y;
                Vector2D v = new Vector2D(ptx, pty);


                int       cnt      = 0;
                Matrix4x4 trobject = new Matrix4x4(transform);

                double[] dx = new double[this.Vertices.Count];
                double[] dy = new double[this.Vertices.Count];
                for (int k = 0; k < this.Vertices.Count; k++)
                {
                    double x, y;
                    x = this.Vertices[k].x;
                    y = this.Vertices[k].y;

                    Vector2D v2  = new Vector2D(x, y);
                    Vector2D trv = (trobject * v2).xy;

                    dx[k] = trv.x;
                    dy[k] = trv.y;
                    cnt++;
                }

                if (this.inpoly(dx, dy, this.Vertices.Count, ptx, pty))
                {
                    this.Hits.Add(i);
                }
            }
        }
Example #5
0
        public override void HitTest(Matrix4x4 transform, List <Vector2D> points)
        {
            Hits.Clear();
            double ptx, pty;

            for (int i = 0; i < points.Count; i++)
            {
                ptx = points[i].x;
                pty = points[i].y;
                Vector2D v = new Vector2D(ptx, pty);


                Matrix4x4 trobject = new Matrix4x4(transform);
                Vector2D  trv      = ((!trobject) * v).xy;

                double dist   = Math.Sqrt(trv.x * trv.x + trv.y * trv.y);
                bool   passed = dist < 0.5;
                double inner  = this.InnerRadius * 0.5;
                passed = passed && (dist > inner);

                double phase = this.Phase % 1.0d;

                double angle = Math.Atan2(trv.y, trv.x);
                angle /= (Math.PI * 2.0);
                angle -= this.Phase;
                angle  = angle % 1.0d;
                angle  = angle < 0 ? (angle + 1.0) : angle;

                passed = passed && (angle < this.Cycles);


                if (passed)
                {
                    this.Hits.Add(i);
                }
            }
        }
Example #6
0
        public async void allCurrentHits()
        {
            Hits.Clear();
            if (end != null)
            {
                var allhits = await currentModel.getHitsByDates(start, end);

                foreach (var item in allhits)
                {
                    updateHitsAndPushPins(item);
                }
            }
            else
            {
                DateTime tempend = start;
                tempend.AddMinutes(10 * Convert.ToInt32(eventNum));
                var allhits = await currentModel.getHitsByDates(start, end);

                foreach (var item in allhits)
                {
                    updateHitsAndPushPins(item);
                }
            }
        }
        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;
        }
Example #8
0
        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;
        }
Example #9
0
        internal void ProcessHits()
        {
            for (int x = 0; x < Hits.Count; x++)
            {
                var p          = Hits[x];
                var info       = p.Info;
                var maxObjects = info.AmmoDef.Const.MaxObjectsHit;
                var phantom    = info.AmmoDef.BaseDamage <= 0;
                var pInvalid   = (int)p.State > 3;
                var tInvalid   = info.Target.IsProjectile && (int)info.Target.Projectile.State > 1;
                if (tInvalid)
                {
                    info.Target.Reset(info.Ai.Session.Tick, Target.States.ProjectileClosed);
                }
                var skip = pInvalid || tInvalid;
                for (int i = 0; i < info.HitList.Count; i++)
                {
                    var hitEnt   = info.HitList[i];
                    var hitMax   = info.ObjectsHit >= maxObjects;
                    var outOfPew = info.BaseDamagePool <= 0 && !(phantom && hitEnt.EventType == HitEntity.Type.Effect);

                    if (skip || hitMax || outOfPew)
                    {
                        if (hitMax || outOfPew || pInvalid)
                        {
                            p.State = Projectile.ProjectileState.Depleted;
                        }
                        Projectiles.HitEntityPool.Return(hitEnt);
                        continue;
                    }
                    switch (hitEnt.EventType)
                    {
                    case HitEntity.Type.Shield:
                        DamageShield(hitEnt, info);
                        continue;

                    case HitEntity.Type.Grid:
                        DamageGrid(hitEnt, info);
                        continue;

                    case HitEntity.Type.Destroyable:
                        DamageDestObj(hitEnt, info);
                        continue;

                    case HitEntity.Type.Voxel:
                        DamageVoxel(hitEnt, info);
                        continue;

                    case HitEntity.Type.Projectile:
                        DamageProjectile(hitEnt, info);
                        continue;

                    case HitEntity.Type.Field:
                        UpdateField(hitEnt, info);
                        continue;

                    case HitEntity.Type.Effect:
                        UpdateEffect(hitEnt, info);
                        continue;
                    }
                    Projectiles.HitEntityPool.Return(hitEnt);
                }

                if (info.BaseDamagePool <= 0)
                {
                    p.State = Projectile.ProjectileState.Depleted;
                }

                info.HitList.Clear();
            }
            Hits.Clear();
        }
Example #10
0
 public void Clear()
 {
     PlayerPositions.Clear();
     Hits.Clear();
     Hearts.Clear();
 }
        internal void ProcessHits()
        {
            for (int x = 0; x < Hits.Count; x++)
            {
                var p          = Hits[x];
                var info       = p.Info;
                var maxObjects = info.AmmoDef.Const.MaxObjectsHit;
                var phantom    = info.AmmoDef.BaseDamage <= 0;
                var pInvalid   = (int)p.State > 3;
                var tInvalid   = info.Target.IsProjectile && (int)info.Target.Projectile.State > 1;
                if (tInvalid)
                {
                    info.Target.Reset(info.Ai.Session.Tick, Target.States.ProjectileClosed);
                }
                var skip      = pInvalid || tInvalid;
                var fixedFire = p.Info.System.TurretMovement == Fixed && p.Guidance == None && !p.Info.AmmoDef.Const.IsBeamWeapon;
                var canDamage = !MpActive || !IsClient && (!fixedFire || (p.Info.IsFiringPlayer || p.Info.ClientSent));

                if (IsClient && p.Info.IsFiringPlayer && fixedFire)
                {
                    SendFixedGunHitEvent(p.Info.Target.FiringCube, p.Hit.Entity, info.HitList[0].HitPos ?? Vector3.Zero, info.Direction, p.Info.OriginUp, p.Info.MuzzleId, info.System.WeaponIdHash);
                    p.Info.IsFiringPlayer = false; //to prevent hits on another grid from triggering again
                }

                for (int i = 0; i < info.HitList.Count; i++)
                {
                    var hitEnt   = info.HitList[i];
                    var hitMax   = info.ObjectsHit >= maxObjects;
                    var outOfPew = info.BaseDamagePool <= 0 && !(phantom && hitEnt.EventType == HitEntity.Type.Effect);

                    if (skip || hitMax || outOfPew)
                    {
                        if (hitMax || outOfPew || pInvalid)
                        {
                            p.State = Projectile.ProjectileState.Depleted;
                        }
                        Projectiles.HitEntityPool.Return(hitEnt);
                        continue;
                    }
                    switch (hitEnt.EventType)
                    {
                    case HitEntity.Type.Shield:
                        DamageShield(hitEnt, info);
                        continue;

                    case HitEntity.Type.Grid:
                        DamageGrid(hitEnt, info, canDamage);
                        continue;

                    case HitEntity.Type.Destroyable:
                        DamageDestObj(hitEnt, info, canDamage);
                        continue;

                    case HitEntity.Type.Voxel:
                        DamageVoxel(hitEnt, info, canDamage);
                        continue;

                    case HitEntity.Type.Projectile:
                        DamageProjectile(hitEnt, info);
                        continue;

                    case HitEntity.Type.Field:
                        UpdateField(hitEnt, info);
                        continue;

                    case HitEntity.Type.Effect:
                        UpdateEffect(hitEnt, info);
                        continue;
                    }
                    Projectiles.HitEntityPool.Return(hitEnt);
                }

                if (info.BaseDamagePool <= 0)
                {
                    p.State = Projectile.ProjectileState.Depleted;
                }

                info.HitList.Clear();
            }
            Hits.Clear();
        }