コード例 #1
0
        /// <summary>
        ///     Determines a valid hardpoint for launching from
        ///     the given base. Validity is determined by the
        ///     DockingPoint.DockingSphere and ShipArchetype.MissionProperty
        ///     enumerations.
        /// </summary>
        /// <param name="ship"></param>
        /// <returns></returns>
        public DockingObject GetLaunchPoint(FOS_ng.Objects.Ship.Ship ship)
        {
            // FIXME: select point based on ship moor type
            var validLaunchObjs = new List <DockingObject>();

            var mp = (ship.Arch as ShipArchetype).mission_property;

            var minType = Int32.MaxValue;

            foreach (DockingObject obj in LaunchObjs)
            {
                if (obj.CanDock(mp))
                {
                    if (obj.Type == DockingPoint.DockingSphere.RING)
                    {
                        if (obj.Index == 1)
                        {
                            return(obj);
                        }
                    }
                    else if ((int)obj.Type <= minType)
                    {
                        if ((int)obj.Type < minType)
                        {
                            validLaunchObjs.Clear();
                            minType = (int)obj.Type;
                        }

                        validLaunchObjs.Add(obj);
                    }
                }
            }

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

            var selectedPoint = _rand.Next(validLaunchObjs.Count);

            return(validLaunchObjs[selectedPoint]);
        }
コード例 #2
0
        public DockingObject GetDockingPoint(FOS_ng.Objects.Ship.Ship ship)
        {
            var validDockingObjs = new List <DockingObject>();

            ShipArchetype.MissionProperty mp = ((ShipArchetype)ship.Arch).mission_property;

            int minType = Int32.MaxValue;

            foreach (DockingObject obj in DockingObjs)
            {
                if (obj.CanDock(mp))
                {
                    if (obj.Type == DockingPoint.DockingSphere.RING)
                    {
                        if (obj.Index == 0)
                        {
                            return(obj);
                        }
                    }
                    else if ((int)obj.Type <= minType)
                    {
                        if ((int)obj.Type < minType)
                        {
                            validDockingObjs.Clear();
                            minType = (int)obj.Type;
                        }

                        validDockingObjs.Add(obj);
                    }
                }
            }

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

            int selectedPoint = _rand.Next(Math.Min(2, validDockingObjs.Count));

            return(validDockingObjs.OrderBy(x => x.Position.DistSqr(ship.Position)).ElementAt(selectedPoint));
        }
コード例 #3
0
 /// <summary>
 ///     Activate the docking point (i.e. close the door)
 /// </summary>
 public void Deactivate(DPGameRunner runner)
 {
     runner.SendActivateObject(this, false,
                               Type == DockingPoint.DockingSphere.TRADELANE_RING ? Ship.Objid : Index);
     Ship = null;
 }
コード例 #4
0
 /// <summary>
 ///     Activate the docking point (i.e. open the door)
 /// </summary>
 public void Activate(Ship.Ship ship)
 {
     Ship = ship;
     runner.SendActivateObject(this, true, Type == DockingPoint.DockingSphere.TRADELANE_RING ? ship.Objid : Index);
 }