private static void Postfix(SpacecraftManager __instance)
 {
     if (!__instance.destinations.Exists((x) => x.type == "Endpoint"))
     {
         __instance.destinations.Add(new SpaceDestination(__instance.destinations.Count, "Endpoint", DISTANCE));
     }
 }
Example #2
0
        public static void GetUnAnalysisSpaceDestination(SpacecraftManager instance, int destId)
        {
            var previous  = instance.GetStarmapAnalysisDestinationID();
            var prevDist  = instance.GetDestination(previous).distance;
            var wormhole  = instance.destinations.Last();
            var completed = instance.GetDestinationAnalysisState(wormhole) ==
                            SpacecraftManager.DestinationAnalysisState.Complete;

            var type    = 1;
            var minDist = int.MaxValue;

            SpaceDestination next = null;

            foreach (var destination in instance.destinations)
            {
                var dist = destination.distance;
                if (instance.GetDestinationAnalysisState(destination) !=
                    SpacecraftManager.DestinationAnalysisState.Complete)
                {
                    if (dist <= minDist)
                    {
                        if (completed || prevDist < 4)
                        {
                            if (dist >= prevDist || prevDist == wormhole.distance)
                            {
                                //广度优先
                                type    = 1;
                                next    = destination;
                                minDist = dist;
                            }
                        }
                        else
                        {
                            if (dist > prevDist)
                            {
                                //深度优先
                                type    = 2;
                                next    = destination;
                                minDist = dist;
                            }
                        }
                    }
                }
            }

            if (next != null)
            {
                destId = next.id;
            }

            Debug.Log(type == 1 ? "广度优先" : "深度优先");
            Debug.Log("准备研究下一个星体:" + destId);
            instance.SetStarmapAnalysisDestinationID(destId);

            var notifier        = instance.FindOrAddComponent <Notifier>();
            var destinationType = instance.GetDestination(previous).GetDestinationType();

            notifier.Add(destinationType.GetNotification(group: "SpaceHook"));
        }
Example #3
0
            /// <summary>
            /// Applied before PushReadyToLandNotification runs.
            /// </summary>
            internal static bool Prefix(SpacecraftManager __instance, Spacecraft spacecraft)
            {
                var notification = new Notification(STRINGS.BUILDING.STATUSITEMS.
                                                    SPACECRAFTREADYTOLAND.NOTIFICATION, NotificationType.Good, HashedString.
                                                    Invalid, (notificationList, data) => STRINGS.BUILDING.STATUSITEMS.
                                                    SPACECRAFTREADYTOLAND.NOTIFICATION_TOOLTIP + notificationList.
                                                    ReduceMessages(false), spacecraft.launchConditions.GetProperName(), true);

                __instance.gameObject.AddOrGet <Notifier>().Add(notification);
                return(false);
            }
Example #4
0
        /// <summary>
        /// The substitute method which queues up the next destination when the old one would
        /// simply remove the destination. Note that the value of the second parameter is
        /// always -1 in practice.
        /// </summary>
        private static void QueueNextDestination(SpacecraftManager instance, int toSet)
        {
            int oldID = instance.GetStarmapAnalysisDestinationID();
            SpaceDestination oldDest;

            if (toSet != oldID && toSet == -1 && (oldDest = instance.GetDestination(oldID)) !=
                null && instance.GetDestinationAnalysisState(oldDest) == SpacecraftManager.
                DestinationAnalysisState.Complete)
            {
                // Destination was just discovered
                int dist = oldDest.distance, minDist = int.MaxValue;
                SpaceDestination next = null;
                foreach (var dest in instance.destinations)
                {
                    int newDist = dest.distance;
                    if (instance.GetDestinationAnalysisState(dest) != SpacecraftManager.
                        DestinationAnalysisState.Complete && newDist >= dist &&
                        newDist < minDist)
                    {
                        // At a further or equal distance, and not complete, but visible
                        // (closest unanalyzed planet)
                        next    = dest;
                        minDist = newDist;
                    }
                }
#if DEBUG
                if (next != null)
                {
                    PUtil.LogDebug("Discovered planet: {0:D}, Queueing: {1:D} ({2})".
                                   F(oldID, next.id, next.type));
                }
                else
                {
                    PUtil.LogDebug("Discovered planet: {0:D}, but none left!".F(oldID));
                }
#endif
                if (next != null)
                {
                    toSet = next.id;
                }
                // Add notification "Starmap destination discovered"
                var obj = instance.gameObject;
                if (obj != null)
                {
                    obj.AddOrGet <Notifier>()?.Add(new MessageNotification(
                                                       new StarmapDiscoveryMessage(oldDest)));
                }
            }
            instance.SetStarmapAnalysisDestinationID(toSet);
        }
    // Use this for initialization
    void Start()
    {
        mainThrusters = transform.GetComponentsInChildren<MainThrusterBehaviour>();
        blasters = transform.GetComponentsInChildren<WeaponBehaviour>();
        rcs = transform.GetComponentsInChildren<RCSBehaviour>();
        shields = transform.GetComponentsInChildren<ShieldBehaviour>();
        reactor = transform.GetComponentInChildren<ReactorBehaviour>();
        ROTATE_SPEED = rcs.Select(r => r.transform.position.magnitude * r.def.thrust).Aggregate((sum, r) => sum + r);
        MANEUVERING_THRUST = rcs.Select(r => r.def.thrust).Aggregate((sum, r) => sum + r);
        status = Instantiate(Resources.Load<StatusBar>("Status"));
        health = MAX_HEALTH;
        //shield = MAX_SHIELD;

        CreateIcon();

        manager = GameObject.FindObjectOfType<SpacecraftManager>();
        manager.Add(this);

        GetComponent<SpriteRenderer>().sortingOrder = -1;
    }
Example #6
0
 public static void Postfix(ref SpacecraftManager __instance)
 {
     __instance.destinations.Add(new MiniSun(21, 4, 0.6f, ROCKETRY.DESTINATION_THRUST_COSTS.HIGH));
 }
Example #7
0
 public static void Postfix(ref SpacecraftManager __instance)
 {
     __instance.destinations.Add(new GassyDwarf(20, 1, 0.5f, ROCKETRY.DESTINATION_THRUST_COSTS.LOW));
 }