// Constructor public Ship(string name, Player owner) { _player = owner; log = new ShipLog(this); this.name = name; _planet = Terraformer.FindPlanet(EventGroup.SpaceSector); updateTimer = new Timer(1f, true); }
static void Main(string[] args) { threadLibrary.Add(Thread.CurrentThread, ThreadId.Main); LogManager.CleanUpFiles(); ConsoleEx.Log("Thread started"); ConsoleEx.Log("Loading strings"); Localization.Load(); ConsoleEx.Log("Loading looters"); Looter.LoadItems(); ConsoleEx.Log("Loading destiny"); Destiny.LoadEvents(); ConsoleEx.Log("Loading planets"); Terraformer.LoadPlanets(); ConsoleEx.Log("Loading accounts"); Authorization.LoadAccounts(); ConsoleEx.Log("Rolling the dice"); Random.RollSeed(); ConsoleEx.Log("Creating the universe"); Universe.Create(); ConsoleEx.Log("Generating RSA keys"); WebSecurity.GenerateKeys(); ConsoleEx.Log("Collecting command line data"); CmdParser.Initialize(); ConsoleEx.Log("Initializing web thread"); Thread webThread = new Thread(WebCore.WebThread); WebCore.OnStart(); webThread.Start(); threadLibrary.Add(webThread, ThreadId.Web); ConsoleEx.Log("Initializing world thread"); Thread worldThread = new Thread(WorldCore.WorldThread); WorldCore.OnStart(); worldThread.Start(); threadLibrary.Add(worldThread, ThreadId.World); ConsoleEx.Log("Initializing disk thread"); Thread diskThread = new Thread(DiskCore.ThreadMain); DiskCore.OnStart(); diskThread.Start(); threadLibrary.Add(diskThread, ThreadId.Disk); ConsoleEx.Log("Initializing update thread"); Thread updateThread = new Thread(WebUpdaterCore.ThreadMain); WebUpdaterCore.OnStart(); updateThread.Start(); threadLibrary.Add(updateThread, ThreadId.Update); ConsoleEx.Log("Initializing GUI thread"); Thread guiThread = new Thread(GUICore.ThreadMain); GUICore.OnStart(); guiThread.Start(); threadLibrary.Add(guiThread, ThreadId.GUI); ConsoleEx.Log("Switching to graphical console"); HideConsole(); while (state != ThreadState.Stopping) { Thread.Sleep(1); } ConsoleEx.Log("Initializing shutdown sequence"); //ConsoleEx.Log("Switching back to native console"); //ShowConsole(); GUICore.OnStop(); ConsoleEx.Log("Shutting down update thread"); WebUpdaterCore.OnStop(); updateThread.Join(1000); updateThread.Abort(); ConsoleEx.Log("Shutting down disk thread"); DiskCore.OnStop(); diskThread.Join(1000); diskThread.Abort(); ConsoleEx.Log("Shutting down world thread"); WorldCore.OnStop(); worldThread.Join(1000); worldThread.Abort(); ConsoleEx.Log("Shutting down web thread"); WebCore.OnStop(); webThread.Join(1000); webThread.Abort(); ConsoleEx.Log("Shutting down main thread"); ConsoleEx.Log("Goodbye"); }
// Public functions public void OnUpdate() { // Update stats if (ship.status == ShipStatus.Exploring) { stamina -= 0.1f * Time.deltaTime; curiosity -= 0.1f * Time.deltaTime; } else if (ship.status == ShipStatus.OnStation) { stamina += 0.1f * Time.deltaTime; curiosity += 0.1f * Time.deltaTime; } // Random event if (Random.Percentage() <= _updateChanceCumulative || ship.log.GetMessageCount() == 0) { // Random event occured! Check if something is queued if (_queuedEvent != null) { // Invoke the queued event RunEvent(_queuedEvent); // Clear the queued event _queuedEvent = null; } // If not - select some random event else { int eventGroups = EventGroup.None; if (ship.status == ShipStatus.Traveling) { eventGroups = EventGroup.InTravel; } else if (ship.planet == null) { eventGroups = EventGroup.SpaceSector; } else { eventGroups = ship.planet.eventGroups; } // Invoke an event RunEvent(eventGroups); } // Reset chance _updateChanceCumulative = updateChanceMinimal; } else { _updateChanceCumulative += updateChanceStep; } // Traveling if (ship.status == ShipStatus.Exploring && (stamina < 5f || curiosity < 5f)) { ship.TravelTo(Terraformer.FindPlanet(EventGroup.Station)); } if (ship.status == ShipStatus.OnStation && (stamina > 80f && curiosity > 90f) && storyStage > StoryStage.ShipExploration) { ship.TravelTo(Terraformer.FindPlanet(EventGroup.Planet | EventGroup.SpaceSector)); } }