private Action <IList <string> > GetCommand(string cmd) { return(cmd switch { /* command all Slaves to follow Master */ "follow" => new Action <IList <string> >(((args) => { string masterName = me.ControlInterface.remoteControl.GetUnitName(me.Player.GetAddress()); foreach (Client slave in Slaves) { slave .ControlInterface .remoteControl .FrameScript__Execute($"FollowUnit('{masterName}')", 0, 0); } })), /* command selected Slave to cast spell on current Master target */ "castspell" => new Action <IList <string> >(((args) => { string casterName = args[0]; string spellName = args[1]; Int64 targetGuid = me.GetTargetGUID(); Client caster = Slaves.FirstOrDefault(c => c.ControlInterface.remoteControl.GetUnitName(c.Player.GetAddress()) == casterName); if (caster != null) { caster.CastSpellOnGuid(spellName, targetGuid); } else { Console.WriteLine($"Couldn't find slave: {casterName}."); } })), /* toggles AI(individual behaviour loops) */ "toggleai" => new Action <IList <string> >(((args) => { string switchArg = args[0]; if (switchArg.Equals("m")) { masterAI = !masterAI; string state = masterAI ? "ON" : "OFF"; Console.WriteLine($"MASTER AI is now {state}."); } else if (switchArg.Equals("s")) { slavesAI = !slavesAI; string state = slavesAI ? "ON" : "OFF"; Console.WriteLine($"SLAVES AI is now {state}."); } })), _ => new Action <IList <string> >(((args) => { Console.WriteLine($"Unrecognized command: {cmd}."); })), });
public TransactionPropagator(Configuration config, Log log, Slaves slaves, CommitPusher pusher) { this._config = config; this._log = log; this._slaves = slaves; this._pusher = pusher; _slaveCommitFailureLogger = (new CappedLogger(log)).setTimeLimit(5, SECONDS, Clocks.systemClock()); _pushedToTooFewSlaveLogger = (new CappedLogger(log)).setTimeLimit(5, SECONDS, Clocks.systemClock()); }
// Constructor public People() { slaves = new Slaves(); shieldMaidens = new ShieldMaiden(); vikings = new Viking(); nbrOfSlave = 5; nbrOfVikings = 20; nbrOfShieldMaidens = 10; }
// Constructor public People() { slaves = new Slaves(); shieldMaidens = new ShieldMaiden(); vikings = new Viking(); nbrOfSlave = 5; nbrOfVikings = 20; nbrOfShieldMaidens = 10; nbrTotalOfWarriors = nbrOfVikings + nbrOfShieldMaidens; }
public TransformationHandler(MainWindow element, ScrollViewer scrollViewer, Viewport3D viewport) { this.window = element; this.scrollViewer = scrollViewer; this.viewport = viewport; Reset(); Attach(); Slaves.Add(viewport); }
public void GetSlaves() { var slaves = Host.getAllInvItems().Where (i => Slaves.ItemExists(i.id)).OrderBy(i => i.name).Select(i => i.name); if (slaves.Count() < 1) { return; } Utils.InvokeOn(this, () => { cmbox_Familiars.Items.Clear(); cmbox_Familiars.Items.AddRange(slaves.ToArray()); cmbox_Familiars.SelectedIndex = 0; }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCapUndesiredSlaveCountPushLogging() public virtual void ShouldCapUndesiredSlaveCountPushLogging() { // GIVEN int serverId = 1; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cluster.InstanceId instanceId = new org.neo4j.cluster.InstanceId(serverId); InstanceId instanceId = new InstanceId(serverId); Configuration config = new ConfigurationAnonymousInnerClass(this, instanceId); Log logger = mock(typeof(Log)); Slaves slaves = mock(typeof(Slaves)); when(slaves.GetSlaves()).thenReturn(Collections.emptyList()); CommitPusher pusher = mock(typeof(CommitPusher)); TransactionPropagator propagator = Life.add(new TransactionPropagator(config, logger, slaves, pusher)); // WHEN for (int i = 0; i < 10; i++) { propagator.Committed(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_ID, serverId); } // THEN verify(logger, times(1)).info(anyString()); }
private Action <Client, IList <string> > GetCommand(string cmd) { var command = masterSolution.GetCommand(cmd); if (command != null) { return((self, args) => command.Invoke(args)); } foreach (var slaveSolution in slavesSolutions) { command = slaveSolution.GetCommand(cmd); if (command != null) { return((self, args) => command.Invoke(args)); } } return(cmd switch { /* set client's cvar */ "cvar" => new Action <Client, IList <string> >(((self, args) => { IEnumerable <Client> clients = null; string charName = args[0]; string cvarName = args[1]; string cvarValue = args[2]; if (charName == "*") { clients = base.clients; } else if (charName == "<slaves>") { clients = Slaves; } else { Func <Client, bool> q = null; var targetGuid = me.Memory.ReadInt64(IntPtr.Zero + Offset.MouseoverGUID); if (targetGuid == 0) { q = c => c.ControlInterface.remoteControl.GetUnitName(c.Player.GetAddress()) == charName; } else { q = c => c.Player.GUID == targetGuid; } clients = base.clients.Where(q); } foreach (var client in clients) { client.ExecLua($"SetCVar('{cvarName}', {cvarValue})"); } })), /* command all to exit vehicle */ "ev" => new Action <Client, IList <string> >((self, args) => { foreach (Client client in clients) { client.ExecLua("VehicleExit()"); } }), /* command all Slaves to follow Master */ "fw" => new Action <Client, IList <string> >((self, args) => { if (!me.GetObjectMgrAndPlayer()) { return; } string masterName = me.ControlInterface.remoteControl.GetUnitName(me.Player.GetAddress()); string switchArg = args[0]; foreach (Client slave in Slaves) { if (switchArg.Equals("st")) { // break follow if (slave.GetObjectMgrAndPlayer()) { var targetGuid = slave.Player.GUID; var targetCoords = slave.Player.Coordinates; slave.ControlInterface.remoteControl.CGPlayer_C__ClickToMove( slave.Player.GetAddress(), ClickToMoveType.Move, ref targetGuid, ref targetCoords, 1f); } } else if (switchArg.Equals("fw")) { if (slave.GetObjectMgrAndPlayer()) { if (slave.Player.IsInCombat()) { var targetGuid = slave.Player.GUID; var targetCoords = me.Player.Coordinates; slave.ControlInterface.remoteControl.CGPlayer_C__ClickToMove( slave.Player.GetAddress(), ClickToMoveType.Move, ref targetGuid, ref targetCoords, 1f); } else { slave.ExecLua($"FollowUnit('{masterName}')"); } } } } }), /* command selected Slave to cast spell on current Master target */ "cs" => new Action <Client, IList <string> >(((self, args) => { string casterName = args[0]; string spellName = args[1]; Int64 targetGuid = 0; if (args.Count > 2 && args[2] == "mo") // optional mouseover { targetGuid = me.Memory.ReadInt64(IntPtr.Zero + Offset.MouseoverGUID); } else { targetGuid = me.GetTargetGUID(); } Client caster = clients.FirstOrDefault(c => c.ControlInterface.remoteControl.GetUnitName(c.Player.GetAddress()) == casterName); if (caster != null) { caster.EnqueuePrioritySpellCast( new SpellCast { Coordinates = null, SpellName = spellName, TargetGUID = targetGuid } ); } else { Console.WriteLine($"Couldn't find slave: {casterName}."); } })), /* use item */ "ui" => new Action <Client, IList <string> >(((self, args) => { IEnumerable <Client> users = null; string location = args[0]; string userName = args[1]; string itemName = args[2]; if (userName == "*") { users = clients; } else if (userName == "<slaves>") { users = Slaves; } else { Func <Client, bool> q = null; var targetGuid = me.Memory.ReadInt64(IntPtr.Zero + Offset.MouseoverGUID); if (targetGuid == 0) { q = c => c.ControlInterface.remoteControl.GetUnitName(c.Player.GetAddress()) == userName; } else { q = c => c.Player.GUID == targetGuid; } users = clients.Where(q); } foreach (var user in users) { if (user != null) { user.ExecLua(UtilScript); if (location == "inv") { user.ExecLua( $"filter = function(itemName) return itemName == \"{itemName}\" end;" + $"sfUseInventoryItem(filter)"); } else if (location == "bag") { user.ExecLua( $"filter = function(itemName) return itemName == \"{itemName}\" end;" + $"sfUseBagItem(filter)"); } } else { Console.WriteLine($"Couldn't find slave: {userName}."); } } })), /* cast terrain-targetable spell */ "ctts" => new Action <Client, IList <string> >(((self, args) => { string casterName = args[0]; string spellName = args[1]; Int64 targetGuid = 0; if (args.Count > 2 && args[2] == "mo") // optional mouseover { targetGuid = me.Memory.ReadInt64(IntPtr.Zero + Offset.MouseoverGUID); } else { targetGuid = me.GetTargetGUID(); } if (targetGuid == 0) { return; } Client caster = Slaves.FirstOrDefault(c => c.ControlInterface.remoteControl.GetUnitName(c.Player.GetAddress()) == casterName); if (caster != null) { GameObject targetObject = caster.ObjectManager.FirstOrDefault(obj => obj.GUID == targetGuid); if (targetObject != null) { caster.EnqueuePrioritySpellCast( new SpellCast { Coordinates = targetObject.Coordinates - Vector3.Random(), /* randomize location a little */ SpellName = spellName, TargetGUID = targetGuid } ); } else { Console.WriteLine($"Target not found."); } } else { Console.WriteLine($"Couldn't find slave: {casterName}."); } })), /* toggles AI(individual behaviour loops) */ "ta" => new Action <Client, IList <string> >(((self, args) => { string switchArg = args[0]; if (switchArg.Equals("ma")) { masterAI = !masterAI; string state = masterAI ? "ON" : "OFF"; Console.WriteLine($"MASTER AI is now {state}."); me.ExecLua($"SetMasterStatus('{state}')"); } else if (switchArg.Equals("sl")) { slavesAI = !slavesAI; string state = slavesAI ? "ON" : "OFF"; Console.WriteLine($"SLAVES AI is now {state}."); me.ExecLua($"SetSlavesStatus('{state}')"); } else if (switchArg.Equals("bu")) { buffingAI = !buffingAI; string state = buffingAI ? "ON" : "OFF"; Console.WriteLine($"BUFFING AI is now {state}."); me.ExecLua($"SetBuffingStatus('{state}')"); } else if (switchArg.Equals("ra")) { radarOn = !radarOn; string state = radarOn ? "ON" : "OFF"; Console.WriteLine($"RADAR is now {state}."); me.ExecLua($"SetRadarStatus('{state}')"); } else if (switchArg.Equals("in")) { inputMultiplexer.ConditionalBroadcastOn = !inputMultiplexer.ConditionalBroadcastOn; string state = inputMultiplexer.ConditionalBroadcastOn ? "ON" : "OFF"; Console.WriteLine($"EXTRA INPUT BROADCAST is now {state}."); me.ExecLua($"SetExInputBroadcastStatus('{state}')"); } })), /* command slaves to interact with Master mouseover target */ "it" => new Action <Client, IList <string> >(((self, args) => { Int64 masterTargetGuid = me.Memory.ReadInt64(IntPtr.Zero + Offset.MouseoverGUID); if (masterTargetGuid == 0) { return; } foreach (Client slave in Slaves) { slave.Memory.Write(IntPtr.Zero + Offset.MouseoverGUID, BitConverter.GetBytes(masterTargetGuid)); slave.ExecLua("InteractUnit('mouseover')"); } })), /* exit all slaves */ "ex" => new Action <Client, IList <string> >(((self, args) => { foreach (Client slave in Slaves) { slave.ExecLua($"Quit()"); } })), /* click static popup */ "stat" => new Action <Client, IList <string> >(((self, args) => { foreach (Client client in Slaves) { // arg is button number client.ExecLua($"StaticPopup1Button{args[0]}:Click()"); } })), /* fixate on target */ "fix" => new Action <Client, IList <string> >(((self, args) => { var targetGuid = me.GetTargetGUID(); if (targetGuid == 0) { return; } fixateTargetGuid = targetGuid; Console.WriteLine($"Fixated on {fixateTargetGuid}"); })), /* toggles simple rotation */ "rot" => new Action <Client, IList <string> >(((self, args) => { complexRotation = !complexRotation; string state = complexRotation ? "ON" : "OFF"; Console.WriteLine($"Complex Rotation is now {state}."); me.ExecLua($"SetRotationStatus('{state}')"); })), "frm" => new Action <Client, IList <string> >(((self, args) => { const float magnitude = 5f; var formation = new[] { new Vector3(-magnitude, -magnitude, 0f), new Vector3(magnitude, magnitude, 0f), new Vector3(-magnitude, magnitude, 0f), new Vector3(magnitude, -magnitude, 0f), }; var formationIndex = 0; foreach (var slave in Slaves) { if (slave.GetObjectMgrAndPlayer()) { Int64 _dummyGuid = 0; Vector3 destination = slave.Player.Coordinates - formation[formationIndex]; slave .ControlInterface .remoteControl .CGPlayer_C__ClickToMove( slave.Player.GetAddress(), ClickToMoveType.Move, ref _dummyGuid, ref destination, 1f); formationIndex++; } } })), /* bring to foreground selected client game window */ "fg" => new Action <Client, IList <string> >(((self, args) => { Int64 targetGuid = 0; if (args.Count > 0 && args[0] == "mo") // optional mouseover { targetGuid = self.Memory.ReadInt64(IntPtr.Zero + Offset.MouseoverGUID); } else { targetGuid = self.GetTargetGUID(); } Client client = clients.FirstOrDefault(c => c.Player.GUID == targetGuid); if (client != null) { self.ControlInterface.remoteControl.YieldWindowFocus(client.Process.MainWindowHandle); } else { Console.WriteLine($"Couldn't find client with player guid {targetGuid}."); } })), _ => new Action <Client, IList <string> >(((self, args) => { Console.WriteLine($"Unrecognized command: {cmd}."); })), });
public Action <Client, IList <string> > GetCommand(string cmd) { var command = masterSolution.GetCommand(cmd); if (command != null) { return((self, args) => command.Invoke(args)); } foreach (var slaveSolution in slavesSolutions) { command = slaveSolution.GetCommand(cmd); if (command != null) { return((self, args) => command.Invoke(args)); } } return(cmd switch { /* behaviours commands */ "bhv" => new Action <Client, IList <string> >((self, args) => { lock (BehaviourLocker) { var fullBehaviourName = $"SpellFire.Primer.Solutions.Mbox.ProdV2.Behaviours.{args[0]}"; currentBehaviour = Activator.CreateInstance(Type.GetType(fullBehaviourName), this) as BTNode; me.ExecLua($"print('Started behaviour: {args[0]}')"); } }), /* set client's cvar */ "cvar" => new Action <Client, IList <string> >(((self, args) => { IEnumerable <Client> clients = null; string charName = args[0]; string cvarName = args[1]; string cvarValue = args[2]; if (charName == "*") { clients = base.clients; } else if (charName == "<slaves>") { clients = Slaves; } else { Func <Client, bool> q = null; var targetGuid = me.Memory.ReadInt64(IntPtr.Zero + Offset.MouseoverGUID); if (targetGuid == 0) { q = c => c.ControlInterface.remoteControl.GetUnitName(c.Player.GetAddress()) == charName; } else { q = c => c.Player.GUID == targetGuid; } clients = base.clients.Where(q); } foreach (var client in clients) { client.ExecLua($"SetCVar('{cvarName}', {cvarValue})"); } })), /* command all to exit vehicle */ "ev" => new Action <Client, IList <string> >((self, args) => { foreach (Client client in clients) { client.ExecLua("VehicleExit()"); } }), /* command all Slaves to follow target */ "fw" => new Action <Client, IList <string> >((self, args) => { if (!followOn) { // about to change to follow-on, set appropriate follow target if (args.Count > 0 && args[0] == "mo") { var targetGuid = self.Memory.ReadInt64(IntPtr.Zero + Offset.MouseoverGUID); if (targetGuid != 0) { followUnit = self.ObjectManager.First(obj => obj.GUID == targetGuid); self.ExecLua($"print('Follow ordered on guid: {targetGuid}')"); } else { self.ExecLua("print('No target selected')"); } } else { // master player as default follow unit followUnit = me.Player; } } followOn = !followOn; string state = followOn ? "ON" : "OFF"; string col = followOn ? "00FF00" : "FF0000"; me.ExecLua($"print('FOLLOW is now |cff{col}{state}|r')"); }), /* command selected Slave to cast spell on current Master target */ "cs" => new Action <Client, IList <string> >(((self, args) => { string casterName = args[0]; string spellName = args[1]; Int64 targetGuid = 0; if (args.Count > 2 && args[2] == "mo") // optional mouseover { targetGuid = me.Memory.ReadInt64(IntPtr.Zero + Offset.MouseoverGUID); } else { targetGuid = me.GetTargetGUID(); } Client caster = clients.FirstOrDefault(c => c.PlayerName == casterName); if (caster != null) { caster.EnqueuePrioritySpellCast( new SpellCast { Coordinates = null, SpellName = spellName, TargetGUID = targetGuid } ); } else { Console.WriteLine($"Couldn't find slave: {casterName}."); } })), /* use item */ "ui" => new Action <Client, IList <string> >(((self, args) => { IEnumerable <Client> users = null; string location = args[0]; string userName = args[1]; string itemName = args[2]; if (userName == "*") { users = clients; } else if (userName == "<slaves>") { users = Slaves; } else { Func <Client, bool> q = null; var targetGuid = me.Memory.ReadInt64(IntPtr.Zero + Offset.MouseoverGUID); if (targetGuid == 0) { q = c => c.ControlInterface.remoteControl.GetUnitName(c.Player.GetAddress()) == userName; } else { q = c => c.Player.GUID == targetGuid; } users = clients.Where(q); } foreach (var user in users) { if (user != null) { user.ExecLua(UtilScript); if (location == "inv") { user.ExecLua( $"filter = function(itemName) return itemName == \"{itemName}\" end;" + $"sfUseInventoryItem(filter)"); } else if (location == "bag") { user.ExecLua( $"filter = function(itemName) return itemName == \"{itemName}\" end;" + $"sfUseBagItem(filter)"); } } else { Console.WriteLine($"Couldn't find slave: {userName}."); } } })), /* cast terrain-targetable spell */ "ctts" => new Action <Client, IList <string> >(((self, args) => { string casterName = args[0]; string spellName = args[1]; Int64 targetGuid = 0; if (args.Count > 2 && args[2] == "mo") // optional mouseover { targetGuid = me.Memory.ReadInt64(IntPtr.Zero + Offset.MouseoverGUID); } else { targetGuid = me.GetTargetGUID(); } if (targetGuid == 0) { return; } Client caster = Slaves.FirstOrDefault(c => c.ControlInterface.remoteControl.GetUnitName(c.Player.GetAddress()) == casterName); if (caster != null) { GameObject targetObject = caster.ObjectManager.FirstOrDefault(obj => obj.GUID == targetGuid); if (targetObject != null) { caster.EnqueuePrioritySpellCast( new SpellCast { Coordinates = targetObject.Coordinates - Vector3.Random(), /* randomize location a little */ SpellName = spellName, TargetGUID = targetGuid } ); } else { Console.WriteLine($"Target not found."); } } else { Console.WriteLine($"Couldn't find slave: {casterName}."); } })), /* toggles AI(individual behaviour loops) */ "ta" => new Action <Client, IList <string> >(((self, args) => { string switchArg = args[0]; if (switchArg.Equals("ma")) { masterAI = !masterAI; string state = masterAI ? "ON" : "OFF"; Console.WriteLine($"MASTER AI is now {state}."); me.ExecLua($"SetMasterStatus('{state}')"); } else if (switchArg.Equals("sl")) { slavesAI = !slavesAI; string state = slavesAI ? "ON" : "OFF"; Console.WriteLine($"SLAVES AI is now {state}."); me.ExecLua($"SetSlavesStatus('{state}')"); } else if (switchArg.Equals("bu")) { buffingAI = !buffingAI; string state = buffingAI ? "ON" : "OFF"; Console.WriteLine($"BUFFING AI is now {state}."); me.ExecLua($"SetBuffingStatus('{state}')"); } else if (switchArg.Equals("ra")) { radarOn = !radarOn; string state = radarOn ? "ON" : "OFF"; Console.WriteLine($"RADAR is now {state}."); me.ExecLua($"SetRadarStatus('{state}')"); } else if (switchArg.Equals("in")) { inputMultiplexer.ConditionalBroadcastOn = !inputMultiplexer.ConditionalBroadcastOn; string state = inputMultiplexer.ConditionalBroadcastOn ? "ON" : "OFF"; Console.WriteLine($"EXTRA INPUT BROADCAST is now {state}."); me.ExecLua($"SetExInputBroadcastStatus('{state}')"); } })), /* command slaves to interact with Master mouseover target */ "it" => new Action <Client, IList <string> >(((self, args) => { Int64 masterTargetGuid = me.Memory.ReadInt64(IntPtr.Zero + Offset.MouseoverGUID); if (masterTargetGuid == 0) { return; } foreach (Client slave in Slaves) { slave.Memory.Write(IntPtr.Zero + Offset.MouseoverGUID, BitConverter.GetBytes(masterTargetGuid)); slave.ExecLua("InteractUnit('mouseover')"); } })), /* exec Lua */ "ex" => new Action <Client, IList <string> >(((self, args) => { foreach (Client slave in Slaves) { slave.ExecLua(args[0]); } })), /* click static popup */ "stat" => new Action <Client, IList <string> >(((self, args) => { foreach (Client client in Slaves) { // arg is button number client.ExecLua($"StaticPopup1Button{args[0]}:Click()"); } })), /* fixate on target */ "fix" => new Action <Client, IList <string> >(((self, args) => { var targetGuid = me.GetTargetGUID(); if (targetGuid == 0) { return; } fixateTargetGuid = targetGuid; Console.WriteLine($"Fixated on {fixateTargetGuid}"); })), /* toggles simple rotation */ "rot" => new Action <Client, IList <string> >(((self, args) => { complexRotation = !complexRotation; string state = complexRotation ? "ON" : "OFF"; Console.WriteLine($"Complex Rotation is now {state}."); me.ExecLua($"SetRotationStatus('{state}')"); })), "frm" => new Action <Client, IList <string> >(((self, args) => { const float magnitude = 5f; var formation = new[] { new Vector3(-magnitude, -magnitude, 0f), new Vector3(magnitude, magnitude, 0f), new Vector3(-magnitude, magnitude, 0f), new Vector3(magnitude, -magnitude, 0f), }; var formationIndex = 0; foreach (var slave in Slaves) { if (slave.GetObjectMgrAndPlayer()) { Int64 _dummyGuid = 0; Vector3 destination = slave.Player.Coordinates - formation[formationIndex]; slave .ControlInterface .remoteControl .CGPlayer_C__ClickToMove( slave.Player.GetAddress(), ClickToMoveType.Move, ref _dummyGuid, ref destination, 1f); formationIndex++; } } })), /* bring to foreground selected client game window */ "fg" => new Action <Client, IList <string> >(((self, args) => { Client client; long targetGuid; if (args.Count > 0 && args[0] == "mo") // optional mouseover { targetGuid = self.Memory.ReadInt64(IntPtr.Zero + Offset.MouseoverGUID); if (targetGuid == 0) { // use tooltip text // this enables range-unlimited switching var getUnitNameFromMouseoverTooltipScript = "if GameTooltip:NumLines() > 0 then name = _G['GameTooltipTextLeft1']:GetText() else name = nil end"; var name = self.ExecLuaAndGetResult(getUnitNameFromMouseoverTooltipScript, "name"); client = clients.FirstOrDefault(c => c.PlayerName == name); if (client == null) { Console.WriteLine($"Couldn't find client with player name {name}."); } } else { client = clients.FirstOrDefault(c => c.Player.GUID == targetGuid); } } else { targetGuid = self.GetTargetGUID(); client = clients.FirstOrDefault(c => c.Player.GUID == targetGuid); } if (client != null) { self.ControlInterface.remoteControl.YieldWindowFocus(client.Process.MainWindowHandle); } else { Console.WriteLine($"Couldn't find client with player guid {targetGuid}."); } })), _ => new Action <Client, IList <string> >(((self, args) => { Console.WriteLine($"Unrecognized command: {cmd}."); })), });
public void RemoveSlave(SlaveInstance slave) { Slaves.Remove(slave.EndPoint.ToString()); }