Ejemplo n.º 1
0
        protected virtual HashSet <IMyEntity> GetMissilesInBoundingBox()
        {
            BoundingBoxD box = Entity.WorldAABB.GetInflated(BbInflateAmount);

            if (Math.Abs(BoundingBoxOffsetFront) > double.Epsilon)
            {
                box = box.Translate(Entity.LocalMatrix.Forward * (float)BoundingBoxOffsetFront);
            }
            //Log.Info("Bounding box in GetMissilesInBoundingBox for "+ GetType()+ " is " + box.Size);
            List <IMyEntity>    entitiesFound = MyAPIGateway.Entities.GetEntitiesInAABB(ref box);
            HashSet <IMyEntity> entitySet     = new HashSet <IMyEntity>();

            foreach (IMyEntity ent in entitiesFound)
            {
                // Log.Info("in guidedmissilehook: found Entity : " + ent);
                if ((ent.GetType().ToString() == GuidedMissileSingleton.SandboxGameWeaponsMyMissile) && (!GuidedMissileSingleton.IsGuidedMissile(ent)))
                {
                    Log.Info("detected something not yet added with speed: " + (ent.Physics.LinearVelocity - Entity.GetTopMostParent().Physics.LinearVelocity).Length());
                    Log.Info("topmostparent velocity was " + Entity.GetTopMostParent().Physics.LinearVelocity);
                    if ((ent.Physics.LinearVelocity - Entity.GetTopMostParent().Physics.LinearVelocity).Length() < MaxSpeedForGuidance)
                    {
                        entitySet.Add(ent);
                    }
                    else
                    {
                        Log.Info("Missile was too fast! Adding to ignoreSet");
                        GuidedMissileSingleton.GetInstance().IgnoreSet.Add(ent);
                    }
                }
            }
            return(entitySet);
        }
Ejemplo n.º 2
0
        protected HashSet <IMyEntity> GetMissilesInBoundingBox()
        {
            BoundingBoxD box = Entity.WorldAABB.GetInflated(2.0);
            //  box = box.Translate(Entity.LocalMatrix.Forward * 0.2f);
            //Log.Info("Bounding box in GetMissilesInBoundingBox for "+ GetType()+ " is " + box.Size);
            List <IMyEntity>    entitiesFound = MyAPIGateway.Entities.GetEntitiesInAABB(ref box);
            HashSet <IMyEntity> entitySet     = new HashSet <IMyEntity>();

            foreach (IMyEntity ent in entitiesFound)
            {
                if ((ent.GetType().ToString() == GuidedMissileSingleton.SandboxGameWeaponsMyMissile) && (!GuidedMissileSingleton.IsGuidedMissile(ent)))
                {
                    //   Log.Info("detected something not yet added with speed: " + (ent.Physics.LinearVelocity - Entity.GetTopMostParent().Physics.LinearVelocity).Length());
                    //   Log.Info("topmostparent velocity was " + Entity.GetTopMostParent().Physics.LinearVelocity);

                    if ((ent.Physics.LinearVelocity - Entity.GetTopMostParent().Physics.LinearVelocity).Length() > 110)
                    {
                        Log.Info("found something");
                        entitySet.Add(ent);
                    }
                    else
                    {
                        //    Log.Info("Missile was too fast! Adding to ignoreSet");
                        GuidedMissileSingleton.GetInstance().IgnoreSet.Add(ent);
                    }
                }
            }
            return(entitySet);
        }