public void subtitles(string message) { #if GAME_SN Subtitles.main.Add(message); #elif GAME_BZ Subtitles.Add(message); #endif }
/* TODO: Not in use as we are not searching for movie title * /// <summary>The parse query doc.</summary> * /// <param name="htmlDoc">The html doc.</param> * /// <returns>The <see cref="string"/>.</returns> * private Tuple<result, string> ParseTitleDoc(HtmlDocument htmlDoc) * { * var resultNodes = htmlDoc.DocumentNode.SelectNodes("//div[@class='search-result']"); * if (resultNodes == null) * { * return Tuple.Create(result.Failure, string.Empty); * } * * var exactList = new List<ItemData>(); * var popularList = new List<ItemData>(); * var closeList = new List<ItemData>(); * List<ItemData> activeList = null; * * foreach (var resultNode in resultNodes) * { * foreach (var childNode in resultNode.ChildNodes) * { * if (childNode.Name == "h2") * { * var nodeClass = childNode.GetAttributeValue("class", string.Empty); * activeList = nodeClass == "exact" * ? exactList * : (nodeClass == "popular" ? popularList : (nodeClass == "close" ? closeList : null)); * continue; * } * * if (activeList != null && childNode.Name == "ul") * { * var titleNodes = childNode.SelectNodes(".//div[@class='title']"); * if (titleNodes == null) * { * continue; * } * * foreach (var titleNode in titleNodes) * { * var linkNode = titleNode.SelectNodes(".//a").FirstOrDefault(); * if (linkNode == null) * { * continue; * } * * var link = linkNode.GetAttributeValue("href", string.Empty).Trim(); * if (!string.IsNullOrEmpty(link)) * { * string count = null; * var countNode = titleNode.NextSibling; * while (countNode != null) * { * if (countNode.GetAttributeValue("class", string.Empty).Contains("count")) * { * count = string.Format("({0})", countNode.InnerText.Trim()); * break; * } * * countNode = countNode.NextSibling; * } * * var title = HttpUtility.HtmlDecode(titleNode.InnerText).Trim(); * activeList.Add(new ItemData(title, link) { Description = HttpUtility.HtmlDecode(count) }); * } * } * * activeList = null; * } * } * } * * var matchingUrl = this.GetSubtitlePageUrl(exactList, popularList, closeList); * var itemData = matchingUrl.Item2; * var url = itemData == null || string.IsNullOrEmpty(itemData.Tag as string) ? string.Empty : "http://subscene.com" + itemData.Tag; * return Tuple.Create(matchingUrl.Item1, url); * } * * /// <summary>The get matching url.</summary> * /// <param name="exactList">The exact list.</param> * /// <param name="popularList">The popular list.</param> * /// <param name="closeList">The close list.</param> * /// <returns>The <see cref="ItemData"/>.</returns> * private Tuple<result, ItemData> GetSubtitlePageUrl(List<ItemData> exactList, List<ItemData> popularList, List<ItemData> closeList) * { * // Process the actual subtitle link * foreach (var matchingTitle in exactList) * { * return Tuple.Create(result.Success, matchingTitle); * } * * var comparer = new InlineComparer<ItemData>((a, b) => string.Equals(a.Name, b.Name), i => i == null ? 0 : i.GetHashCode()); * var selections = popularList.Union(closeList, comparer).ToList(); * if (!selections.Any()) * { * this.view.Notify(Literals.Data_No_matching_title_for + this.FilePath); * return Tuple.Create<result, ItemData>(result.Failure, null); * } * * var matchingUrl = this.view.GetSelection(selections, this.FilePath, Literals.Data_Select_matching_video_title); * return matchingUrl; * } */ /// <summary> /// Parses subtitle release document. /// </summary> /// <param name="htmlDoc">The HTML document.</param> /// <returns>The query result.</returns> private QueryResult <Subtitles> ParseSubtitleReleaseDoc(HtmlDocument htmlDoc) { var subtitleNodes = htmlDoc.DocumentNode.SelectNodes("//td[@class='a1']"); Subtitles subtitles = new Subtitles(); var result = Status.Failure; if (subtitleNodes != null) { foreach (var subtitleNode in subtitleNodes) { var linkNode = subtitleNode.SelectSingleNode(".//a"); if (linkNode == null) { continue; } var link = linkNode.GetAttributeValue("href", string.Empty); var rating = Rating.Dot; var linkSpanNodes = linkNode.SelectNodes(".//span"); var rateNode = linkSpanNodes.FirstOrDefault(); if (rateNode != null) { var rateClass = rateNode.GetAttributeValue("class", string.Empty).Split(' ').LastOrDefault(); if (!string.IsNullOrEmpty(rateClass) && rateClass.Contains("-icon")) { var rate = rateClass.Substring(0, rateClass.Length - 5); Enum.TryParse(rate, true, out rating); } } var titleNode = linkSpanNodes.LastOrDefault(); if (titleNode == null) { continue; } var title = titleNode.InnerText.Trim(); var commentNode = subtitleNode.ParentNode.SelectSingleNode(".//td[@class='a6']/div"); string description = string.Empty; if (commentNode != null) { description = commentNode.InnerText.Trim(); } description = HttpUtility.HtmlDecode(description.Replace(Environment.NewLine, " ")); title = HttpUtility.HtmlDecode(title); var url = BaseUrl + "/" + link; subtitles.Add(new Subtitle(title, description + " [Subscene.com]", url, rating, this)); } result = Status.Success; } return(new QueryResult <Subtitles>(result, subtitles)); }
public static void Patch_Player_Health() { Inventory pInventory = Inventory.main; IList <InventoryItem> medKit = pInventory.container.GetItems(TechType.FirstAidKit); if (!MainPatch.EditNameCheck) { if (Input.GetKeyDown(MainPatch.MedHotKey)) { if (MainPatch.ToggleMedHotKey) { if (Player.main.GetComponent <LiveMixin>().health <= MainPatch.HealthPercentage) { if (medKit != null) { pInventory.ExecuteItemAction(ItemAction.Use, medKit.First()); } else { if (MainPatch.TextValue == "Standard") { ErrorMessage.AddWarning("You Do Not Have Any MedKits In your Inventory"); } else if (MainPatch.TextValue == "Subtitles") { Subtitles.Add("You Do Not Have Any MedKits In your Inventory"); } } } else { if (MainPatch.TextValue == "Standard") { ErrorMessage.AddWarning($"You Do not need to use a FirstAidKit Your health is already above {MainPatch.HealthPercentage}"); } else if (MainPatch.TextValue == "Subtitles") { Subtitles.Add($"You Do not need to use a FirstAidKit Your health is already above {MainPatch.HealthPercentage }"); } } } else { if (MainPatch.TextValue == "Standard") { ErrorMessage.AddWarning("You have Disabled The MedKit Hotkey"); } else if (MainPatch.TextValue == "Subtitles") { Subtitles.Add("You Have Disabled The MedKit Hotkey"); } } } } }
public async Task FillSubtitles() { if (Subtitles.Any()) { return; } IEnumerable <ISubtitle> res = await VideoItemFactory.GetVideoItemSubtitlesAsync(ID).ConfigureAwait(true); Subtitles.Clear(); res.ForEach(x => Subtitles.Add(x)); }
private async void OnMediaTrackAdded(TrackType type, int trackId, string name) { var item = new DictionaryKeyValue { Id = trackId, Name = name }; await DispatchHelper.InvokeInUIThread(CoreDispatcherPriority.Normal, () => { if (type == TrackType.Audio) { if (AudioTracks.Count == 0) { AudioTracks.Add(new DictionaryKeyValue { Id = -1, Name = "Disabled" }); } AudioTracks.Add(item); if (_currentAudioTrack == null) { _currentAudioTrack = item; } OnPropertyChanged(nameof(AudioTracks)); OnPropertyChanged(nameof(CurrentAudioTrack)); } else if (type == TrackType.Subtitle) { if (Subtitles.Count == 0) { Subtitles.Add(new DictionaryKeyValue { Id = -1, Name = "Disabled" }); } Subtitles.Add(item); if (_currentSubtitle == null) { _currentSubtitle = item; } OnPropertyChanged(nameof(Subtitles)); OnPropertyChanged(nameof(CurrentSubtitle)); } else { Locator.NavigationService.Go(VLCPage.VideoPlayerPage); } }); }
private async Task FillSubtitles() { if (Subtitles.Any()) { return; } List <SubtitlePOCO> res = await YouTubeSite.GetVideoSubtitlesByIdAsync(youId).ConfigureAwait(false); if (res.Any()) { Subtitles.Clear(); foreach (ISubtitle sb in res.Select(SubtitleFactory.CreateSubtitle)) { Subtitles.Add(sb); } } }
public static bool Prefix(LowOxygenAlert __instance, ref Utils.ScalarMonitor ___secondsMonitor, Player ___player, ref float ___lastOxygenCapacity) { ___secondsMonitor.Update(___player.GetOxygenAvailable()); float oxygenCapacity = ___player.GetOxygenCapacity(); if (Utils.NearlyEqual(oxygenCapacity, ___lastOxygenCapacity, 1.401298E-45f) || oxygenCapacity < ___lastOxygenCapacity) { for (int i = __instance.alertList.Count - 1; i >= 0; i--) { LowOxygenAlert.Alert alert = __instance.alertList[i]; if (oxygenCapacity >= alert.minO2Capacity && ___secondsMonitor.JustDroppedBelow((float)alert.oxygenTriggerSeconds) && Ocean.GetDepthOf(Utils.GetLocalPlayer()) > alert.minDepth && (___player.IsSwimming() || (___player.GetMode() == Player.Mode.LockedPiloting && !___player.GetVehicle().IsPowered()) || (___player.IsInSub() && !___player.CanBreathe()))) { Subtitles.Add(alert.notification.text); alert.soundSFX.Play(); break; } } } ___lastOxygenCapacity = oxygenCapacity; return(false); }
/* TODO: Not in use as we are not searching for movie title /// <summary>The parse query doc.</summary> /// <param name="htmlDoc">The html doc.</param> /// <returns>The <see cref="string"/>.</returns> private Tuple<result, string> ParseTitleDoc(HtmlDocument htmlDoc) { var resultNodes = htmlDoc.DocumentNode.SelectNodes("//div[@class='search-result']"); if (resultNodes == null) { return Tuple.Create(result.Failure, string.Empty); } var exactList = new List<ItemData>(); var popularList = new List<ItemData>(); var closeList = new List<ItemData>(); List<ItemData> activeList = null; foreach (var resultNode in resultNodes) { foreach (var childNode in resultNode.ChildNodes) { if (childNode.Name == "h2") { var nodeClass = childNode.GetAttributeValue("class", string.Empty); activeList = nodeClass == "exact" ? exactList : (nodeClass == "popular" ? popularList : (nodeClass == "close" ? closeList : null)); continue; } if (activeList != null && childNode.Name == "ul") { var titleNodes = childNode.SelectNodes(".//div[@class='title']"); if (titleNodes == null) { continue; } foreach (var titleNode in titleNodes) { var linkNode = titleNode.SelectNodes(".//a").FirstOrDefault(); if (linkNode == null) { continue; } var link = linkNode.GetAttributeValue("href", string.Empty).Trim(); if (!string.IsNullOrEmpty(link)) { string count = null; var countNode = titleNode.NextSibling; while (countNode != null) { if (countNode.GetAttributeValue("class", string.Empty).Contains("count")) { count = string.Format("({0})", countNode.InnerText.Trim()); break; } countNode = countNode.NextSibling; } var title = HttpUtility.HtmlDecode(titleNode.InnerText).Trim(); activeList.Add(new ItemData(title, link) { Description = HttpUtility.HtmlDecode(count) }); } } activeList = null; } } } var matchingUrl = this.GetSubtitlePageUrl(exactList, popularList, closeList); var itemData = matchingUrl.Item2; var url = itemData == null || string.IsNullOrEmpty(itemData.Tag as string) ? string.Empty : "http://subscene.com" + itemData.Tag; return Tuple.Create(matchingUrl.Item1, url); } /// <summary>The get matching url.</summary> /// <param name="exactList">The exact list.</param> /// <param name="popularList">The popular list.</param> /// <param name="closeList">The close list.</param> /// <returns>The <see cref="ItemData"/>.</returns> private Tuple<result, ItemData> GetSubtitlePageUrl(List<ItemData> exactList, List<ItemData> popularList, List<ItemData> closeList) { // Process the actual subtitle link foreach (var matchingTitle in exactList) { return Tuple.Create(result.Success, matchingTitle); } var comparer = new InlineComparer<ItemData>((a, b) => string.Equals(a.Name, b.Name), i => i == null ? 0 : i.GetHashCode()); var selections = popularList.Union(closeList, comparer).ToList(); if (!selections.Any()) { this.view.Notify(Literals.Data_No_matching_title_for + this.FilePath); return Tuple.Create<result, ItemData>(result.Failure, null); } var matchingUrl = this.view.GetSelection(selections, this.FilePath, Literals.Data_Select_matching_video_title); return matchingUrl; } */ /// <summary> /// Parses subtitle release document. /// </summary> /// <param name="htmlDoc">The HTML document.</param> /// <returns>The query result.</returns> private QueryResult<Subtitles> ParseSubtitleReleaseDoc(HtmlDocument htmlDoc) { var subtitleNodes = htmlDoc.DocumentNode.SelectNodes("//td[@class='a1']"); Subtitles subtitles = new Subtitles(); var result = Status.Failure; if (subtitleNodes != null) { foreach (var subtitleNode in subtitleNodes) { var linkNode = subtitleNode.SelectSingleNode(".//a"); if (linkNode == null) { continue; } var link = linkNode.GetAttributeValue("href", string.Empty); var rating = Rating.Dot; var linkSpanNodes = linkNode.SelectNodes(".//span"); var rateNode = linkSpanNodes.FirstOrDefault(); if (rateNode != null) { var rateClass = rateNode.GetAttributeValue("class", string.Empty).Split(' ').LastOrDefault(); if (!string.IsNullOrEmpty(rateClass) && rateClass.Contains("-icon")) { var rate = rateClass.Substring(0, rateClass.Length - 5); Enum.TryParse(rate, true, out rating); } } var titleNode = linkSpanNodes.LastOrDefault(); if (titleNode == null) { continue; } var title = titleNode.InnerText.Trim(); var commentNode = subtitleNode.ParentNode.SelectSingleNode(".//td[@class='a6']/div"); string description = string.Empty; if (commentNode != null) { description = commentNode.InnerText.Trim(); } description = HttpUtility.HtmlDecode(description.Replace(Environment.NewLine, " ")); title = HttpUtility.HtmlDecode(title); var url = BaseUrl + "/" + link; subtitles.Add(new Subtitle(title, description + " [Subscene.com]", url, rating, this)); } result = Status.Success; } return new QueryResult<Subtitles>(result, subtitles); }
private void ExtractInfo(string filePath, string pathToDll, NumberFormatInfo providerNumber) { using (var mediaInfo = new MediaInfo(pathToDll)) { Version = mediaInfo.Option("Info_Version"); mediaInfo.Open(filePath); var streamNumber = 0; // Setup videos for (var i = 0; i < mediaInfo.CountGet(StreamKind.Video); ++i) { VideoStreams.Add(new VideoStreamBuilder(mediaInfo, streamNumber++, i).Build()); } if (VideoDuration == 0) { double duration; double.TryParse( mediaInfo.Get(StreamKind.Video, 0, "Duration"), NumberStyles.AllowDecimalPoint, providerNumber, out duration); VideoDuration = (int)duration; } // Setup audios for (var i = 0; i < mediaInfo.CountGet(StreamKind.Audio); ++i) { AudioStreams.Add(new AudioStreamBuilder(mediaInfo, streamNumber++, i).Build()); } // Setup subtitles for (var i = 0; i < mediaInfo.CountGet(StreamKind.Text); ++i) { Subtitles.Add(new SubtitleStreamBuilder(mediaInfo, streamNumber++, i).Build()); } // Setup chapters for (var i = 0; i < mediaInfo.CountGet(StreamKind.Other); ++i) { Chapters.Add(new ChapterStreamBuilder(mediaInfo, streamNumber++, i).Build()); } // Setup menus for (var i = 0; i < mediaInfo.CountGet(StreamKind.Menu); ++i) { MenuStreams.Add(new MenuStreamBuilder(mediaInfo, streamNumber++, i).Build()); } MediaInfoNotloaded = VideoStreams.Count == 0 && AudioStreams.Count == 0 && Subtitles.Count == 0; // Produce copability properties if (MediaInfoNotloaded) { SetPropertiesDefault(); } else { SetupProperties(mediaInfo); } } }
public void ReadStreamInfo() { List <string> output = new List <string>(); //the list that holds the mkvInfo output try { //create the process that will execute mkvinfo. Hide the cmd window and redirect the output Process p = new Process(); p.StartInfo = new ProcessStartInfo(Path, "\"" + mkvPath + "\""); //assign the argument p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.Start(); StreamReader reader = p.StandardOutput; Tools.WriteLogLine("Mkv Command: " + Path + " \"" + mkvPath + "\""); //add each line of the output to the output list while (!reader.EndOfStream) { string line = reader.ReadLine(); if (line.Length > 0) { output.Add(line); Tools.WriteLogLine(line); } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Unable to execute MkvInfo:" + Environment.NewLine + ex.ToString()); } //search the output list for audio and subtitle streams for (int i = 0; i < output.Count; i++) { if (output[i].Contains("Track type: subtitles") || output[i].Contains("Track type: audio") || output[i].Contains("Track type: video")) { //instantiate temporary variables int uid = -1; string language = "Unknown"; bool isDefault = true; StreamType stream = StreamType.Unknown; string codec = "Unknown"; if (output[i].Contains("Track type: subtitles")) { stream = StreamType.Subtitles; } if (output[i].Contains("Track type: audio")) { stream = StreamType.Audio; } if (output[i].Contains("Track type: video")) { stream = StreamType.Video; } //parse the id number Match trackNumberMatch = Regex.Match(output[i - 2], @"Track number: \d+ \(track ID for mkvmerge & mkvextract: (?<trackNumber>\d+)\)"); if (trackNumberMatch.Success) { uid = Convert.ToInt32(trackNumberMatch.Groups["trackNumber"].Value); } else { Match trackNumberMatch2 = Regex.Match(output[i - 3], @"Track number: \d+ \(track ID for mkvmerge & mkvextract: (?<trackNumber>\d+)\)"); if (trackNumberMatch2.Success) { uid = Convert.ToInt32(trackNumberMatch2.Groups["trackNumber"].Value); } } //get other stream info for (int j = i; j < output.Count; j++) { try { if (output[j].Contains("+ Language:")) { Match languageMatch = Regex.Match(output[j], @"^.+: (?<language>.*$)"); if (languageMatch.Success) { language = languageMatch.Groups["language"].Value; } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } try { if (output[j].Contains("+ Codec ID:")) { codec = output[j].Substring(15); } //System.Windows.Forms.MessageBox.Show(j.ToString()); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } try { if (output[j].Contains("+ Default flag: 0")) { isDefault = false; } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } //when the search reaches the next stream, stop if (output[j].Contains("A track")) { i = j; break; } } //add the stream info to the appropriate list if (stream == StreamType.Subtitles) { Subtitles.Add(new MkvInfoStreamInfo(uid, codec, language, isDefault, stream)); } if (stream == StreamType.Audio) { AudioStreams.Add(new MkvInfoStreamInfo(uid, codec, language, isDefault, stream)); } if (stream == StreamType.Video) { VideoStreams.Add(new MkvInfoStreamInfo(uid, codec, language, isDefault, stream)); } } if (output[i].Contains("+ Chapters")) { for (int j = i; j < output.Count; j++) { if (output[j].Contains("+ ChapterAtom")) { Chapters.AddChapter(); } } } } }
private void ExtractInfo(string filePath, NumberFormatInfo providerNumber) #endif { #if (NET40 || NET45) using (var mediaInfo = new MediaInfo(pathToDll)) #else using (var mediaInfo = new MediaInfo()) #endif { if (mediaInfo.Handle == IntPtr.Zero) { MediaInfoNotloaded = true; _logger.LogWarning("MediaInfo library was not loaded!"); return; } else { Version = mediaInfo.Option("Info_Version"); _logger.LogDebug($"MediaInfo library was loaded. Handle={mediaInfo.Handle} Version is {Version}"); } var filePricessingHandle = mediaInfo.Open(filePath); if (filePricessingHandle == IntPtr.Zero) { MediaInfoNotloaded = true; _logger.LogWarning($"MediaInfo library has not been opened media {filePath}"); return; } else { _logger.LogDebug($"MediaInfo library successfully opened {filePath}. Handle={filePricessingHandle}"); } var streamNumber = 0; Tags = new AudioTagBuilder(mediaInfo, 0).Build(); // Setup videos for (var i = 0; i < mediaInfo.CountGet(StreamKind.Video); ++i) { VideoStreams.Add(new VideoStreamBuilder(mediaInfo, streamNumber++, i).Build()); } if (Duration == 0) { double.TryParse( mediaInfo.Get(StreamKind.Video, 0, (int)NativeMethods.Video.Video_Duration), NumberStyles.AllowDecimalPoint, providerNumber, out var duration); Duration = (int)duration; } // Fix 3D for some containers if (VideoStreams.Count == 1 && Tags.GeneralTags.TryGetValue((NativeMethods.General) 1000, out var isStereo)) { var video = VideoStreams.First(); if (Tags.GeneralTags.TryGetValue((NativeMethods.General) 1001, out var stereoMode)) { video.Stereoscopic = (StereoMode)stereoMode; } else { video.Stereoscopic = (bool)isStereo ? StereoMode.Stereo : StereoMode.Mono; } } // Setup audios for (var i = 0; i < mediaInfo.CountGet(StreamKind.Audio); ++i) { AudioStreams.Add(new AudioStreamBuilder(mediaInfo, streamNumber++, i).Build()); } if (Duration == 0) { double.TryParse( mediaInfo.Get(StreamKind.Audio, 0, (int)NativeMethods.Audio.Audio_Duration), NumberStyles.AllowDecimalPoint, providerNumber, out var duration); Duration = (int)duration; } // Setup subtitles for (var i = 0; i < mediaInfo.CountGet(StreamKind.Text); ++i) { Subtitles.Add(new SubtitleStreamBuilder(mediaInfo, streamNumber++, i).Build()); } // Setup chapters for (var i = 0; i < mediaInfo.CountGet(StreamKind.Other); ++i) { Chapters.Add(new ChapterStreamBuilder(mediaInfo, streamNumber++, i).Build()); } // Setup menus for (var i = 0; i < mediaInfo.CountGet(StreamKind.Menu); ++i) { MenuStreams.Add(new MenuStreamBuilder(mediaInfo, streamNumber++, i).Build()); } MediaInfoNotloaded = VideoStreams.Count == 0 && AudioStreams.Count == 0 && Subtitles.Count == 0; // Produce capability properties if (MediaInfoNotloaded) { SetPropertiesDefault(); } else { SetupProperties(mediaInfo); } } }
public static void Patch_Player_Water() { //int[] TechTypes = new int[] { 4500, 808, 4501, 4516 }; /*bool consoleOpened = (bool)typeof(DevConsole).GetField("state", BindingFlags.NonPublic | * BindingFlags.Instance).GetValue(typeof(DevConsole).GetField("instance", BindingFlags.NonPublic | * BindingFlags.Static).GetValue(null));*/ Inventory pInventory = Inventory.main; IList <InventoryItem> filteredWater = pInventory.container.GetItems(TechType.FilteredWater); IList <InventoryItem> stillSuitWater = pInventory.container.GetItems(TechType.StillsuitWater); IList <InventoryItem> disinfectedWater = pInventory.container.GetItems(TechType.DisinfectedWater); IList <InventoryItem> bigfilteredWater = pInventory.container.GetItems(TechType.BigFilteredWater); IList <InventoryItem> cOffee = pInventory.container.GetItems(TechType.Coffee); if (Input.GetKeyDown(Config.WaterHotKey) && Config.ToggleWaterHotKey == false && !MainPatch.EditNameCheck) { if (Config.TextValue == 0) { ErrorMessage.AddWarning("You have Disabled The Water Hotkey"); } else if (Config.TextValue == 1) { Subtitles.Add("You Have Disabled The Water Hotkey"); } } else if (Input.GetKeyDown(Config.WaterHotKey) && Config.ToggleWaterHotKey == true && !MainPatch.EditNameCheck) { if (Player.main.GetComponent <Survival>().water <= Config.WaterPercentage) { if (filteredWater != null) { pInventory.ExecuteItemAction(ItemAction.Eat, filteredWater.First()); } else if (stillSuitWater != null) { pInventory.ExecuteItemAction(ItemAction.Eat, stillSuitWater.First()); } else if (disinfectedWater != null) { pInventory.ExecuteItemAction(ItemAction.Eat, disinfectedWater.First()); } else if (bigfilteredWater != null) { pInventory.ExecuteItemAction(ItemAction.Eat, bigfilteredWater.First()); } else if (cOffee != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cOffee.First()); } else { if (Config.TextValue == 0) { ErrorMessage.AddWarning("You Do Not Have Any Drinkable Items In your Inventory"); } else if (Config.TextValue == 1) { Subtitles.Add("You Do Not Have Any Drinkable Items In your Inventory"); } } } else { if (Config.TextValue == 0) { ErrorMessage.AddWarning("You Do Not Need A Drink, You're Not Thirsty"); } else if (Config.TextValue == 1) { Subtitles.Add("You Do Not Need A Drink, You're Not Thirsty"); } } } }
public static void Patch_Player_Food_Drink() { Inventory pInventory = Inventory.main; List <InventoryItem> foodDrink = new List <InventoryItem>(); if (pInventory.container.itemsMap != null) { foreach (var test in pInventory.container.itemsMap) { var itemAction = pInventory.GetAllItemActions(test); if (test != null) { if (itemAction == ItemAction.Eat) { if (!test.item.GetComponent <Thermos>()) { foodDrink.Add(test); } } } } } if (!MainPatch.EditNameCheck) { if (Input.GetKeyDown(MainPatch.FoodDrinkHotKey)) { if (MainPatch.ToggleFoodDrink) { if (Player.main.GetComponent <Survival>().food <= MainPatch.FoodDrinkPercentage || Player.main.GetComponent <Survival>().water <= MainPatch.FoodDrinkPercentage) { if (foodDrink.Count > 0) { pInventory.ExecuteItemAction(ItemAction.Eat, foodDrink.First()); } else { if (MainPatch.TextValue == "Standard") { ErrorMessage.AddWarning("You Do Not Have Any Eatable/Drinkable Items In your Inventory"); } else if (MainPatch.TextValue == "Subtitles") { Subtitles.Add("You Do Not Have Any Eatable/Drinkable Items In your Inventory"); } } } else { if (MainPatch.TextValue == "Standard") { ErrorMessage.AddWarning($"You Do Not Need To Eat Or Drink, Your Food And Drink is Already Above {MainPatch.FoodDrinkPercentage}"); } else if (MainPatch.TextValue == "Subtitles") { Subtitles.Add($"You Do Not Need To Eat Or Drink, Your Food And Drink is Already Above {MainPatch.FoodDrinkPercentage}"); } } } else { if (MainPatch.TextValue == "Standard") { ErrorMessage.AddWarning("You have Disabled The Food/Drink Hotkey"); } else if (MainPatch.TextValue == "Subtitles") { Subtitles.Add("You Have Disabled The Food/Drink Hotkey"); } } } } }
public static void Patch_Player_Food() { /*bool consoleOpened = (bool)typeof(DevConsole).GetField("state", BindingFlags.NonPublic | * BindingFlags.Instance).GetValue(typeof(DevConsole).GetField("instance", BindingFlags.NonPublic | * BindingFlags.Static).GetValue(null));*/ Inventory pInventory = Inventory.main; //CookedFood IList <InventoryItem> cookedBladderFish = pInventory.container.GetItems(TechType.CookedBladderfish); IList <InventoryItem> cookedBoomerang = pInventory.container.GetItems(TechType.CookedBoomerang); IList <InventoryItem> cookedEyeeye = pInventory.container.GetItems(TechType.CookedEyeye); IList <InventoryItem> cookedGarryFish = pInventory.container.GetItems(TechType.CookedGarryFish); IList <InventoryItem> cookedHoleFish = pInventory.container.GetItems(TechType.CookedHoleFish); IList <InventoryItem> cookedHoopFish = pInventory.container.GetItems(TechType.CookedHoopfish); IList <InventoryItem> cookedHoverFish = pInventory.container.GetItems(TechType.CookedHoverfish); IList <InventoryItem> cookedLavaBoomerang = pInventory.container.GetItems(TechType.CookedLavaBoomerang); IList <InventoryItem> cookedLavaEyeeye = pInventory.container.GetItems(TechType.CookedLavaEyeye); IList <InventoryItem> cookedOculus = pInventory.container.GetItems(TechType.CookedOculus); IList <InventoryItem> cookedPeeper = pInventory.container.GetItems(TechType.CookedArcticPeeper); IList <InventoryItem> cookedReginald = pInventory.container.GetItems(TechType.CookedReginald); IList <InventoryItem> cookedSpadeFish = pInventory.container.GetItems(TechType.CookedSpadefish); IList <InventoryItem> cookedSpineFish = pInventory.container.GetItems(TechType.CookedSpinefish); IList <InventoryItem> cookedArrowRay = pInventory.container.GetItems(TechType.CookedArrowRay); IList <InventoryItem> cookedFeatherFish = pInventory.container.GetItems(TechType.CookedFeatherFish); IList <InventoryItem> cookedFeatherFishRed = pInventory.container.GetItems(TechType.CookedFeatherFishRed); IList <InventoryItem> cookedNootFish = pInventory.container.GetItems(TechType.CookedNootFish); IList <InventoryItem> cookedSpinnerFish = pInventory.container.GetItems(TechType.CookedSpinnerfish); IList <InventoryItem> cookedSymbiote = pInventory.container.GetItems(TechType.CookedSymbiote); IList <InventoryItem> cookedTriops = pInventory.container.GetItems(TechType.CookedTriops); //Cured Food IList <InventoryItem> curedBladderFish = pInventory.container.GetItems(TechType.CuredBladderfish); IList <InventoryItem> curedBoomerang = pInventory.container.GetItems(TechType.CuredBoomerang); IList <InventoryItem> curedEyeeye = pInventory.container.GetItems(TechType.CuredEyeye); IList <InventoryItem> curedGarryFish = pInventory.container.GetItems(TechType.CuredGarryFish); IList <InventoryItem> curedHoleFish = pInventory.container.GetItems(TechType.CuredHoleFish); IList <InventoryItem> curedHoopFish = pInventory.container.GetItems(TechType.CuredHoopfish); IList <InventoryItem> curedHoverFish = pInventory.container.GetItems(TechType.CuredHoverfish); IList <InventoryItem> curedLavaBoomerang = pInventory.container.GetItems(TechType.CuredLavaBoomerang); IList <InventoryItem> curedLavaEyeeye = pInventory.container.GetItems(TechType.CuredLavaEyeye); IList <InventoryItem> curedOculus = pInventory.container.GetItems(TechType.CuredOculus); IList <InventoryItem> curedPeeper = pInventory.container.GetItems(TechType.CuredPeeper); IList <InventoryItem> curedarcticPeeper = pInventory.container.GetItems(TechType.CuredArcticPeeper); IList <InventoryItem> curedReginald = pInventory.container.GetItems(TechType.CuredReginald); IList <InventoryItem> curedSpadeFish = pInventory.container.GetItems(TechType.CuredSpadefish); IList <InventoryItem> curedSpineFish = pInventory.container.GetItems(TechType.CuredSpinefish); IList <InventoryItem> curedArrowRay = pInventory.container.GetItems(TechType.CuredArrowRay); IList <InventoryItem> curedFeatherFish = pInventory.container.GetItems(TechType.CuredFeatherFish); IList <InventoryItem> curedFeatherFishRed = pInventory.container.GetItems(TechType.CuredFeatherFishRed); IList <InventoryItem> curedNootFish = pInventory.container.GetItems(TechType.CuredNootFish); IList <InventoryItem> curedSpinnerFish = pInventory.container.GetItems(TechType.CuredSpinnerfish); IList <InventoryItem> curedSymbiote = pInventory.container.GetItems(TechType.CuredSymbiote); IList <InventoryItem> curedTriops = pInventory.container.GetItems(TechType.CuredTriops); //Vegies and fruits IList <InventoryItem> bulboTreeFruit = pInventory.container.GetItems(TechType.BulboTreePiece); IList <InventoryItem> chinaPotato = pInventory.container.GetItems(TechType.PurpleVegetable); IList <InventoryItem> laternFruit = pInventory.container.GetItems(TechType.HangingFruit); IList <InventoryItem> marbleMelon = pInventory.container.GetItems(TechType.Melon); //Snacks and Nutrient Block IList <InventoryItem> nutBlock = pInventory.container.GetItems(TechType.NutrientBlock); IList <InventoryItem> snacks1 = pInventory.container.GetItems(TechType.Snack1); IList <InventoryItem> snacks2 = pInventory.container.GetItems(TechType.Snack2); IList <InventoryItem> snacks3 = pInventory.container.GetItems(TechType.Snack3); if (Input.GetKeyDown(Config.FoodHotKey) && Config.ToggleFoodHotKey == false && !MainPatch.EditNameCheck) { if (Config.TextValue == 0) { ErrorMessage.AddWarning("You have Disabled The Food Hotkey"); } else if (Config.TextValue == 1) { Subtitles.Add("You Have Disabled The Food Hotkey"); } } else if (Input.GetKeyDown(Config.FoodHotKey) && Config.ToggleFoodHotKey == true && !MainPatch.EditNameCheck) { if (Player.main.GetComponent <Survival>().food <= Config.FoodPercentage) { //Cooked if (cookedBladderFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedBladderFish.First()); } else if (cookedBoomerang != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedBoomerang.First()); } else if (cookedEyeeye != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedEyeeye.First()); } else if (cookedGarryFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedGarryFish.First()); } else if (cookedHoleFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedHoleFish.First()); } else if (cookedHoopFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedHoopFish.First()); } else if (cookedHoverFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedHoverFish.First()); } else if (cookedLavaBoomerang != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedLavaBoomerang.First()); } else if (cookedLavaEyeeye != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedLavaEyeeye.First()); } else if (cookedOculus != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedOculus.First()); } else if (cookedPeeper != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedPeeper.First()); } else if (cookedReginald != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedReginald.First()); } else if (cookedSpadeFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedSpadeFish.First()); } else if (cookedSpineFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedSpineFish.First()); } else if (cookedArrowRay != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedArrowRay.First()); } else if (cookedFeatherFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedFeatherFish.First()); } else if (cookedFeatherFishRed != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedFeatherFishRed.First()); } else if (cookedNootFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedNootFish.First()); } else if (cookedFeatherFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedFeatherFish.First()); } else if (cookedSpinnerFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedSpinnerFish.First()); } else if (cookedSymbiote != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedSymbiote.First()); } else if (cookedTriops != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedTriops.First()); } //Cured else if (curedBladderFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedBladderFish.First()); } else if (curedBoomerang != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedBoomerang.First()); } else if (curedEyeeye != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedEyeeye.First()); } else if (curedGarryFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedGarryFish.First()); } else if (curedHoleFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedHoleFish.First()); } else if (curedHoopFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedHoopFish.First()); } else if (curedHoverFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedHoverFish.First()); } else if (curedLavaBoomerang != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedLavaBoomerang.First()); } else if (curedLavaEyeeye != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedLavaEyeeye.First()); } else if (curedOculus != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedOculus.First()); } else if (curedPeeper != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedPeeper.First()); } else if (curedReginald != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedReginald.First()); } else if (curedSpadeFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedSpadeFish.First()); } else if (curedSpineFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedSpineFish.First()); } else if (cookedArrowRay != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedArrowRay.First()); } else if (cookedFeatherFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedFeatherFish.First()); } else if (cookedFeatherFishRed != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedFeatherFishRed.First()); } else if (cookedNootFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, cookedNootFish.First()); } else if (curedFeatherFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedFeatherFish.First()); } else if (curedSpinnerFish != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedSpinnerFish.First()); } else if (curedSymbiote != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedSymbiote.First()); } else if (curedTriops != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedTriops.First()); } else if (curedarcticPeeper != null) { pInventory.ExecuteItemAction(ItemAction.Eat, curedarcticPeeper.First()); } //Vegies and Fruit else if (bulboTreeFruit != null) { pInventory.ExecuteItemAction(ItemAction.Eat, bulboTreeFruit.First()); } else if (chinaPotato != null) { pInventory.ExecuteItemAction(ItemAction.Eat, chinaPotato.First()); } else if (laternFruit != null) { pInventory.ExecuteItemAction(ItemAction.Eat, laternFruit.First()); } else if (marbleMelon != null) { pInventory.ExecuteItemAction(ItemAction.Eat, marbleMelon.First()); } else if (nutBlock != null) { pInventory.ExecuteItemAction(ItemAction.Eat, nutBlock.First()); } else if (snacks1 != null) { pInventory.ExecuteItemAction(ItemAction.Eat, snacks1.First()); } else if (snacks2 != null) { pInventory.ExecuteItemAction(ItemAction.Eat, snacks2.First()); } else if (snacks3 != null) { pInventory.ExecuteItemAction(ItemAction.Eat, snacks3.First()); } else { if (Config.TextValue == 0) { ErrorMessage.AddWarning("You Do Not Have Any Eatable Items In your Inventory"); } else if (Config.TextValue == 1) { Subtitles.Add("You Do Not Have Any Eatable Items In your Inventory"); } } } else { if (Config.TextValue == 0) { ErrorMessage.AddWarning("You Do Not Need Too Eat, You're Not Hungry"); } else if (Config.TextValue == 1) { Subtitles.Add("You Do Not Need Too Eat, You're Not Hungry"); } } } }
public static void Patch_Player_Health() { /*bool consoleOpened = (bool)typeof(DevConsole).GetField("state", BindingFlags.NonPublic | * BindingFlags.Instance).GetValue(typeof(DevConsole).GetField("instance", BindingFlags.NonPublic | * BindingFlags.Static).GetValue(null));*/ Inventory pInventory = Inventory.main; IList <InventoryItem> medKit = pInventory.container.GetItems(TechType.FirstAidKit); if (Input.GetKeyDown(Config.MedHotKey) && Config.ToggleMedHotKey == false && !MainPatch.EditNameCheck) { if (Config.TextValue == 0) { ErrorMessage.AddWarning("You have Disabled The MedKit Hotkey"); } else if (Config.TextValue == 1) { Subtitles.Add("You Have Disabled The MedKit Hotkey"); } } else if (Input.GetKeyDown(Config.MedHotKey) && Config.ToggleMedHotKey == true && !MainPatch.EditNameCheck) { #if DEBUG Debug.Log($"[WaterDrinkHotkey] :: PlayerHealth is {Player.main.GetComponent<LiveMixin>().health}"); Debug.Log($"[WaterDrinkHotkey] :: Player Creative Gamemode is {GameModeUtils.IsOptionActive(GameModeOption.Creative)}"); Debug.Log($"[WaterDrinkHotkey] :: Player NoSurvival Gamemode is {GameModeUtils.IsOptionActive(GameModeOption.NoSurvival)}"); Debug.Log($"[WaterDrinkHotkey] :: Player Freedom Gamemode is {GameModeUtils.IsOptionActive(GameModeOption.Freedom)}"); Debug.Log($"[WaterDrinkHotkey] :: Player Survival Gamemode is {GameModeUtils.IsOptionActive(GameModeOption.Survival)}"); #endif if (Player.main.GetComponent <LiveMixin>().health <= Config.HealthPercentage) { if (medKit != null) { pInventory.ExecuteItemAction(ItemAction.Use, medKit.First()); } else { if (Config.TextValue == 0) { ErrorMessage.AddWarning("You Do Not Have Any MedKits In your Inventory"); } else if (Config.TextValue == 1) { Subtitles.Add("You Do Not Have Any MedKits In your Inventory"); } } } else { if (Config.TextValue == 0) { ErrorMessage.AddWarning($"You Do not need to use a FirstAidKit Your health is already above {Config.HealthPercentage}"); } else if (Config.TextValue == 1) { Subtitles.Add($"You Do not need to use a FirstAidKit Your health is already above {Config.HealthPercentage }"); } } } }
public static void Patch_Player_Heat() { Inventory pInventory = Inventory.main; List <InventoryItem> heatItems = new List <InventoryItem>(); if (pInventory.container.itemsMap != null) { foreach (var test in pInventory.container.itemsMap) { if (test != null) { if (test.item.GetComponent <Thermos>()) { heatItems.Add(test); } } } } if (!MainPatch.EditNameCheck) { if (Input.GetKeyDown(MainPatch.HeatHotkey)) { if (MainPatch.ToggleHeatHotKey) { if (Player.main.GetComponent <Survival>().bodyTemperature.currentBodyHeatValue <= MainPatch.HeatPercentage) { if (heatItems.Count > 0) { pInventory.ExecuteItemAction(ItemAction.Eat, heatItems.First()); } else { if (MainPatch.TextValue == "Standard") { ErrorMessage.AddWarning("You Do Not Have Any Thermos In your Inventory"); } else if (MainPatch.TextValue == "Subtitles") { Subtitles.Add("You Do Not Have Any Thermos In your Inventory"); } } } else { if (MainPatch.TextValue == "Standard") { ErrorMessage.AddWarning($"You Do Not Need To Use a Thermos Your Heat is Already Above {MainPatch.HeatPercentage}"); } else if (MainPatch.TextValue == "Subtitles") { Subtitles.Add($"You Do Not Need To Use a Thermos Your Heat is Already Above {MainPatch.HeatPercentage}"); } } } else { if (MainPatch.TextValue == "Standard") { ErrorMessage.AddWarning("You Have Disabled The Thermos Hotkey"); } else if (MainPatch.TextValue == "Subtitles") { Subtitles.Add("You Have Disabled The Thermos Hotkey"); } } } } }