/// <summary> /// checks for chained cascade targets. this is expensive as the theoretical linked distance is 200 yds /// if all 4 hops occur and mobs are in straight line. regardless, this ability can easily aggro the /// entire countryside while questing, so we will be conservative in our assessment of whether it can /// be used or not while still maximizing the number of mobs hit based upon the initial targets proximity /// to linked mobs /// </summary> /// <returns></returns> public static WoWUnit GetBestCascadeTarget() { if (!Spell.CanCastHack("Cascade", Me, skipWowCheck: true)) { Logger.WriteDebug("GetBestCascadeTarget: CanCastHack says NO to Cascade"); return(null); } // search players we are facing in range for the number of hops they represent var targetInfo = Unit.UnfriendlyUnits() .Where(u => u.SpellDistance() < 40 && Me.IsSafelyFacing(u) && u.InLineOfSpellSight) .Select(p => new { Unit = p, Count = Clusters.GetChainedClusterCount(p, Unit.UnfriendlyUnits(), 40f, AvoidAttackingTarget) }) .OrderByDescending(v => v.Count) // maximize count .OrderByDescending(v => (int)v.Unit.DistanceSqr) // maximize initial distance .DefaultIfEmpty(null) .FirstOrDefault(); if (targetInfo == null) { Logger.WriteDiagnostic("GetBestCascadeTarget: 0 mobs without unwanted aggro / cc break"); return(null); } Logger.WriteDiagnostic( "GetBestCascadeTarget: {0} will hit {1} mobs without unwanted aggro / cc break", targetInfo.Unit.SafeName(), targetInfo.Count ); return(targetInfo.Unit); }
public static Composite CreateMageFireInstancePullAndCombat() { return(new PrioritySelector( Safers.EnsureTarget(), Movement.CreateMoveToLosBehavior(), Movement.CreateFaceTargetBehavior(), Helpers.Common.CreateAutoAttack(true), Spell.WaitForCast(true), // Defensive stuff new Decorator( ret => StyxWoW.Me.ActiveAuras.ContainsKey("Ice Block"), new ActionIdle()), Spell.BuffSelf("Ice Block", ret => StyxWoW.Me.HealthPercent < 20 && !StyxWoW.Me.ActiveAuras.ContainsKey("Hypothermia")), // Cooldowns Spell.BuffSelf("Evocation", ret => StyxWoW.Me.ManaPercent < 30), Spell.BuffSelf("Mirror Image"), Spell.BuffSelf("Mage Ward", ret => StyxWoW.Me.HealthPercent <= 75), Common.CreateUseManaGemBehavior(ret => StyxWoW.Me.ManaPercent < 80), // AoE comes first new Decorator( ret => Unit.UnfriendlyUnitsNearTarget(10f).Count() >= 3, new PrioritySelector( Spell.Cast("Fire Blast", ret => StyxWoW.Me.ActiveAuras.ContainsKey("Impact") && (StyxWoW.Me.CurrentTarget.HasMyAura("Combustion") || TalentManager.IsSelected(13))), Spell.CastOnGround("Blast Wave", ret => Clusters.GetBestUnitForCluster(Unit.NearbyUnitsInCombatWithMe, ClusterType.Radius, 8f).Location), Spell.Cast("Dragon's Breath", ret => Clusters.GetClusterCount(StyxWoW.Me, Unit.NearbyUnitsInCombatWithMe, ClusterType.Cone, 15f) >= 3), Spell.CastOnGround("Flamestrike", ret => Clusters.GetBestUnitForCluster(Unit.NearbyUnitsInCombatWithMe, ClusterType.Radius, 8f).Location, ret => !ObjectManager.GetObjectsOfType <WoWDynamicObject>().Any(o => o.CasterGuid == StyxWoW.Me.Guid && o.Spell.Name == "Flamestrike" && o.Location.Distance( Clusters.GetBestUnitForCluster(Unit.NearbyUnitsInCombatWithMe, ClusterType.Radius, 8f).Location) < o.Radius)) )), Spell.BuffSelf("Time Warp", ret => !StyxWoW.Me.GroupInfo.IsInRaid && StyxWoW.Me.CurrentTarget.HealthPercent > 20 && StyxWoW.Me.CurrentTarget.IsBoss() && !StyxWoW.Me.HasAura("Temporal Displacement")), // Rotation Spell.Cast("Frostfire Bolt", ret => StyxWoW.Me.CurrentTarget.IsImmune(WoWSpellSchool.Fire)), Spell.Cast("Living Bomb", ret => !StyxWoW.Me.CurrentTarget.HasAura("Living Bomb") || (StyxWoW.Me.CurrentTarget.HasAura("Living Bomb") && StyxWoW.Me.CurrentTarget.GetAuraTimeLeft("Living Bomb", true).TotalSeconds <= 2)), Spell.Cast("Inferno Blast", ret => StyxWoW.Me.HasAura("Heating Up")), Spell.Cast("Frost Bomb", ret => Unit.UnfriendlyUnitsNearTarget(10f).Count() >= 1), Spell.Cast("Combustion", ret => StyxWoW.Me.CurrentTarget.HasMyAura("Ignite") && StyxWoW.Me.CurrentTarget.HasMyAura("Pyroblast")), Spell.Cast("Pyroblast", ret => StyxWoW.Me.ActiveAuras.ContainsKey("Pyroblast!")), Spell.Cast("Fireball", ret => !SpellManager.HasSpell("Scorch")), Spell.Cast("Frostfire bolt", ret => !SpellManager.HasSpell("Fireball")), Spell.Cast("Scorch"), Movement.CreateMoveToTargetBehavior(true, 39f) )); }
private void InitClusterPoints() { Clusters.ForEach((cluster) => { cluster.Points = Points.Where(p => p.Cluster.ClusterID == cluster.ClusterID).ToList(); SeriesCollection.ElementAt(cluster.ClusterID).Values.AddRange(new List <ScatterPoint>() { new ScatterPoint(cluster.AttrX, cluster.AttrY, clusterWeight) }); }); Clusters.ForEach((cluster) => { cluster.NbPoints = cluster.Points.Count(); cluster.Points.ForEach((point) => { point.CalculateSilhouette(Points, DistanceAlgorithm); }); }); Clusters.ForEach((cluster) => { cluster.CalculateSilhouettePercentage(); SilhouettePercentage = (SilhouettePercentage + cluster.SilhouettePercentage) / 2; }); }
/// <summary> /// Finds exactly the cluster closest to the cluster whose label matches color1 and the points /// in each cluster that are closest, along with the square distance between them. /// </summary> /// <param name="color1">Label of the cluster whose nearest neighbor is being sought.</param> /// <returns>A point in the cluster corresponding to color1, the closest point to it /// from another cluster, the square distance between the points, and the label of the other cluster. /// NOTE: ClosestPair.Color1 will equal color1. /// </returns> public ClosestPair FindClusterExhaustively(TLabel color1) { var shortest = new ClosestPair(); foreach (var p1 in Clusters.PointsInClass(color1)) { foreach (var pc in Clusters.Points() .Select(p => new { Point = p, Color = Clusters.GetClassLabel(p) }) .Where(pc => !color1.Equals(pc.Color))) { var d = p1.Measure(pc.Point); if (d < shortest.SquareDistance) { shortest.SquareDistance = d; shortest.Color1 = color1; shortest.Point1 = p1; shortest.Color2 = pc.Color; shortest.Point2 = pc.Point; } } } //TODO: If there is only one cluster, the if statement above will not be triggered and shortest will // be ill-defined and cause a Null Pointer exception in Swap. return(shortest.Swap(color1)); }
public void Start() { Random rand = new Random(); // On commence par sélectionner un "point" au hasard pour chaque cluster for (int i = 0; i < m_clusters; i++) { Clusters.Add(new Cluster( i, new Vector4( rand.NextFloat(0.0f, 0.8f), rand.NextFloat(0.0f, 0.8f), rand.NextFloat(0.0f, 0.8F), 1.0f), new Vector3(rand.NextFloat(-1.0f, 1.0f), rand.NextFloat(-1.0f, 1.0f), 0.0f))); Centroids.Add(new Entity(Entity)); MeshRenderer meshrenderer = Centroids[i].AddComponent <MeshRenderer>(); meshrenderer.material_ = new MaterialDX11(); meshrenderer.material_.SetMainColor(Clusters[i].Color); meshrenderer.model_ = Quad.GetMesh(); Centroids[i].transform_.SetScale(0.05f, 0.05f, 1.0f); } m_start = true; }
public void DeregisterContext(string context) { if (clientConfig.RegisteredContexts.Contains(context)) { clientConfig.RegisteredContexts.Remove(context); } // We will do all actions and raise multiple exceptions Dictionary <Cluster, Exception> exceptions = new Dictionary <Cluster, Exception>(); // Deregister on cluster foreach (var cluster in Clusters.ToList()) { try { cluster.DeregisterContext(context); } catch (Exception ex) { exceptions.Add(cluster, ex); } } // Handle exceptions if (exceptions.Count == 0) { return; } else { throw new Exceptions.MultiClusterException(exceptions); } }
/// <summary> /// Finds an approximately closest pair of points (one of each color) by using the ordering found in SortedPoints. /// /// This compares points in two of the clusters, ignoring points in all other clusters. /// /// NOTE: This was a good idea, but yields results too poor to be used. /// </summary> /// <param name="color1">Label of the first cluster.</param> /// <param name="color2">Label of the second cluster.</param> /// <returns>The point with Color1, the point with Color2 and the square distance between them. /// </returns> public ClosestPair FindPairApproximately(TLabel color1, TLabel color2) { var shortest = new ClosestPair(); UnsignedPoint prevP = null; TLabel prevColor = default(TLabel); foreach (var pc in SortedPoints .Select(p => new { Point = p, Color = Clusters.GetClassLabel(p) }) .Where(pc => pc.Color.Equals(color1) || pc.Color.Equals(color2))) { if (prevP != null && !prevColor.Equals(pc.Color)) { var d = pc.Point.Measure(prevP); if (d < shortest.SquareDistance) { shortest.SquareDistance = d; shortest.Color1 = prevColor; shortest.Point1 = prevP; shortest.Color2 = pc.Color; shortest.Point2 = pc.Point; } } prevP = pc.Point; prevColor = pc.Color; } return(shortest.Swap(color1)); }
public void RegisterContextPath(string context) { if (string.IsNullOrEmpty(context)) { throw new InvalidOperationException("Cannot register an empty context"); } if (!clientConfig.RegisteredContexts.Contains(context)) { clientConfig.RegisteredContexts.Add(context); } // We will do all actions and raise multiple exceptions Dictionary <Cluster, Exception> exceptions = new Dictionary <Cluster, Exception>(); // Push to each route foreach (var cluster in Clusters.ToList()) { try { cluster.RegisterContextPath(context); } catch (Exception ex) { exceptions.Add(cluster, ex); } } // Handle exceptions if (exceptions.Count == 0) { return; } else { throw new Exceptions.MultiClusterException(exceptions); } }
private void DeregisterRoute() { // We will do all actions and raise multiple exceptions Dictionary <Cluster, Exception> exceptions = new Dictionary <Cluster, Exception>(); // Enum all clusters foreach (var cluster in Clusters.ToList()) { try { cluster.DeregisterRoute(); lock (_globalLockObject) { cluster.Dispose(); Clusters.Remove(cluster); } } catch (Exception ex) { exceptions.Add(cluster, ex); } } // Handle exceptions if (exceptions.Count == 0) { return; } else { throw new Exceptions.MultiClusterException(exceptions); } }
private void RegisterRoute(IEnumerable <string> contexts) { if (log != null && log.IsDebugEnabled) { log.Debug("Starting RegisterRoute(" + string.Join(",", contexts) + ")"); } // We will do all actions and raise multiple exceptions Dictionary <Cluster, Exception> exceptions = new Dictionary <Cluster, Exception>(); //TODO: Query if it exists already before trying to CONFIG it // Enum all clusters foreach (var cluster in Clusters.ToList()) { try { cluster.RegisterRoute(contexts); } catch (Exception ex) { exceptions.Add(cluster, ex); } } // Handle exceptions if (exceptions.Count == 0) { return; } else { throw new Exceptions.MultiClusterException(exceptions); } }
/// <summary> /// checks for chained cascade targets. this is expensive as the theoretical linked distance is 200 yds /// if all 4 hops occur and mobs are in straight line. regardless, this ability can easily aggro the /// entire countryside while questing, so we will be conservative in our assessment of whether it can /// be used or not while still maximizing the number of mobs hit based upon the initial targets proximity /// to linked mobs /// </summary> /// <returns></returns> public static bool UseDivineStar() { if (!Spell.CanCastHack("Divine Star", Me.CurrentTarget, skipWowCheck: true)) { return(false); } Vector3 endPoint = Me.Location.RayCast(Me.RenderFacing, 26); List <WoWUnit> hitByDS = Clusters.GetPathToPointCluster(endPoint, Unit.UnfriendlyUnits(26), 4).ToList(); if (hitByDS == null || !hitByDS.Any()) { Logger.WriteDiagnostic("UseDivineStar: 0 mobs would be hit"); return(false); } WoWUnit avoid = hitByDS.FirstOrDefault(u => u.IsAvoidMob()); if (avoid != null) { Logger.WriteDiagnostic( "UseDivineStar: skipping to avoid hitting {0} - aggr:{1} cc:{2} avdmob:{3}", avoid.SafeName(), (avoid.Aggro || avoid.PetAggro).ToYN(), avoid.IsCrowdControlled().ToYN(), avoid.IsAvoidMob().ToYN() ); return(false); } return(false); }
public static Composite CreateSlowMeleeBehavior() { return(new PrioritySelector( // Uncomment when MeshTrace is working //ctx => SafeArea.NearestEnemyMobAttackingMe, //new Action( ret => { // if (SingularSettings.Debug) // { // if (ret == null) // Logger.WriteDebug("SlowMelee: no nearest mob found"); // else // Logger.WriteDebug("SlowMelee: crowdcontrolled: {0}, slowed: {1}", ((WoWUnit)ret).IsCrowdControlled(), ((WoWUnit)ret).IsSlowed()); // } // return RunStatus.Failure; // }), new Decorator( // ret => ret != null && !((WoWUnit)ret).Stunned && !((WoWUnit)ret).Rooted && !((WoWUnit)ret).IsSlowed(), ret => ret != null, new PrioritySelector( new Decorator( req => ((WoWUnit)req).IsCrowdControlled(), new SeqDbg(1f, s => "SlowMelee: target already crowd controlled") ), Spell.CastOnGround("Ring of Frost", onUnit => (WoWUnit)onUnit, req => ((WoWUnit)req).SpellDistance() < 30, true), Spell.Cast("Frost Nova", mov => true, onUnit => (WoWUnit)onUnit, req => ((WoWUnit)req).SpellDistance() < 12, cancel => false), new Decorator( ret => TalentManager.CurrentSpec == WoWSpec.MageFrost, Frost.CastFreeze(on => Clusters.GetBestUnitForCluster(Unit.NearbyUnfriendlyUnits.Where(u => u.SpellDistance() < 8), ClusterType.Radius, 8)) ), Spell.Cast("Frostjaw", mov => true, onUnit => (WoWUnit)onUnit, req => true, cancel => false) ) ) )); }
/* * public static Sequence CreateHealingSphereBehavior( int sphereBelowHealth) * { * // healing sphere keeps spell on cursor for up to 3 casts... need to stop targeting after 1 * return new Sequence( * Spell.CastOnGround("Healing Sphere", * on => Me, * ret => Me.HealthPercent < sphereBelowHealth * && (Me.PowerType != WoWPowerType.Mana) * && !Common.AnySpheres(SphereType.Healing, 1f), * false), * new WaitContinue( TimeSpan.FromMilliseconds(500), ret => Spell.GetPendingCursorSpell != null, new ActionAlwaysSucceed()), * new Action(ret => Lua.DoString("SpellStopTargeting()")), * new WaitContinue( * TimeSpan.FromMilliseconds(750), * ret => Me.Combat || (Spell.GetSpellCooldown("Healing Sphere") == TimeSpan.Zero && !Common.AnySpheres(SphereType.Healing, 1f)), * new ActionAlwaysSucceed() * ) * ); * } */ public static Composite CreateChiBurstBehavior() { if (!HasTalent(MonkTalents.ChiBurst)) { return(new ActionAlwaysFail()); } if (TalentManager.CurrentSpec == WoWSpec.MonkMistweaver && SingularRoutine.CurrentWoWContext != WoWContext.Normal) { return(new Decorator( req => Me.GotTarget() && !Spell.IsSpellOnCooldown("Chi Burst") && !Me.CurrentTarget.IsBoss() && 3 <= Clusters.GetPathToPointCluster(Me.Location.RayCast(Me.RenderFacing, 40f), HealerManager.Instance.TargetList.Where(m => Me.IsSafelyFacing(m, 25)), 5f).Count(), Spell.Cast("Chi Burst", mov => true, ctx => Me, ret => Me.HealthPercent < MonkSettings.ChiWavePct, cancel => false ) )); } return(new Decorator( req => Me.GotTarget() && !Spell.IsSpellOnCooldown("Chi Burst") && !Me.CurrentTarget.IsBoss() && 3 <= Clusters.GetPathToPointCluster(Me.Location.RayCast(Me.RenderFacing, 40f), Unit.NearbyUnfriendlyUnits.Where(m => Me.IsSafelyFacing(m, 25)), 5f).Count(), Spell.Cast("Chi Burst", mov => true, ctx => Me, ret => Me.HealthPercent < MonkSettings.ChiWavePct, cancel => false ) )); }
public void AddCluster(Cluster cluster, bool repeat = false) { if (repeat || !Clusters.Contains(cluster)) { Clusters.Add(cluster); } }
public static Composite CreateLowbieWarriorCombat() { return(new PrioritySelector( // Ensure Target Safers.EnsureTarget(), // LOS Check Movement.CreateMoveToLosBehavior(), // face target Movement.CreateFaceTargetBehavior(), // Auto Attack Common.CreateAutoAttack(false), Helpers.Common.CreateInterruptSpellCast(ret => StyxWoW.Me.CurrentTarget), // Heal Spell.Cast("Victory Rush"), //rend Spell.Buff("Rend"), // AOE new Decorator( ret => Clusters.GetClusterCount(StyxWoW.Me, Unit.NearbyUnfriendlyUnits, ClusterType.Radius, 6f) >= 2, new PrioritySelector( Spell.Cast("Victory Rush", ret => StyxWoW.Me.HealthPercent < 80), Spell.Cast("Thunder Clap"), Spell.Cast("Strike"))), // DPS Spell.Cast("Strike"), Spell.Cast("Thunder Clap", ret => StyxWoW.Me.RagePercent > 50), //move to melee Movement.CreateMoveToTargetBehavior(true, 5f) )); }
public static WoWUnit GetBestChainHealTarget() { if (!Me.IsInGroup()) { return(null); } if (!Spell.CanCastHack("Chain Heal", Me, skipWowCheck: true)) { Logger.WriteDebug("GetBestChainHealTarget: CanCastHack says NO to Chain Heal"); return(null); } WoWUnit target = Clusters.GetBestUnitForCluster(ChainHealPlayers, ClusterType.Chained, ChainHealHopDistance); int count = 0; if (target != null) { count = Clusters.GetClusterCount(target, ChainHealPlayers, ClusterType.Chained, ChainHealHopDistance); if (count < ShamanSettings.RestoHealSettings.MinChainHealCount) { target = null; } } if (target != null) { Logger.WriteDebug("Chain Heal Target: found {0} with {1} nearby under {2}%", target.SafeName(), count, ShamanSettings.RestoHealSettings.ChainHeal); } return(target); }
public static Composite ArmsPvPCombat() { return(new PrioritySelector( new Decorator(ret => !Me.Combat && Me.IsCasting, new ActionAlwaysSucceed()), CreateChargeBehavior(), Spell.Cast("Rallying Cry", ret => Me.HealthPercent <= 30), new Throttle(1, 1, new Sequence( CreateInterruptSpellCast(on => BestInterrupt))), Item.UsePotionAndHealthstone(40), Spell.Cast("Victory Rush", ret => Me.HealthPercent <= 90 && Me.CachedHasAura("Victorious")), ShatterBubbles(), new Decorator(ret => /*Me.CurrentTarget.IsPlayer &&*/ !Me.CurrentTarget.IsStunned() && !Me.CurrentTarget.IsCrowdControlled() && (!Me.CurrentTarget.HasAuraWithEffectsing(WoWApplyAuraType.ModDecreaseSpeed) /*w|| !Me.CurrentTarget.CachedHasAura("Hamstring")*/), new PrioritySelector( Spell.Cast("Piercing Howl"), Spell.Cast("Hamstring"))), DemoBanner(), HeroicLeap(), MockingBanner(), new Decorator(ret => AdvancedAI.Movement, new PrioritySelector( DemoBannerAuto(), MockingBannerAuto())), Spell.Cast("Intervene", on => BestBanner), //Spell.CastOnGround("Demoralizing Banner", on => Me.Location, ret => Me.HealthPercent < 40), Spell.Cast("Disarm", ret => Me.CurrentTarget.HasAnyAura(Disarm) && !Me.CurrentTarget.HasAnyAura(DontDisarm)), Spell.Cast("Die by the Sword", ret => Me.HealthPercent <= 20 /*&& Me.CurrentTarget.IsMelee()*/), new Decorator(ret => AdvancedAI.Burst && Me.CurrentTarget.IsWithinMeleeRange, new PrioritySelector( Spell.Cast("Recklessness"), Spell.Cast("Bloodbath"), Spell.Cast("Avatar", ret => Me.CachedHasAura("Recklessness")), Spell.Cast("Skull Banner", ret => Me.CachedHasAura("Recklessness")))), new Action(ret => { Item.UseHands(); return RunStatus.Failure; }), Spell.Cast("Intervene", on => BestInterveneTarget), Spell.Cast("Charge", on => ChargeInt), Spell.Cast("Heroic Strike", ret => (Me.CurrentTarget.CachedHasAura("Colossus Smash") && Me.CurrentRage >= 70) || Me.CurrentRage >= 95), Spell.Cast("Sweeping Strikes", ret => Unit.UnfriendlyUnits(8).Count() >= 2 && AdvancedAI.Aoe), Spell.Cast("Bladestorm", ret => Me.HasAura("Bloodbath") && Me.CurrentTarget.Distance <= 8), //new Decorator(ret => Me.CurrentTarget != null && SpellManager.GlobalCooldown, // new ActionAlwaysSucceed()), Spell.Cast("Mortal Strike"), Spell.Cast("Dragon Roar", ret => !Me.CurrentTarget.CachedHasAura("Colossus Smash") && Me.CachedHasAura("Bloodbath") && Me.CurrentTarget.Distance <= 8), Spell.Cast("Colossus Smash", ret => Me.HasAuraExpired("Colossus Smash", 1)), Spell.Cast("Execute", ret => Me.CurrentTarget.CachedHasAura("Colossus Smash") || Me.CachedHasAura("Recklessness") || Me.CurrentRage >= 30), Spell.Cast("Dragon Roar", ret => Me.CurrentTarget.Distance <= 8 && (!Me.CurrentTarget.CachedHasAura("Colossus Smash") && Me.CurrentTarget.HealthPercent < 20) || Me.CachedHasAura("Bloodbath")), Spell.Cast("Thunder Clap", ret => Clusters.GetClusterCount(Me, Unit.NearbyUnfriendlyUnits, ClusterType.Radius, 8f) >= 2 && Clusters.GetCluster(Me, Unit.NearbyUnfriendlyUnits, ClusterType.Radius, 8).Any(u => !u.HasMyAura("Deep Wounds"))), Spell.Cast("Slam", ret => (Me.CurrentTarget.CachedHasAura("Colossus Smash") || Me.CachedHasAura("Recklessness")) && Me.CurrentTarget.HealthPercent >= 20), Spell.Cast("Overpower", ret => Me.CurrentTarget.HealthPercent >= 20 || Me.CachedHasAura("Sudden Execute")), Spell.Cast("Execute", ret => !Me.CachedHasAura("Sudden Execute")), Spell.Cast("Slam", ret => Me.CurrentRage >= 40 && Me.CurrentTarget.HealthPercent >= 20), Spell.Cast("Battle Shout"), Spell.Cast("Heroic Throw"), Spell.Cast("Impending Victory", ret => Me.CurrentTarget.HealthPercent > 20 || Me.HealthPercent < 50), new Decorator(ret => AdvancedAI.Movement, Movement.CreateMoveToMeleeBehavior(true)), new ActionAlwaysSucceed())); }
public scenario_structure_bsp(CacheBase Cache, CacheBase.IndexItem Tag) { cache = Cache; int Address = Tag.Offset; EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); Reader.SeekTo(Address + 68); XBounds = new Range <float>(Reader.ReadSingle(), Reader.ReadSingle()); YBounds = new Range <float>(Reader.ReadSingle(), Reader.ReadSingle()); ZBounds = new Range <float>(Reader.ReadSingle(), Reader.ReadSingle()); #region Clusters Block Reader.SeekTo(Address + 172); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Tag.Magic; for (int i = 0; i < iCount; i++) { ModelSections.Add(new ModelSection(Cache, Tag, iOffset + 176 * i, null) { FacesIndex = i, VertsIndex = i, NodeIndex = 255 }); Clusters.Add(new Cluster(i)); } #endregion #region Shaders Block Reader.SeekTo(Address + 180); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Tag.Magic; for (int i = 0; i < iCount; i++) { Shaders.Add(new Halo2Xbox.render_model.Shader(Cache, iOffset + 32 * i)); } #endregion #region ModelParts Block Reader.SeekTo(Address + 328); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Tag.Magic; for (int i = 0; i < iCount; i++) { ModelSections.Add(new ModelSection(Cache, Tag, iOffset + 200 * i, BoundingBoxes) { FacesIndex = i + Clusters.Count, VertsIndex = i + Clusters.Count, NodeIndex = 255 }); } #endregion #region GeometryInstances Block Reader.SeekTo(Address + 336); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Tag.Magic; for (int i = 0; i < iCount; i++) { GeomInstances.Add(new InstancedGeometry(Cache, iOffset + 88 * i, Clusters.Count)); } #endregion }
public void DecreaseClusterFile(int _oldSize, File _file) { //New number cluster var nCluster = (int)Math.Ceiling((decimal)_file.Size / Settings.Settings.ClusterSize); //Number clear cluster var numberClusterToDelete = _file.NumberClusterUse - nCluster; //Get index of cluster to remove var listIndex = (List <int>)GetIndexFragmentClusterFileOfFile(_file); //Clear clusters for (var i = 0; i < numberClusterToDelete; i++) { var cluster = Clusters.ElementAt(listIndex.Last()); cluster.ClusterFile = new EmptyClusterFile(); listIndex.RemoveAt(listIndex.Count - 1); } if (listIndex.Count > 0) { //Update cluster var cluster = Clusters.ElementAt(listIndex.Last()); if (cluster.ClusterFile is FragmentClusterFile fragmentFile) { fragmentFile.NextCluster = null; } } }
/// <summary> /// Merges the small outlier clusters with nearby larger clusters. /// </summary> /// <returns>The number of outlier clusters merged.</returns> /// <param name="maxOutlierMergeDistance">An outlier will only be merged if its distance from /// its nearest cluster does not exceed this square distance.</param> public int MergeOutliers(long maxOutlierMergeDistance) { var mergesDone = 0; var cc = new ClosestCluster <string>(Clusters); var closeOutlierPairs = cc.FindClosestOutliers( MaxNeighborsToCompare, maxOutlierMergeDistance, OutlierSize ); foreach (var pair in closeOutlierPairs) { pair.Relabel(Clusters); // We do not want an outlier to cause the merger of two large clusters // if each of the large clusters is near the outlier but not near each other. // Thus, once the outlier is merged with the nearer of its neighbors, // it will be ruled out from firther merges. if (pair.CountOutliers(Clusters, OutlierSize) != 1) { continue; } if (Clusters.Merge(pair.Color1, pair.Color2)) { mergesDone++; } } return(mergesDone); }
protected int spriteColorByCluster(int nSprite, int nLevels) { int set = 0; int unset = 0; int i = nSprite * nClustersPerSprite; int z = i + nClustersPerSprite; for ( ; i < z; i++) { if (Clusters.Get(i)) { set++; } else { unset++; } } if (set == 0) { return(nLevels); } double percent = (double)set / (set + unset); int level = (int)(percent * nLevels); if (level >= nLevels) { level = nLevels - 1; } return(level); }
public override void RemoveFile(File _file) { if (_file == null) { return; } //Clear selection ClearSelection(); //Get index of cluster to remove var listIndex = GetIndexFragmentClusterFileOfFile(_file); //Clear cluster foreach (var index in listIndex) { Clusters.ElementAt(index).Content = new EmptyContentCluster(); } Files.Remove(_file); SelectedFile = null; var needUpdate = RootDirectory.NeedUpdateRootDirectory(); if (needUpdate) { DeleteRootDirectory(); } }
public override IEnumerable <int> GetIndexFragmentClusterFileOfFile(File _file) { var listIndex = new List <int>(); //Add index of all cluster to empty var file = _file.FragmentFiles.First(); if (file != null) { for (var i = 0; i < Clusters.Count; i++) { var cluster = Clusters[i]; if (cluster.Content == file) { listIndex.Add(i); break; } } } while (file.NextCluster != null) { listIndex.Add(Clusters.IndexOf(file.NextCluster)); file = file.NextCluster.Content as ContentFileCluster; } return(listIndex); }
/// <summary> /// selects best target, favoring healing multiple group members followed by damaging multiple targets /// </summary> /// <returns></returns> private static WoWUnit BestChiBurstTarget() { WoWUnit target = null; if (Me.IsInGroup()) { target = Clusters.GetBestUnitForCluster( Unit.NearbyGroupMembers.Where(m => m.IsAlive && m.HealthPercent < 80), ClusterType.PathToUnit, 40f); } if (target == null || target.IsMe) { target = Clusters.GetBestUnitForCluster( Unit.NearbyUnitsInCombatWithMeOrMyStuff, ClusterType.PathToUnit, 40f); } if (target == null) { target = Me; } return(target); }
private void BuildClustersMenu() { Clusters.Clear(); if (Presentation == null) { return; } var transformations = Presentation.GetModule <ITransformationModule>(); var captions = Presentation.GetModule <ICaptionModule>(); var clusters = transformations.Graph.Clusters .Union(Presentation.Graph.Clusters) .Select(c => c.Id) .Distinct() .Select(id => new ClusterWithCaption { Id = id, Caption = captions.Get(id).DisplayText }) .OrderBy(id => id.Caption); foreach (var cluster in clusters) { Clusters.Add(cluster); } }
public void Clear() { GlyphIndicies.Clear(); GlyphPositions.Clear(); Clusters.Clear(); CodePointXCoords.Clear(); }
/// <summary> /// Makes a new cluster, without registrating it - you have to call: <see cref="AddCluster(ItemCluster<T>)"/> to keep it within collection /// </summary> /// <param name="name">The name.</param> /// <returns></returns> public TCluster NewCluster <TCluster>(String name = "") where TCluster : ItemCluster <T>, new() { TCluster output = new TCluster(); output.name = "C" + Clusters.Count(); return(output); }
private Cluster getNearestCluster(User user) { if (Clusters == null) { return(null); } return(Clusters.OrderByDescending(y => user.Distance(y.Center)).First()); }
private static Clusters FindClusters(int cMAType, double[] derivatives, double[] minThresholds) { Clusters c = new BAL.CMA.Clusters(); Clusters optimalC = null; for (int ii = 0; ii < minThresholds.Length; ii++) { c.minThresholdRequired = minThresholds[ii]; c.clusters = Common.Statistics.FindClusters(derivatives, minThresholds[ii]).ToArray(); if (cMAType == (int)CMAType.Regular) { if (c.clusters.Length <= 2) { if (optimalC == null) { optimalC = new BAL.CMA.Clusters(); } optimalC.minThresholdRequired = c.minThresholdRequired; optimalC.clusters = c.clusters; } if (c.clusters.Length == 2) { break; } } else if (cMAType == (int)CMAType.ShortSale) { if (optimalC == null) { optimalC = new BAL.CMA.Clusters(); optimalC.minThresholdRequired = c.minThresholdRequired; optimalC.clusters = c.clusters; } else if (optimalC.clusters.Length < c.clusters.Length) { optimalC.minThresholdRequired = c.minThresholdRequired; optimalC.clusters = c.clusters; } } else { if (optimalC == null) { optimalC = new BAL.CMA.Clusters(); optimalC.minThresholdRequired = c.minThresholdRequired; optimalC.clusters = c.clusters; } else if (optimalC.clusters.Length < c.clusters.Length) { optimalC.minThresholdRequired = c.minThresholdRequired; optimalC.clusters = c.clusters; } } } return(optimalC); }
public static Composite CreateHunterSurvivalPullAndCombat() { return(new PrioritySelector( Helpers.Common.EnsureReadyToAttackFromMelee(), Spell.WaitForCastOrChannel(), new Decorator( ret => !Spell.IsGlobalCooldown(), new PrioritySelector( CreateSurvivalDiagnosticOutputBehavior(), Movement.WaitForFacing(), Movement.WaitForLineOfSpellSight(), Helpers.Common.CreateInterruptBehavior(), // Artifact Weapon new Decorator( ret => HunterSettings.UseArtifactOnlyInAoE && Clusters.GetConeClusterCount(90f, Unit.UnfriendlyUnits(8), 100f) > 1, new PrioritySelector( Spell.Cast("Fury of the Eagle", ret => HunterSettings.UseDPSArtifactWeaponWhen == UseDPSArtifactWeaponWhen.OnCooldown || (HunterSettings.UseDPSArtifactWeaponWhen == UseDPSArtifactWeaponWhen.AtHighestDPSOpportunity && Me.GetAuraStacks("Mongoose Fury") >= 6) ) ) ), Spell.Cast("Fury of the Eagle", ret => HunterSettings.UseDPSArtifactWeaponWhen == UseDPSArtifactWeaponWhen.OnCooldown || (HunterSettings.UseDPSArtifactWeaponWhen == UseDPSArtifactWeaponWhen.AtHighestDPSOpportunity && Me.GetAuraStacks("Mongoose Fury") >= 6) ), Spell.BuffSelf("Aspect of the Eagle", ret => Me.GetAuraTimeLeft("Mongoose Fury", false).TotalSeconds > 10), Spell.Cast("Mongoose Bite", req => SpellManager.HasSpell("Aspect of the Eagle") && Spell.GetSpellCooldown("Aspect of the Eagle").TotalSeconds <= 0 && !Me.HasActiveAura("Mongoose Fury")), Spell.BuffSelf("Snake Hunter", ret => Me.HasAura("Aspect of the Eagle") && Spell.GetCharges("Mongoose Bite") <= 0), Spell.Cast("Butchery", ret => Unit.UnfriendlyUnits(8).Count() >= 2), Spell.CastOnGround("Explosive Trap", on => Me.CurrentTarget.Location), Spell.Cast("Dragonsfire Grenade"), Spell.CastOnGround("Steel Trap", on => Me.CurrentTarget.Location, ret => Me.CurrentTarget.TimeToDeath() > 5), Spell.Cast("Raptor Strike", ret => Common.HasTalent(HunterTalents.WayOfTheMokNathal) && (Me.GetAuraTimeLeft("Mok'Nathal Tactics").TotalSeconds < 1.8 || Me.GetAuraStacks("Mok'Nathal Tactics") < 4)), Spell.Cast("Lacerate"), Spell.Cast("Mongoose Bite", ret => Spell.GetCharges("Mongoose Bite") == 2 && Spell.TimeUntilNextCharge("Mongoose Bite").TotalSeconds < 1.8), Spell.Cast("Throwing Axes"), Spell.CastOnGround("Caltrops", on => Me.CurrentTarget.Location), Spell.Cast("Spitting Cobra"), // Avoiding getting focus capped with Flanking Strike Spell.Cast("Flanking Strike", ret => Common.FocusDeficit < 20 && Unit.UnfriendlyUnits(8).Count() <= 3), Spell.Cast("Carve", ret => Common.FocusDeficit < 20 && Unit.UnfriendlyUnits(8).Count() >= 4), Spell.Cast("Carve", ret => Common.HasTalent(HunterTalents.SerpentString) && Unit.UnfriendlyUnits(8).Count(u => u.GetAuraTimeLeft("Serpent String").TotalSeconds < 1.8) >= 3), Spell.Cast("Mongoose Bite", ret => !SpellManager.HasSpell("Aspect of the Eagle") || Spell.GetSpellCooldown("Aspect of the Eagle").TotalSeconds > 12) ) ) )); }