Ejemplo n.º 1
0
        private void PlayerIntersect(MyEntity ent)
        {
            var character = ent as IMyCharacter;

            if (character == null || character.MarkedForClose || character.IsDead)
            {
                return;
            }

            var npcname = character.ToString();

            if (npcname.Equals(SpaceWolf))
            {
                if (_isServer)
                {
                    var charEvent = Session.Instance.PlayerEffectPool.Get();
                    charEvent.Init(character, this);
                    Session.Instance.ThreadEvents.Enqueue(charEvent);
                }
                return;
            }
            var player = MyAPIGateway.Multiplayer.Players.GetPlayerControllingEntity(ent);

            if (player == null || player.PromoteLevel == MyPromoteLevel.Owner || player.PromoteLevel == MyPromoteLevel.Admin)
            {
                return;
            }
            var obb             = new MyOrientedBoundingBoxD(ent.PositionComp.WorldAABB.Center, ent.PositionComp.LocalAABB.HalfExtents, Quaternion.CreateFromRotationMatrix(ent.WorldMatrix));
            var playerIntersect = CustomCollision.ObbIntersect(obb, DetectMatrixOutside, DetectMatrixOutsideInv);

            if (playerIntersect != null)
            {
                var collisionData = new MyCollisionPhysicsData
                {
                    Entity1      = ent,
                    Force1       = -Vector3.Normalize(ShieldEnt.PositionComp.WorldAABB.Center - (Vector3D)playerIntersect),
                    CollisionAvg = (Vector3D)playerIntersect
                };
                if (_isServer)
                {
                    var charEvent = Session.Instance.PlayerCollisionPool.Get();
                    charEvent.Init(collisionData, this);
                    Session.Instance.ThreadEvents.Enqueue(charEvent);
                }
            }
        }