private void InitHudObjective() { IMyHudObjectiveLine objective = MyAPIGateway.Utilities.GetObjectiveLine(); objective.Title = _track.Title; objective.Objectives.Clear(); objective.Objectives.Add(""); objective.Show(); }
public override void UpdateBeforeSimulation() { try { if (MyAPIGateway.Session == null) { return; } _updateCount++; if (!_init) { Initialize(); } if (!_playerInit && MyAPIGateway.Session?.Player?.Character != null) { _playerInit = true; if (MyAPIGateway.Utilities.FileExistsInLocalStorage("Ship.bin", typeof(LinkModCore))) { BinaryReader reader = MyAPIGateway.Utilities.ReadBinaryFileInLocalStorage("Ship.bin", typeof(LinkModCore)); int count = reader.ReadInt32(); byte[] bytes = reader.ReadBytes(count); Logging.Instance.WriteLine($"Sending grid parts: {count} bytes."); Communication.SegmentAndSend(Communication.MessageType.ServerGridPart, bytes, MyAPIGateway.Session.Player.SteamUserId); } else { var character = MyAPIGateway.Session.Player.Character; var pos = Utilities.RandomPositionFromPoint(character.GetPosition(), 500000); var newPos = MyAPIGateway.Entities.FindFreePlace(pos, 5f); character.SetPosition(newPos ?? pos); } //if (!MyAPIGateway.Utilities.FileExistsInLocalStorage("Greeting.cfm", typeof(LinkModCore))) //{ // MyAPIGateway.Utilities.ShowMissionScreen("ServerLink", // "", // null, // "Welcome to the server link demo! Important rules and explanations:\r\n" + // "Pistons and rotors are prohibited.\r\n" + // "Grids are limited to 5k blocks.\r\n" + // "Grids in the hub will always be static, and all weapons are disabled.\r\n" + // "Grids in the hub MUST be owned! Unowned grids and grids beloning to offline players will be deleted every 10 minutes.\r\n\r\n" + // "Hub server provided by Neimoh of Galaxy Strike Force\r\n" + // "Match server #1 provided by Franky500 of Frankys Space\r\n" + // "Be sure to visit their regular servers!\r\n" + // "All other servers provided by X_Wing_Ian\r\n\r\n" + // "Use !join to get a list of servers you can join. Use !help for a full list of commands you can use.\r\n\r\n\r\n" + // "Enjoy!\r\n" + // "-rexxar", // null, // "Close"); // var w = MyAPIGateway.Utilities.WriteFileInLocalStorage("Greeting.cfm", typeof(LinkModCore)); // w.Write("true"); // w.Flush(); // w.Close(); //} //else if (!Settings.Instance.Hub && !Exempt.Contains(MyAPIGateway.Session.Player.SteamUserId)) //{ // MyAPIGateway.Utilities.ShowMessage("System", "You shouldn't be here!"); // Communication.RedirectClient(MyAPIGateway.Session.Player.SteamUserId, Utilities.ZERO_IP); //} } if (MyAPIGateway.Session.Player != null) { if (LobbyTime.HasValue && LobbyTime > DateTime.UtcNow) { IMyHudObjectiveLine line = MyAPIGateway.Utilities.GetObjectiveLine(); line.Title = "Match starting in:"; line.Objectives.Clear(); line.Objectives.Add((DateTime.UtcNow - LobbyTime.Value).ToString(@"mm\:ss")); if (_countdown && !line.Visible) { line.Show(); } } else { if (MatchTime.HasValue && MatchTime >= DateTime.UtcNow) { IMyHudObjectiveLine line = MyAPIGateway.Utilities.GetObjectiveLine(); line.Title = "Match ending in:"; line.Objectives.Clear(); line.Objectives.Add((DateTime.UtcNow - MatchTime.Value).ToString(@"mm\:ss")); if (_countdown && !line.Visible) { line.Show(); } } } } if (MyAPIGateway.Multiplayer.IsServer) { if (Settings.Instance == null) { MyAPIGateway.Utilities.ShowMessage("LinkMod", "Settings not defined on this server! Link mod will not work!"); MyAPIGateway.Utilities.SendMessage("Settings not defined on this server! Link mod will not work!"); return; } if (Settings.Instance.Hub) { if (_updateCount % 10 == 0) { ProcessEnforcement(); } } else { if (_updateCount % 120 == 0) { ProcessCleanup(); } if (_lobbyRunning) { var entities = new HashSet <IMyEntity>(); MyAPIGateway.Entities.GetEntities(entities); foreach (var entity in entities) { var grid = entity as IMyCubeGrid; if (grid?.Physics != null) { entity.Physics.LinearVelocity = Vector3D.ClampToSphere(entity.Physics.LinearVelocity, 10); } } } } } } catch (Exception ex) { Logging.Instance.WriteLine($"Exception during update:\r\n{ex}"); } }