Пример #1
0
        internal void EntIntersectSelector(KeyValuePair <MyEntity, EntIntersectInfo> pair)
        {
            var entInfo = pair.Value;
            var webent  = pair.Key;

            if (entInfo == null || webent == null || webent.MarkedForClose)
            {
                return;
            }
            var relation = entInfo.Relation;

            var tick      = Session.Instance.Tick;
            var tick25    = tick % 25 == 0;
            var entCenter = webent.PositionComp.WorldVolume.Center;

            if (entInfo.LastTick != tick)
            {
                return;
            }
            if (entInfo.BlockUpdateTick == tick && (relation == Ent.LargeNobodyGrid || relation == Ent.LargeEnemyGrid))
            {
                (webent as IMyCubeGrid)?.GetBlocks(entInfo.CacheBlockList);
            }
            switch (relation)
            {
            case Ent.EnemyPlayer:
            {
                if (tick25 && CustomCollision.PointInShield(entCenter, DetectMatrixOutsideInv))
                {
                    if (Session.Enforced.Debug == 3)
                    {
                        Log.Line($"Ent EnemyPlayer: {webent.DebugName} - ShieldId [{Shield.EntityId}]");
                    }
                    PlayerIntersect(webent);
                }
                return;
            }

            case Ent.SmallNobodyGrid:
            {
                if (Session.Enforced.Debug == 3)
                {
                    Log.Line($"Ent SmallNobodyGrid: {webent.DebugName} - ShieldId [{Shield.EntityId}]");
                }
                SmallGridIntersect(webent);
                return;
            }

            case Ent.LargeNobodyGrid:
            {
                if (Session.Enforced.Debug == 3)
                {
                    Log.Line($"Ent LargeNobodyGrid: {webent.DebugName} - ShieldId [{Shield.EntityId}]");
                }
                GridIntersect(webent);
                return;
            }

            case Ent.SmallEnemyGrid:
            {
                if (Session.Enforced.Debug == 3)
                {
                    Log.Line($"Ent SmallEnemyGrid: {webent.DebugName} - ShieldId [{Shield.EntityId}]");
                }
                SmallGridIntersect(webent);
                return;
            }

            case Ent.LargeEnemyGrid:
            {
                if (Session.Enforced.Debug == 3)
                {
                    Log.Line($"Ent LargeEnemyGrid: {webent.DebugName} - ShieldId [{Shield.EntityId}]");
                }
                GridIntersect(webent);
                return;
            }

            case Ent.Shielded:
            {
                if (Session.Enforced.Debug == 3)
                {
                    Log.Line($"Ent Shielded: {webent.DebugName} - ShieldId [{Shield.EntityId}]");
                }
                ShieldIntersect(webent);
                return;
            }

            case Ent.Other:
            {
                if (!_isServer)
                {
                    return;
                }
                if (Session.Enforced.Debug == 3)
                {
                    Log.Line($"Ent Other: {webent.DebugName} - ShieldId [{Shield.EntityId}]");
                }
                if (webent.MarkedForClose || !webent.InScene || webent.Closed)
                {
                    return;
                }
                var meteor = webent as IMyMeteor;
                if (meteor != null)
                {
                    if (CustomCollision.PointInShield(entCenter, DetectMatrixOutsideInv))
                    {
                        MeteorDmg.Enqueue(meteor);
                    }
                }
                else
                {
                    var predictedHit = CustomCollision.MissileIntersect(this, webent, DetectionMatrix, DetectMatrixOutsideInv);
                    if (predictedHit != null)
                    {
                        MissileDmg.Enqueue(webent);
                    }
                }
                return;
            }

            default:
                if (Session.Enforced.Debug == 3)
                {
                    Log.Line($"Ent default: {webent.DebugName} - relation:{entInfo.Relation} - ShieldId [{Shield.EntityId}]");
                }
                return;
            }
        }