public override void Core_Update() { try { List.Clear(); Patches.Clear(); string[] files = Directory.GetFiles(Core.Path_Patches); foreach (string file in files) { if (file.EndsWith(".feh", StringComparison.OrdinalIgnoreCase)) { HackManager patch = new HackManager(); patch.OpenFile(file); Patches.Add(patch); List.Add(Tuple.Create( patch.HackAuthor, patch.HackName, patch.IsApplied())); } } } catch (Exception ex) { Program.ShowError("The patch list could not be loaded onscreen.", ex); } }
public void Dispose() { foreach (var patch in Patches) { patch.Disable(); // this could also be done with Dispose } Patches.Clear(); }
public void DoSearch() { foreach (var card in Cards) { card.IsDisplayed = true; } foreach (var card in Cards) { var isNameMatch = string.IsNullOrEmpty(CardNameSearch) ? true : card.Info.Name.ToLower().Contains(CardNameSearch.ToLower()); var isPatchMatch = string.IsNullOrEmpty(PatchSearch) ? true : card.Info.Patch.Contains(PatchSearch); var isNpcMatch = string.IsNullOrEmpty(NPCNameSearch) ? true : card.Info.NPCs.FirstOrDefault(n => n.ToLower().Contains(NPCNameSearch.ToLower())) != null; var isMinDifficultyMatch = string.IsNullOrEmpty(MinDifficultySearch) ? true : card.Difficulty >= int.Parse(MinDifficultySearch); var isMaxDifficultyMatch = string.IsNullOrEmpty(MaxDifficultySearch) ? true : card.Difficulty <= int.Parse(MaxDifficultySearch); var isCollectionMatch = string.IsNullOrEmpty(CollectedSearch) || CollectedSearch == "No Preference" ? true : (CollectedSearch == "Collected" && card.IsCollected) || (CollectedSearch == "Uncollected" && !card.IsCollected); card.IsDisplayed = isNameMatch && isPatchMatch && isNpcMatch && isMinDifficultyMatch && isMaxDifficultyMatch && isCollectionMatch; } // store fields for resetting later var cardName = CardNameSearch; var patch = PatchSearch; var npcName = NPCNameSearch; CardNames.Clear(); Patches.Clear(); NPCNames.Clear(); var displayedCards = Cards.Where(c => c.IsDisplayed); foreach (var displayedCard in displayedCards) { if (!CardNames.Contains(displayedCard.Info.Name)) { CardNames.Add(displayedCard.Info.Name); } if (!Patches.Contains(displayedCard.Info.Patch)) { Patches.Add(displayedCard.Info.Patch); } foreach (var npc in displayedCard.Info.NPCs) { if (!NPCNames.Contains(npc)) { NPCNames.Add(npc); } } } // set fields back after the search CardNameSearch = cardName; PatchSearch = patch; NPCNameSearch = npcName; }
public void ReloadPatches() { foreach (var patch in Patches) { patch.Disable(); } Patches.Clear(); LoadPatches(); }
public void Patch() { foreach (int patch in Patches) { long address = Address; int @int = VMB.GetInt(patch); int value = VMBuffer.EncodeInstructionBranch(VMBuffer.GetInstruction(@int), patch); VMB.SetInt(patch, value); } Patches.Clear(); }
public override void Draw() { Patches.Clear(); UISys.Skin().DrawBox((int)WidX, (int)WidY, (int)WidW, (int)WidH); UISys.Skin().DrawBoxText((int)(WidX + WidW / 2 - UISys.Skin().SmallFont.Width(Name) / 2), (int)WidY + 8, Name); int oy = Scroll.Current; int dy = 25 - oy; sy = -1; ey = -1; foreach (var i in ItemRoot.Sub) { dy = DrawItem(i, dy); } Scroll.Max = (dy + oy); Scroll.ViewH = (ey - sy); Scroll.Rebuild(); }
private void BuildPatches() { var points = GetVoronoiPoints(NumPatches, Center).ToList(); var v = Voronoi.Build(points); for (var i = 0; i < 3; i++) { var toRelax = v.Points.Take(3).ToList(); toRelax.Add(v.Points[NumPatches]); v = Voronoi.Relax(v, toRelax); } v = Voronoi.Relax(v); var comparer = new Vector2LengthComparer(); v.Points.Sort(comparer); var regions = v.Partitioning(); Patches.Clear(); foreach (var region in regions) { Patches.Add(Patch.FromRegion(this, region)); } var patchesInTown = Patches.OrderBy(p => (Center - p.Center).magnitude).Take(NumPatches).ToList(); // Find random patch at the outside of town to place water if (Options.Water) { var firstWaterPatch = patchesInTown.Where(p => p.GetAllNeighbours().Any(n => !n.WithinCity)) .OrderBy(p => Random.value).First(); firstWaterPatch.Water = true; Vector2 waterDirection = (firstWaterPatch.Center - Center).normalized; var toCheck = new List <Patch> { firstWaterPatch }; while (toCheck.Any()) { var checking = toCheck[0]; toCheck.RemoveAt(0); var waterPatches = checking.GetAllNeighbours().Except(patchesInTown) .Where(n => Math.Abs(GeometryHelpers.AngleComparedTo(Center - n.Center, waterDirection)) < Math.PI / 4) .Where(n => !n.Water).ToList(); foreach (var waterPatch in waterPatches) { waterPatch.Water = true; toCheck.Add(waterPatch); } } } patchesInTown = Patches.Where(p => !p.Water).OrderBy(p => (Center - p.Center).magnitude).Take(NumPatches) .ToList(); foreach (var patch in patchesInTown) { patch.WithinCity = true; patch.WithinWalls = true; } Castle = new Castle(patchesInTown.Last()); Market = patchesInTown.First(); Market.IsCityCenter = true; var circumference = FindCircumference(patchesInTown); var smoothAmount = Math.Min(1f, 40f / circumference.Vertices.Count); if (Options.Walls) { SmoothPatches(circumference, smoothAmount); } if (Options.Water) { var waterCircumference = FindCircumference(Patches.Where(p => p.Water)); SmoothPatches(waterCircumference, 0.2f); WaterBorder.Clear(); WaterBorder.AddRange(waterCircumference.Vertices); } }
internal void ComputeTrajectory() { if (!VesselHasParts)// || AttachedVessel.LandedOrSplashed) { increment_time = 0d; Patches.Clear(); return; } try { // start of trajectory calculation in current frame increment_time = Util.Clocks; // create or update aerodynamic model if (aerodynamicModel_ == null || !aerodynamicModel_.IsValidFor(AttachedVessel.mainBody)) { aerodynamicModel_ = AerodynamicModelFactory.GetModel(this, AttachedVessel.mainBody); } else { aerodynamicModel_.UpdateVesselMass(); } // if there is no ongoing partial computation, start a new one if (partialComputation_ == null) { //total_time = Util.Clocks; // restart the public buffers patchesBackBuffer_.Clear(); maxAccelBackBuffer_ = 0; // Create enumerator for Trajectory increment calculator partialComputation_ = ComputeTrajectoryIncrement().GetEnumerator(); } // we are finished when there are no more partial computations to be done bool finished = !partialComputation_.MoveNext(); // when calculation is finished, if (finished) { // swap the buffers for the patches and the maximum acceleration, // "publishing" the results List <Patch> tmp = Patches; Patches = patchesBackBuffer_; patchesBackBuffer_ = tmp; MaxAccel = maxAccelBackBuffer_; // Reset partial computation partialComputation_.Dispose(); partialComputation_ = null; // how long did the whole calculation take? //total_time = Util.ElapsedMilliseconds(total_time); } // how long did the calculation in this frame take? increment_time = Util.ElapsedMilliseconds(increment_time); } catch (Exception) { ++ErrorCount; throw; } }