private void CastSkill(TriggerCommand command, params object[] arguments) { if (!(arguments[0] is Player target)) { return; } target.SendChatMessage($"Laser!"); var parameters = command.Arguments.Split(','); var skill = int.Parse(parameters[0]); var skillComponent = GameObject.AddComponent <SkillComponent>(); var _ = Task.Run(async() => { try { await skillComponent.CalculateSkillAsync(skill, target); } catch (Exception e) { Logger.Error(e.Message); throw; } }); }
private void UpdateMission(TriggerCommand command, params object[] arguments) { if (!(arguments[0] is Player target)) { return; } if (!target.TryGetComponent <MissionInventoryComponent>(out var missionInventoryComponent)) { return; } var commandArgs = command.Arguments.Split(','); if (commandArgs.Length == 0) { return; } switch (commandArgs.First()) { // ReSharper disable once StringLiteralTypo case "exploretask": _ = missionInventoryComponent.DiscoverAsync(commandArgs.Last()); break; } }
private void ExecuteTriggerCommand(TriggerCommand command, params object[] arguments) { Logger.Information($"TRIGGER: {command.Id} -> {string.Join(", ", arguments)}"); switch (command.Id) { case "SetPhysicsVolumeEffect": SetPhysicsVolumeEffect(command); break; case "CastSkill": CastSkill(command, arguments); break; case "pushObject": PushObject(command, arguments); break; case "repelObject": RepealObject(command, arguments); break; case "updateMission": UpdateMission(command, arguments); break; case "DestroySpawnerNetworkObjects": DestroySpawnerNetworkObjects(command, arguments); break; } GameObject.Serialize(GameObject); }
private void startDisplayTrigger(TriggerCommand triggerCommand) { foreach (var builders in displayValueBuilders) { builders.Value.StartDisplayTrigger(triggerCommand); } }
private void SetPhysicsVolumeEffect(TriggerCommand command) { if (!GameObject.TryGetComponent <PhantomPhysicsComponent>(out var physicsComponent)) { return; } var arguments = command.Arguments.Split(','); physicsComponent.IsEffectActive = true; var effectTypeInfo = typeof(PhantomPhysicsEffectType); var effectType = (PhantomPhysicsEffectType)Enum.Parse(effectTypeInfo, arguments[0]); physicsComponent.EffectType = effectType; var amount = float.Parse(arguments[1]); physicsComponent.EffectAmount = amount; if (arguments.Length > 2) { var direction = new Vector3 { X = float.Parse(arguments[2]), Y = float.Parse(arguments[3]), Z = float.Parse(arguments[4]) }; physicsComponent.EffectDirection = direction; } }
private void RepealObject(TriggerCommand command, params object[] arguments) { if (!(arguments[0] is Player target)) { return; } var targetDirection = Transform.Position - target.Transform.Position; var rotation = targetDirection.QuaternionLookRotation(Vector3.UnitY); var forward = rotation.VectorMultiply(Vector3.UnitX); var parameters = command.Arguments.Split(','); target.SendChatMessage($"Knockback!"); target.Message(new KnockbackMessage { Associate = target, Caster = GameObject, Originator = GameObject, KnockbackTime = 1, Vector = forward * float.Parse(parameters[0]) }); }
public TriggerCommand StartTriggerGroup(string triggerName, double startTime, double endTime, int group = 0) { var triggerCommand = new TriggerCommand(triggerName, startTime, endTime, group); addCommand(triggerCommand); startDisplayTrigger(triggerCommand); return(triggerCommand); }
public void StartDisplayTrigger(TriggerCommand triggerCommand) { if (composite != null) { throw new InvalidOperationException("Cannot start trigger: already inside a loop or trigger"); } decorate = (command) => new TriggerDecorator <TValue>(command); composite = new CompositeCommand <TValue>(); }
/// <summary> /// Initializes the commands. /// </summary> /// <remarks> /// </remarks> private void InitializeCommands() { this.ToggleCommandA = new ToggleCommand <object>(this.OnTestCommand) { Caption = "Toggle A", Hint = "Test Command Toggle A", KeyTip = "A" }; this.ListModeCommand = new ToggleCommand <object>(this.ActivateMode) { Caption = "List Mode", Hint = "Activate the list mode on the plots.", KeyTip = "L", IsChecked = true }; this.SampleGroupModeCommand = new ToggleCommand <object>(this.HandleColorBySampleGroupFlag) { Caption = "Color by Sample Group", Hint = "Activate the color by sample group mode on the plots.", KeyTip = "G", IsChecked = false }; this.OverlayModeCommand = new ToggleCommand <object>(this.ActivateMode) { Caption = "Overlay Mode", Hint = "Activate the overlay mode on the plots.", KeyTip = "O" }; this.GroupOverlayModeCommand = new ToggleCommand <object>(this.ActivateMode) { Caption = "Sample Group Overlay Mode", Hint = "Activate the sample group overlay mode on the plots.", KeyTip = "O" }; this.ExportCommand = new TriggerCommand <object>(obj => this.ExportData()) { Caption = "Export Data", Hint = "Export Table data to a png file.", KeyTip = "E" }; this.TriggerCommandB = new TriggerCommand <object>(this.OnTestCommand) { Caption = "Trigger B", Hint = "Test Command Trigger B", KeyTip = "B" }; DisplayMode = "List"; }
private void DestroySpawnerNetworkObjects(TriggerCommand command, params object[] arguments) { var name = command.Arguments; // Find all networks with this name var networks = Zone.GameObjects.Where(o => o.Name == name); // Destroy all found networks foreach (var networkObject in networks.ToArray()) { Destroy(networkObject); } }
public IEnumerable<Command> Parse(IEnumerable<string> data_arr) { var condition_text = data_arr.ElementAt(1); var condition = TriggerConditionBase.Parse(condition_text); TriggerCommand command = new TriggerCommand(); command.Condition=condition; command.StartTime=data_arr.ElementAt(2).ToInt(); command.EndTime=string.IsNullOrWhiteSpace(data_arr.ElementAt(3)) ? command.StartTime : data_arr.ElementAt(3).ToInt(); command.GroupID=data_arr.Count()>4 ? (string.IsNullOrWhiteSpace(data_arr.ElementAt(4)) ? 0 : data_arr.ElementAt(4).ToInt()) : 0; yield return command; }
/// <summary> /// Initializes the commands. /// </summary> /// <remarks> /// </remarks> private void InitializeCommands() { this.ToggleCommandA = new ToggleCommand <object>(this.OnTestCommand) { Caption = "Toggle A", Hint = "Test Command Toggle A", KeyTip = "A" }; this.TriggerCommandB = new TriggerCommand <object>(this.OnTestCommand) { Caption = "Trigger B", Hint = "Test Command Trigger B", KeyTip = "B" }; }
private void AddTriggerCommand(TriggerCommand trigger_command, bool insert = false) { if (!Triggers.TryGetValue(trigger_command.GroupID, out var list)) { Triggers[trigger_command.GroupID] = new HashSet <TriggerCommand>(); } Triggers[trigger_command.GroupID].Add(trigger_command); trigger_command.BindObject(this); TriggerListener.DefaultListener.Add(this); if (!CommandMap.TryGetValue(Event.Trigger, out var x) || x.Count == 0) { BaseTransformResetAction += TriggerCommand.OverrideDefaultValue; } }
/// <summary> /// Initializes the commands. /// </summary> /// <remarks> /// </remarks> private void InitializeCommands() { this.ToggleCommandA = new ToggleCommand <object>(this.OnTestCommand) { Caption = "Toggle A", Hint = "Test Command Toggle A", KeyTip = "A" }; this.TriggerCommandB = new TriggerCommand <object>(this.OnTestCommand) { Caption = "Trigger B", Hint = "Test Command Trigger B", KeyTip = "B" }; this.ExperimentSetupCommand = new TriggerCommand <object>(this.SetExperimentSetupState) { Caption = "Experiment Setup", Hint = "Experiment Setup", KeyTip = "E" }; this.FeatureExtractionCommand = new ToggleCommand <object>(this.OnTestCommand)//(this.runMFEWithBusyIndicator) { Caption = "Feature Extraction", Hint = "Feature Extraction", KeyTip = "F" }; this.StatisticAnalysisCommand = new TriggerCommand <object>(this.OnTestCommand) { Caption = "Statistical Analysis", Hint = "Statistical Analysis", KeyTip = "S" }; this.IdentificationCommand = new TriggerCommand <object>(this.OnTestCommand) { Caption = "Identification", Hint = "Identification", KeyTip = "I" }; this.ReportCommand = new SelectorCommand <object>(this.OnTestCommand) { Caption = "Report", Hint = "Report", KeyTip = "R" }; }
public GAConfigurationWindowViewModel() { // instatntiate and initialize _basisAirfoilConfiguratorVisibility = Visibility.Visible; basisAirfoilMethodConfigManager = new BasisAirfoilConfigManager(); _selectedRepMethod = airfoilRepMethod[0]; // Regist callbacks PropertyChanged += thisPropertisDidChange; basisAirfoilMethodConfigManager.readyStatusDidChange += BasisAirfoilMethodConfigManager_readyStatusDidChange; // Regist TriggerCommands closingWindow = new TriggerCommand(closingWindowExecute, closingWindowCanExecute); applyButtonDidClick = new TriggerCommand(applyButtonExecute, applyButtonCanExecute); cancelButtonDidClick = new TriggerCommand(cancelButtonExecute, cancelButtonCanExecute); addButtonDidClick = new TriggerCommand(addButtonExecute, addButtunCanExecute); removeButtonDidClick = new TriggerCommand(removeButtonExecute, removeButtonCenExecute); // Load Current Configuration // Basis Airfoil Method ---------------------------------------------------- // var basisAirfoilMethod = OptimizationManager.instance.representedAirfoilsManager?.airfoilRepresentationMethod as BasisAirfoilsMethod; if (basisAirfoilMethod != null) { foreach (var airfoil in basisAirfoilMethod?.basisAirfoils) { basisAirfoilItems.Add(new BasisAirfoilItem(airfoil)); } } // ------------------------------------------------------------------------- // // B-Spline Method --------------------------------------------------------- // // ------------------------------------------------------------------------- // // PARSEC Method ----------------------------------------------------------- // // ------------------------------------------------------------------------- // // Generate Mock for debugging --------------------------------------------- // // ------------------------------------------------------------------------- // }
/// <summary> /// Initializes the commands. /// </summary> /// <remarks> /// </remarks> private void InitializeCommands() { this.ToggleCommandA = new ToggleCommand <object>(this.OnTestCommand) { Caption = "Toggle A", Hint = "Test Command Toggle A", KeyTip = "A" }; this.TriggerCommandB = new TriggerCommand <object>(this.OnTestCommand) { Caption = "Trigger B", Hint = "Test Command Trigger B", KeyTip = "B" }; this.ExportCommand = new TriggerCommand <object>(obj => this.ExportData()) { Caption = "Export Data", Hint = "Export Table data to a png file.", KeyTip = "E" }; }
/// <summary> /// When receiving a command from the wire parse using this method into a CBus Command /// </summary> /// <param name="CommandBytes"></param> /// <param name="Command"></param> /// <returns></returns> internal static bool TryParse(byte[] CommandBytes, int CommandLength, bool IsShortFormMessage, byte CBusApplicationAddress, ref int dataPointer, out CBusTriggerCommand Command) { Command = null; var triggerCommandList = new List <TriggerCommand>(); CBusHeader header; CBusHeader.TryParse(CommandBytes[0], out header); //As message length includes checksum, where as we just want the payload length var messagePayloadLenght = (CommandLength - 1); //Process Contained Commands while (dataPointer < messagePayloadLenght) { //Most Significant Bit indicates long or short format comamnd if ((CommandBytes[dataPointer] & 0x80) == 0) { //Short form command byte group = 0; var triggerCommandType = TriggerCommand.TriggerCommandId.UNKNOWN; if (!Enum.IsDefined(typeof(TriggerCommand.TriggerCommandId), CommandBytes[dataPointer])) { return(false); } //Lower 3 bites of command //var commandLength = (commandId & 0x07); triggerCommandType = (TriggerCommand.TriggerCommandId)CommandBytes[dataPointer++]; group = CommandBytes[dataPointer++]; //Add the command switch (triggerCommandType) { case TriggerCommand.TriggerCommandId.EVENT: { var triggerGroup = CommandBytes[dataPointer++]; var Action = CommandBytes[dataPointer++]; var cmd = new TriggerCommand(triggerGroup, Action); triggerCommandList.Add(cmd); break; } //Also contain level parameter case TriggerCommand.TriggerCommandId.TRIGGER_MIN: case TriggerCommand.TriggerCommandId.TRIGGER_MAX: case TriggerCommand.TriggerCommandId.TRIGGER_KILL: { var triggerGroup = CommandBytes[dataPointer++]; var cmd = new TriggerCommand(triggerCommandType, triggerGroup); triggerCommandList.Add(cmd); break; } case TriggerCommand.TriggerCommandId.UNKNOWN: default: return(false); } } else { //Long form command, not implemented break; } } Command = new CBusTriggerCommand(header, CBusApplicationAddress, triggerCommandList); return(true); }