private void SetMembers(EngineManager engineState)
 {
     this.EngineState    = engineState;
     AreaCompPolyHandler = new AreaCompPolyHandler(EngineState);
     DefCompPolyHandler  = new DefinitiveCompPolyHandler(EngineState);
     _entityBuilder      = new EntityBuilder(this);
     BumpersHandler      = new BumpersHandler(this);
     _rocketsHandler     = new RocketsHandler(this);
     ProjectionHandler   = new ProjectionHandler(this);
 }
Beispiel #2
0
        public List <List <IntPoint> > GetAreaPoly(CompEntityPoly adder)
        {
            var polys = new List <List <IntPoint> >();

            if (adder is BubbleEntityPoly)
            {
                BumpersHandler.AddBumpsAreaForBubble(ref polys, this, adder as BubbleEntityPoly);
            }
            else
            {
                polys = new List <List <IntPoint> >()
                {
                    AreaCompPolyHandler.GetBumperPoly((BumpRigid)CompObj, adder.PositionXNACenter2D)
                };
            }
            //EntraDrawer.DrawIntoFileTesting(polys);
            return(polys);
        }
Beispiel #3
0
        public static List <List <IntPoint> > GetDelPolysOfMe(BumperEntityPoly me, List <CompEntityPoly> adders)
        {
            List <List <IntPoint> > allDels = new List <List <IntPoint> >();

            if (adders == null)
            {
                return(allDels);
            }
            if (adders.Count == 0)
            {
                return(allDels);
            }

            foreach (CompEntityPoly adder in adders)
            {
                if (adder != me)
                {
                    //if (!(compEntityPoly is BumperEntityPoly))
                    {
                        List <List <IntPoint> > newDelPolys = new List <List <IntPoint> >();

                        if (adder is BumperEntityPoly)
                        {
                            var adderBump = adder as BumperEntityPoly;
                            if (EntraSolver.IsPolyOperation(me.GetDefPoly(),
                                                            adderBump.GetAreaPoly(),
                                                            ClipType.ctIntersection))
                            {
                                newDelPolys =
                                    me.EntraAgentSimple.ProjectionHandler.ProjectCompOntoBumper(
                                        adderBump.PositionXNACenter2D, me);
                                EntraDrawer.DrawIntoFile(newDelPolys);
                            }
                        }
                        else
                        {
                            if (EntraSolver.IsPolyOperation(me.GetDefPoly(),
                                                            adder.GetAreaPoly(), ClipType.ctIntersection))
                            {
                                newDelPolys =
                                    me.EntraAgentSimple.ProjectionHandler.ProjectCompOntoBumper(
                                        adder.PositionXNACenter2D, me);
                                EntraDrawer.DrawIntoFile(newDelPolys);

                                if (adder is RocketEntityPoly)
                                {
                                    var rocket = adder as RocketEntityPoly;
                                    ProjectionHandler.ReAddRocketTrajectoryMissingAreas(
                                        rocket,
                                        me, ref newDelPolys);
                                    var dir = (rocket.CompObj as RocketCarrierService).Dir;
                                    if (dir == Direction.North ||
                                        dir == Direction.NorthEast ||
                                        dir == Direction.NorthWest)
                                    {
                                        newDelPolys = new List <List <IntPoint> >();
                                    }
                                }
                                else
                                {
                                    if (adder is RopeEntityPoly)
                                    {
                                        List <BumperEntityPoly> allBumps =
                                            me.EntraAgentSimple.AllCompsEntities.FindAll(delegate(CompEntityPoly obj)
                                                                                         { return(obj is BumperEntityPoly); })
                                            .ConvertAll(input => input as BumperEntityPoly);

                                        List <List <BumperEntityPoly> > groups =
                                            BumpersHandler.GroupizeCloseBumpers(allBumps);

                                        if (IsBumperCloseToAnother(me, allBumps))
                                        {
                                            if (IsOnCutSide(me, adder as RopeEntityPoly, groups) || groups.Count == 0)
                                            {
                                                ProjectionHandler.ReAddBlowerBubbleRopeTrajectoryMissingAreas(
                                                    adder.PositionXNACenter2D,
                                                    me, ref newDelPolys);
                                            }
                                            else

                                            {
                                                var bumperCutSide = FindCutSideBumper(me,
                                                                                      adder as
                                                                                      RopeEntityPoly,
                                                                                      groups);
                                                if (bumperCutSide != null)
                                                {
                                                    ProjectionHandler.ReAddInverseCutPolygon(
                                                        adder.PositionXNACenter2D,
                                                        bumperCutSide, ref newDelPolys);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            ProjectionHandler.ReAddBlowerBubbleRopeTrajectoryMissingAreas(
                                                adder.PositionXNACenter2D,
                                                me, ref newDelPolys);
                                        }
                                    }
                                    else
                                    {
                                        ProjectionHandler.ReAddBlowerBubbleRopeTrajectoryMissingAreas(
                                            adder.PositionXNACenter2D,
                                            me, ref newDelPolys);
                                    }
                                }
                            }
                        }
                        EntraDrawer.DrawIntoFile(newDelPolys);
                        allDels.AddRange(newDelPolys);
                        //result = BumpersHandler.GetDelPolysIntersection(result);
                        //if (result == null)
                        //{
                        //    result = new List<List<IntPoint>>();
                        //}
                    }
                }
            }
            allDels = BumpersHandler.GetDelPolysIntersection(allDels) ?? new List <List <IntPoint> >();
            return(allDels);
        }