private Composite CreateBehavior_InternalMoveTo(LocationDelegate locationDelegate) { return( new Sequence(context => locationDelegate(), // Druids, switch to Aquatic Form if swimming and distance dictates... new DecoratorContinue(ret => (SpellManager.CanCast(_spellId_DruidAquaticForm) && !Me.HasAura(AuraName_DruidAquaticForm) && (Me.Location.Distance(locationDelegate()) > MinDistanceToUse_DruidAquaticForm)), new Action(delegate { SpellManager.Cast(_spellId_DruidAquaticForm); })), // Move... new Action(delegate { // Try to use Navigator to get there... WoWPoint location = locationDelegate(); MoveResult moveResult = Navigator.MoveTo(location); // If Navigator fails, fall back to click-to-move... if ((moveResult == MoveResult.Failed) || (moveResult == MoveResult.PathGenerationFailed)) { WoWMovement.ClickToMove(location); } }), new WaitContinue(_delay_WoWClientMovementThrottle, ret => false, new ActionAlwaysSucceed()) ) ); }
public LocationHook() { var mainAddress = Utility.GetModuleHandle("EliteDangerous.exe"); var imageBase = 4194304; var locationAddress = IntPtr.Subtract(mainAddress, imageBase) + 0xBC3850; _locationOriginal = (LocationDelegate)Marshal.GetDelegateForFunctionPointer(locationAddress, typeof(LocationDelegate)); _name = string.Format("LocationHook"); _hook = LocalHook.Create(locationAddress, new LocationDelegate(LocationDetour), this); _hook.ThreadACL.SetExclusiveACL(new Int32[] { 0 }); }
public static void getCurrent(LocationDelegate callback) { GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); watcher.MovementThreshold = 20; // use MovementThreshold to ignore noise in the signal //watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>( (object sender, GeoPositionChangedEventArgs<GeoCoordinate> e) => { System.Diagnostics.Debug.WriteLine(e.Position.Location); watcher.Stop(); callback(e.Position.Location); }); watcher.Start(); }
// Returns: RunStatus.Success while movement is in progress; othwerise, RunStatus.Failure if no movement necessary private Composite UtilityBehavior_MoveWithinRange(LocationDelegate locationDelegate, MessageDelegate locationNameDelegate) { return(new Sequence( // Done, if we're already at destination... new DecoratorContinue(context => Navigator.AtLocation(locationDelegate(context)), new Decorator(context => Me.IsMoving, // This decorator failing indicates the behavior is complete new Action(delegate { WoWMovement.MoveStop(); }))), // Notify user of progress... new CompositeThrottle(TimeSpan.FromSeconds(1), new Action(context => { double destinationDistance = Me.Location.Distance(locationDelegate(context)); string locationName = locationNameDelegate(context) ?? locationDelegate(context).ToString(); Utility_NotifyUser(string.Format("Moving to {0} (distance: {1:F1})", locationName, destinationDistance)); })), new Action(context => { WoWPoint destination = locationDelegate(context); // Try to use Navigator to get there... MoveResult moveResult = Navigator.MoveTo(destination); // If Navigator fails, fall back to click-to-move... if ((moveResult == MoveResult.Failed) || (moveResult == MoveResult.PathGenerationFailed)) { WoWMovement.ClickToMove(destination); } return RunStatus.Success; // fall through }), new WaitContinue(_delay_WoWClientMovementThrottle, ret => false, new ActionAlwaysSucceed()) )); }
private Composite CreateBehavior_InternalMoveTo(LocationDelegate locationDelegate) { return ( new Sequence(context => locationDelegate(), // Druids, switch to Aquatic Form if swimming and distance dictates... new DecoratorContinue(ret => (SpellManager.CanCast(SpellId_DruidAquaticForm) && !Me.HasAura(AuraName_DruidAquaticForm) && (Me.Location.Distance(locationDelegate()) > MinDistanceToUse_DruidAquaticForm)), new Action(delegate { SpellManager.Cast(SpellId_DruidAquaticForm); })), // Move... new Action(delegate { // Try to use Navigator to get there... WoWPoint location = locationDelegate(); MoveResult moveResult = Navigator.MoveTo(location); // If Navigator fails, fall back to click-to-move... if ((moveResult == MoveResult.Failed) || (moveResult == MoveResult.PathGenerationFailed)) { WoWMovement.ClickToMove(location); } }), new WaitContinue(Delay_WoWClientMovementThrottle, ret => false, new ActionAlwaysSucceed()) ) ); }
public Composite CreateBehavior_MoveToLocation(LocationDelegate location) { return ( new PrioritySelector(context => location(), // If we're not at location, move to it... new Decorator(wowPoint => (Me.Location.Distance((WoWPoint)wowPoint) > Navigator.PathPrecision), new Sequence( new DecoratorContinueThrottled(Delay_StatusUpdateThrottle, ret => true, new Action(wowPoint => TreeRoot.StatusText = "Moving to location " + (WoWPoint)wowPoint)), CreateBehavior_InternalMoveTo(() => location()) )) )); }