Esempio n. 1
0
        // 「命令」コマンドを終了
        private void FinishOrderCommand()
        {
            switch (SelectedCommand ?? "")
            {
            case "移動命令":
            {
                SelectedUnit.Mode = SrcFormatter.Format(SelectedX) + " " + SrcFormatter.Format(SelectedY);
                break;
            }

            case "攻撃命令":
            case "護衛命令":
            {
                SelectedUnit.Mode = SelectedTarget.MainPilot().ID;
                break;
            }
            }

            if (ReferenceEquals(Status.DisplayedUnit, SelectedUnit))
            {
                Status.DisplayUnitStatus(SelectedUnit);
            }

            GUI.RedrawScreen();
            CommandState = "ユニット選択";
        }
Esempio n. 2
0
 public void InteractWithTarget(GameObject player)
 {
     if (_hasTargetSelected)
     {
         SelectedTarget.GetComponent <InteractableObject>().Interact(player);
     }
 }
Esempio n. 3
0
        // 「会話」コマンドを終了
        private void FinishTalkCommand()
        {
            Pilot p;

            GUI.LockGUI();
            if (SelectedUnit.CountPilot() > 0)
            {
                p = SelectedUnit.Pilots.First();
            }
            else
            {
                p = null;
            }

            // 会話イベントを実施
            Event.HandleEvent("会話", SelectedUnit.MainPilot().ID, SelectedTarget.MainPilot().ID);
            if (SRC.IsScenarioFinished)
            {
                SRC.IsScenarioFinished = false;
                return;
            }

            if (p is object)
            {
                if (p.Unit is object)
                {
                    SelectedUnit = p.Unit;
                }
            }

            GUI.UnlockGUI();

            // 行動終了
            WaitCommand();
        }
        private void RestoreAllSFARs()
        {
            bool restore;

            checkSFARRestoreForBackup();
            if (SelectedTarget.TextureModded)
            {
                if (!Settings.DeveloperMode)
                {
                    M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_restoringSfarsAlotBlocked), M3L.GetString(M3L.string_cannotRestoreSfarFiles), MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                else
                {
                    var res = M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_restoringSfarsAlotDevMode), M3L.GetString(M3L.string_invalidTexturePointersWarning), MessageBoxButton.YesNo, MessageBoxImage.Warning);
                    restore = res == MessageBoxResult.Yes;
                }
            }
            else
            {
                restore = M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_restoreAllModifiedSfarsQuestion), M3L.GetString(M3L.string_confirmRestoration), MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes;
            }
            if (restore)
            {
                foreach (var v in SelectedTarget.ModifiedSFARFiles)
                {
                    SelectedTarget.RestoreSFAR(v, true);
                }
            }
        }
Esempio n. 5
0
        // 「補給」コマンドを終了
        private void FinishSupplyCommand()
        {
            GUI.LockGUI();
            GUI.OpenMessageForm(SelectedTarget, SelectedUnit);
            var currentUnit = SelectedUnit;

            // 選択内容を変更
            Event.SelectedUnitForEvent   = SelectedUnit;
            Event.SelectedTargetForEvent = SelectedTarget;

            // 補給メッセージ&特殊効果
            if (currentUnit.IsMessageDefined("補給"))
            {
                currentUnit.PilotMessage("補給", msg_mode: "");
            }

            if (currentUnit.IsAnimationDefined("補給", currentUnit.FeatureName("補給装置")))
            {
                currentUnit.PlayAnimation("補給", currentUnit.FeatureName("補給装置"));
            }
            else
            {
                currentUnit.SpecialEffect("補給", currentUnit.FeatureName("補給装置"));
            }

            GUI.DisplaySysMessage(currentUnit.Nickname + "は" + SelectedTarget.Nickname + "に" + currentUnit.FeatureName("補給装置") + "を使った。");

            // 補給を実施
            SelectedTarget.FullSupply();
            SelectedTarget.IncreaseMorale(-10);

            if (Information.IsNumeric(GeneralLib.LIndex(currentUnit.FeatureData("補給装置"), 2)))
            {
                currentUnit.EN = currentUnit.EN - Conversions.ToInteger(GeneralLib.LIndex(currentUnit.FeatureData("補給装置"), 2));
            }

            GUI.UpdateMessageForm(SelectedTarget, SelectedUnit);
            GUI.DisplaySysMessage(SelectedTarget.Nickname + "の弾数と" + Expression.Term("EN", SelectedTarget) + "が全快した。");

            // 経験値を獲得
            currentUnit.GetExp(SelectedTarget, "補給", exp_mode: "");
            if (GUI.MessageWait < 10000)
            {
                GUI.Sleep(GUI.MessageWait);
            }

            // 形態変化のチェック
            SelectedTarget.Update();
            SelectedTarget.CurrentForm().CheckAutoHyperMode();
            SelectedTarget.CurrentForm().CheckAutoNormalMode();
            GUI.CloseMessageForm();

            // 行動終了
            WaitCommand();
        }
Esempio n. 6
0
        public void RefreshASIStates()
        {
            // Rebuild the list of shown ASIs
            if (SelectedTarget != null)
            {
                var selectedObject          = SelectedASI;
                var installedASIs           = SelectedTarget.GetInstalledASIs();
                var installedKnownASIMods   = installedASIs.OfType <KnownInstalledASIMod>();
                var installedUnknownASIMods = installedASIs.OfType <UnknownInstalledASIMod>();
                var notInstalledASIs        = ASIManager.GetASIModsByGame(SelectedTarget.Game).Except(installedKnownASIMods.Select(x => x.AssociatedManifestItem.OwningMod));
                DisplayedASIMods.ReplaceAll(installedKnownASIMods.OrderBy(x => x.AssociatedManifestItem.Name));
                DisplayedASIMods.AddRange(installedUnknownASIMods.OrderBy(x => x.UnmappedFilename));
                DisplayedASIMods.AddRange(notInstalledASIs.OrderBy(x => x.LatestVersion.Name));

                // Attempt to re-select the existing object
                if (DisplayedASIMods.Contains(selectedObject))
                {
                    SelectedASI = selectedObject;
                }
                else
                {
                    foreach (var v in DisplayedASIMods)
                    {
                        if (v is KnownInstalledASIMod kim && kim.AssociatedManifestItem.OwningMod == selectedObject)
                        {
                            SelectedASI = v;
                            break;
                        }
                    }
                }



                //Application.Current.Dispatcher.Invoke(() =>
                //{
                //    DisplayedASIMods.ReplaceAll(DisplayedASIMods.Where(x => x is ASIMod).ToList());
                //});
                ////Clear installation states
                //foreach (var asi in DisplayedASIMods)
                //{
                //    if (asi is ASIMod a)
                //    {
                //        //a.UIOnly_Installed = false;
                //        //a.UIOnly_Outdated = false;
                //        //a.InstalledInfo = null;
                //    }
                //}
            }

            //InstalledASIs = GetInstalledASIMods(Game);
            //MapInstalledASIs();
            //UpdateSelectionTexts(SelectedASI);
        }
 public void OnSelectedTargetChanged()
 {
     if (SelectedTarget != null)
     {
         SelectedTarget.PopulateDLCMods(false, modNamePrefersTPMI: true);
         InstalledDLCModsForGame.ReplaceAll(SelectedTarget.UIInstalledDLCMods.OrderBy(x => x.InstalledByManagedSolution));
     }
     else
     {
         InstalledDLCModsForGame.ClearEx();
     }
 }
        public static AIHeroClient GetTarget(float range, DamageType damageType, Vector3?source = null, bool addBoundingRadius = false)
        {
            var sourcePosition = source ?? Player.Instance.ServerPosition;

            if (SelectedEnabled && SelectedTarget.IsValidTarget())
            {
                if (OnlySelectedTarget)
                {
                    return(SelectedTarget);
                }
                if (sourcePosition.IsInRange(SelectedTarget, range * 1.15f))
                {
                    return(SelectedTarget);
                }
            }
            return(GetTarget(EntityManager.Heroes.Enemies.Where(h => h.IsValidTarget() && sourcePosition.IsInRange(h, range + (addBoundingRadius ? h.BoundingRadius : 0))), damageType));
        }
Esempio n. 9
0
        // スペシャルパワーコマンドを終了
        private void FinishSpecialPowerCommand()
        {
            GUI.LockGUI();

            // 自爆を選択した場合は確認を取る
            {
                var spd = SRC.SPDList.Item(SelectedSpecialPower);
                if (spd.Effects.Any(x => x.strEffectType == "自爆"))
                {
                    if (GUI.Confirm("自爆させますか?", "自爆", GuiConfirmOption.OkCancel | GuiConfirmOption.Question) != GuiDialogResult.Ok)
                    {
                        CommandState = "ユニット選択";
                        GUI.UnlockGUI();
                        return;
                    }
                }
            }

            // 使用イベント
            Event.HandleEvent("使用", SelectedUnit.MainPilot().ID, SelectedSpecialPower);
            if (SRC.IsScenarioFinished)
            {
                SRC.IsScenarioFinished = false;
                CommandState           = "ユニット選択";
                GUI.UnlockGUI();
                return;
            }

            if (SRC.IsCanceled)
            {
                SRC.IsCanceled = false;
                CommandState   = "ユニット選択";
                GUI.UnlockGUI();
                return;
            }

            // スペシャルパワーを使用
            if (WithDoubleSPConsumption)
            {
                SelectedPilot.UseSpecialPower(SelectedSpecialPower, 2d);
            }
            else
            {
                SelectedPilot.UseSpecialPower(SelectedSpecialPower);
            }

            SelectedUnit = SelectedUnit.CurrentForm();

            // ステータスウィンドウを更新
            if (SelectedTarget is object)
            {
                if (SelectedTarget.CurrentForm().Status == "出撃")
                {
                    Status.DisplayUnitStatus(SelectedTarget);
                }
            }

            // 使用後イベント
            Event.HandleEvent("使用後", SelectedUnit.MainPilot().ID, SelectedSpecialPower);
            if (SRC.IsScenarioFinished)
            {
                SRC.IsScenarioFinished = false;
            }

            if (SRC.IsCanceled)
            {
                SRC.IsCanceled = false;
            }

            SelectedSpecialPower = "";
            GUI.UnlockGUI();
            CommandState = "ユニット選択";
        }
        /// <summary>
        /// This method is run on a background thread so all UI calls needs to be wrapped
        /// </summary>
        private void PopulateUI()
        {
            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (a, b) =>
            {
                bool deleteConfirmationCallback(InstalledDLCMod mod)
                {
                    if (Utilities.IsGameRunning(SelectedTarget.Game))
                    {
                        M3L.ShowDialog(Window.GetWindow(this),
                                       M3L.GetString(M3L.string_interp_cannotDeleteModsWhileXIsRunning,
                                                     Utilities.GetGameName(SelectedTarget.Game)), M3L.GetString(M3L.string_gameRunning),
                                       MessageBoxButton.OK, MessageBoxImage.Error);
                        return(false);
                    }

                    if (SelectedTarget.TextureModded)
                    {
                        var res = M3L.ShowDialog(Window.GetWindow(this),
                                                 M3L.GetString(M3L.string_interp_deletingXwhileAlotInstalledUnsupported, mod.ModName),
                                                 M3L.GetString(M3L.string_deletingWillPutAlotInUnsupportedConfig), MessageBoxButton.YesNo,
                                                 MessageBoxImage.Error);
                        return(res == MessageBoxResult.Yes);
                    }

                    return(M3L.ShowDialog(Window.GetWindow(this),
                                          M3L.GetString(M3L.string_interp_removeXFromTheGameInstallationQuestion, mod.ModName),
                                          M3L.GetString(M3L.string_confirmDeletion), MessageBoxButton.YesNo,
                                          MessageBoxImage.Warning) == MessageBoxResult.Yes);
                }

                void notifyDeleted()
                {
                    PopulateUI();
                }

                SelectedTarget.PopulateDLCMods(true, deleteConfirmationCallback, notifyDeleted);
                SelectedTarget.PopulateExtras();
                SelectedTarget.PopulateTextureInstallHistory();
                bool restoreBasegamefileConfirmationCallback(string filepath)
                {
                    if (Utilities.IsGameRunning(SelectedTarget.Game))
                    {
                        M3L.ShowDialog(Window.GetWindow(this),
                                       M3L.GetString(M3L.string_interp_cannotRestoreFilesWhileXIsRunning,
                                                     Utilities.GetGameName(SelectedTarget.Game)), M3L.GetString(M3L.string_gameRunning),
                                       MessageBoxButton.OK, MessageBoxImage.Error);
                        return(false);
                    }

                    if (SelectedTarget.TextureModded && filepath.RepresentsPackageFilePath())
                    {
                        if (!Settings.DeveloperMode)
                        {
                            M3L.ShowDialog(Window.GetWindow(this),
                                           M3L.GetString(M3L.string_interp_restoringXWhileAlotInstalledIsNotAllowed,
                                                         Path.GetFileName(filepath)), M3L.GetString(M3L.string_cannotRestorePackageFiles),
                                           MessageBoxButton.OK, MessageBoxImage.Error);
                            return(false);
                        }
                        else
                        {
                            var res = M3L.ShowDialog(Window.GetWindow(this),
                                                     M3L.GetString(M3L.string_interp_restoringXwhileAlotInstalledLikelyBreaksThingsDevMode,
                                                                   Path.GetFileName(filepath)),
                                                     M3L.GetString(M3L.string_invalidTexturePointersWarning), MessageBoxButton.YesNo,
                                                     MessageBoxImage.Warning);
                            return(res == MessageBoxResult.Yes);
                        }
                    }

                    bool?holdingShift = Keyboard.Modifiers == ModifierKeys.Shift;

                    if (!holdingShift.Value)
                    {
                        holdingShift = null;
                    }
                    return(holdingShift ?? M3L.ShowDialog(Window.GetWindow(this),
                                                          M3L.GetString(M3L.string_interp_restoreXquestion, Path.GetFileName(filepath)),
                                                          M3L.GetString(M3L.string_confirmRestoration), MessageBoxButton.YesNo,
                                                          MessageBoxImage.Warning) == MessageBoxResult.Yes);
                }

                bool restoreSfarConfirmationCallback(string sfarPath)
                {
                    if (Utilities.IsGameRunning(SelectedTarget.Game))
                    {
                        M3L.ShowDialog(Window.GetWindow(this),
                                       M3L.GetString(M3L.string_interp_cannotRestoreFilesWhileXIsRunning,
                                                     Utilities.GetGameName(SelectedTarget.Game)), M3L.GetString(M3L.string_gameRunning),
                                       MessageBoxButton.OK, MessageBoxImage.Error);
                        return(false);
                    }

                    if (SelectedTarget.TextureModded)
                    {
                        if (!Settings.DeveloperMode)
                        {
                            M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_restoringSfarsAlotBlocked),
                                           M3L.GetString(M3L.string_cannotRestoreSfarFiles), MessageBoxButton.OK,
                                           MessageBoxImage.Error);
                            return(false);
                        }
                        else
                        {
                            var res = M3L.ShowDialog(Window.GetWindow(this),
                                                     M3L.GetString(M3L.string_restoringSfarsAlotDevMode),
                                                     M3L.GetString(M3L.string_invalidTexturePointersWarning), MessageBoxButton.YesNo,
                                                     MessageBoxImage.Warning);
                            return(res == MessageBoxResult.Yes);
                        }
                    }

                    //Todo: warn of unpacked file deletion
                    bool?holdingShift = Keyboard.Modifiers == ModifierKeys.Shift;

                    if (!holdingShift.Value)
                    {
                        holdingShift = null;
                    }
                    return(holdingShift ?? M3L.ShowDialog(Window.GetWindow(this),
                                                          M3L.GetString(M3L.string_interp_restoreXquestion, sfarPath),
                                                          M3L.GetString(M3L.string_confirmRestoration), MessageBoxButton.YesNo,
                                                          MessageBoxImage.Warning) == MessageBoxResult.Yes);
                }

                void notifyStartingSfarRestoreCallback()
                {
                    SFARBeingRestored = true;
                }

                void notifyStartingBasegameFileRestoreCallback()
                {
                    BasegameFilesBeingRestored = true;
                }

                void notifyRestoredCallback(object itemRestored)
                {
                    if (itemRestored is GameTarget.ModifiedFileObject mf)
                    {
                        Application.Current.Dispatcher.Invoke(delegate
                        {
                            SelectedTarget.ModifiedBasegameFiles.Remove(mf);
                        });
                        bool resetBasegameFilesBeingRestored = SelectedTarget.ModifiedBasegameFiles.Count == 0;
                        if (!resetBasegameFilesBeingRestored)
                        {
                            resetBasegameFilesBeingRestored =
                                !SelectedTarget.ModifiedBasegameFiles.Any(x => x.Restoring);
                        }

                        if (resetBasegameFilesBeingRestored)
                        {
                            BasegameFilesBeingRestored = false;
                        }
                    }
                    else if (itemRestored is GameTarget.SFARObject ms)
                    {
                        if (!ms.IsModified)
                        {
                            SelectedTarget.ModifiedSFARFiles.Remove(ms);
                        }

                        bool resetSfarsBeingRestored = SelectedTarget.ModifiedSFARFiles.Count == 0;
                        if (!resetSfarsBeingRestored)
                        {
                            resetSfarsBeingRestored = !SelectedTarget.ModifiedSFARFiles.Any(x => x.Restoring);
                        }

                        if (resetSfarsBeingRestored)
                        {
                            SFARBeingRestored = false;
                        }
                    }
                    else if (itemRestored == null)
                    {
                        //restore failed.
                        bool resetSfarsBeingRestored = SelectedTarget.ModifiedSFARFiles.Count == 0;
                        if (!resetSfarsBeingRestored)
                        {
                            resetSfarsBeingRestored = !SelectedTarget.ModifiedSFARFiles.Any(x => x.Restoring);
                        }

                        if (resetSfarsBeingRestored)
                        {
                            SFARBeingRestored = false;
                        }

                        bool resetBasegameFilesBeingRestored = SelectedTarget.ModifiedBasegameFiles.Count == 0;
                        if (!resetBasegameFilesBeingRestored)
                        {
                            resetBasegameFilesBeingRestored =
                                !SelectedTarget.ModifiedBasegameFiles.Any(x => x.Restoring);
                        }

                        if (resetBasegameFilesBeingRestored)
                        {
                            BasegameFilesBeingRestored = false;
                        }
                    }
                }

                SelectedTarget.PopulateModifiedBasegameFiles(restoreBasegamefileConfirmationCallback,
                                                             restoreSfarConfirmationCallback,
                                                             notifyStartingSfarRestoreCallback,
                                                             notifyStartingBasegameFileRestoreCallback,
                                                             notifyRestoredCallback);
                SFARBeingRestored = false;

                SelectedTarget.PopulateASIInfo();
                SelectedTarget.PopulateBinkInfo();

                if (SelectedTarget != null && !SelectedTarget.TextureModded)
                {
                    NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"BasegameSourceIdentifier");
                    nbw.DoWork += (a, b) =>
                    {
                        foreach (var v in SelectedTarget.ModifiedBasegameFiles.ToList())
                        {
                            v.DetermineSource();
                        }
                    };
                    nbw.RunWorkerAsync();
                }
            };
            bw.RunWorkerAsync();
        }
 private bool CanRestoreMPSFARs()
 {
     return(IsPanelOpen && SelectedTarget != null && SelectedTarget.Game != MEGame.Unknown && !Utilities.IsGameRunning(SelectedTarget.Game) && SelectedTarget.HasModifiedMPSFAR() && !SFARBeingRestored);
 }
Esempio n. 12
0
        public Composite CreateMainBehavior()
        {
            // NB: We need to allow lower BT nodes to run when the behavior is finished; otherwise, HB will not
            // process the change of _isBehaviorDone state.
            return(new PrioritySelector(

                       // If quest is done, behavior is done...
                       new Decorator(context => IsDone,
                                     new Action(context =>
            {
                _isBehaviorDone = true;
                QBCLog.Info("Finished");
            })),

                       // If using cannon, start spanking targets...
                       new Decorator(context => Query.IsInVehicle(),
                                     // Ready, Aim, Fire!
                                     new Action(context =>
            {
                // If ejected from vehicle, try to re-locate it...
                if ((CannonVehicle == null) || !CannonVehicle.IsValid)
                {
                    CannonVehicle = FindUnitsFromId(VehicleId_NurongsCannon).FirstOrDefault();
                    return;
                }

                // If target is no longer valid, select another...
                if (!IsViableTarget(CannonVehicle, SelectedTarget))
                {
                    SelectedTarget = ChooseTarget(CannonVehicle, SelectedTarget);
                    if (SelectedTarget == null)
                    {
                        return;
                    }
                    SelectedTarget.Target();
                }

                AimAndFireCannon(CannonVehicle, SelectedTarget);
            })),

                       // If not using cannon, get in cannon vehicle...
                       new Decorator(context => !Query.IsInVehicle(),
                                     new PrioritySelector(cannonContext => FindUnitsFromId(MobId_NurongsCannon).FirstOrDefault(),

                                                          // If unable to locate cannon, warn user and stop...
                                                          new Decorator(cannonContext => cannonContext == null,
                                                                        new PrioritySelector(
                                                                            // The Wait is a defensive bumper against a WoWclient/HBcore race condition...
                                                                            // Sometimes, the toon is ejected from the vehicle before the quest is marked as 'complete'.
                                                                            // We don't want this situation to cause the profile to stop, so we wait for a short while
                                                                            // before declaring a profile problem.
                                                                            new Wait(TimeSpan.FromMilliseconds(5000), cannonContext => IsDone, new ActionAlwaysSucceed()),
                                                                            new Action(cannonContext =>
            {
                QBCLog.Error("PROFILE ERROR: Nurong's Cannon is not in the area--please repair profile");
                TreeRoot.Stop();
                _isBehaviorDone = true;
            })
                                                                            )),

                                                          // Move close enough, and interact with cannon...
                                                          new Decorator(cannonContext => ((WoWUnit)cannonContext).Distance > ((WoWUnit)cannonContext).InteractRange,
                                                                        new Action(cannonContext => { Navigator.MoveTo(((WoWUnit)cannonContext).Location); })),
                                                          new Decorator(cannonContext => !Me.IsFacing((WoWUnit)cannonContext),
                                                                        new Action(cannonContext => { ((WoWUnit)cannonContext).Face(); })),
                                                          new Decorator(cannonContext => Me.IsMoving,
                                                                        new Action(cannonContext => { WoWMovement.MoveStop(); })),
                                                          new Decorator(cannonContext => !Query.IsInVehicle(),
                                                                        new Action(cannonContext =>
            {
                ((WoWUnit)cannonContext).Interact();
                CannonVehicle = null;
            })),
                                                          new Wait(TimeSpan.FromMilliseconds(5000), cannonContext => Query.IsInVehicle(), new ActionAlwaysSucceed())
                                                          ))
                       ));
        }
        internal static void Initialize()
        {
            #region Loading Priorities

            ActiveMode = TargetSelectorMode.Auto;

            PriorityData = JsonConvert.DeserializeObject <Dictionary <string, int> >(Resources.Priorities);
            foreach (var enemy in EntityManager.Heroes.Enemies.Where(enemy => !Priorities.ContainsKey(enemy.Hero)))
            {
                if (PriorityData.ContainsKey(enemy.ChampionName))
                {
                    Priorities.Add(enemy.Hero, PriorityData[enemy.ChampionName]);
                }
                else
                {
                    Logger.Log(LogLevel.Warn, "[TargetSelector] '{0}' is not present in database! Using priority 1!", enemy.ChampionName);
                    Priorities.Add(enemy.Hero, 1);
                }
                var name = enemy.ChampionName;
                CurrentPriorities.Add(enemy.Hero, () => Menu[name].Cast <Slider>().CurrentValue);
            }

            #endregion

            #region Menu Creation

            Menu = MainMenu.AddMenu("Target Selector", "TargetSelector2.0");

            Menu.AddGroupLabel("Target Selector Mode");

            var modeBox = new ComboBox("Selected Mode:", Enum.GetValues(typeof(TargetSelectorMode)).Cast <TargetSelectorMode>().Select(o => o.ToString()));
            Menu.Add("modeBox", modeBox).OnValueChange += delegate { ActiveMode = (TargetSelectorMode)Enum.Parse(typeof(TargetSelectorMode), modeBox.SelectedText); };

            if (Priorities.Count > 0)
            {
                Menu.AddGroupLabel("Priorities");
                Menu.AddLabel("(Higher value means higher priority)");
                foreach (var champ in Priorities)
                {
                    Menu.Add(champ.Key.ToString(), new Slider(champ.Key.ToString(), champ.Value, 1, 5));
                }

                Menu.AddSeparator();
                Menu.Add("reset", new CheckBox("Reset to default priorities", false)).OnValueChange += delegate(ValueBase <bool> sender, ValueBase <bool> .ValueChangeArgs args)
                {
                    if (args.NewValue)
                    {
                        foreach (var champ in Priorities)
                        {
                            Menu[champ.Key.ToString()].Cast <Slider>().CurrentValue = champ.Value;
                        }
                        sender.CurrentValue = false;
                    }
                };
            }

            Menu.AddGroupLabel("Selected Target Settings");
            Menu.Add("selectedTargetEnabled", new CheckBox("Enable manual selected target"));
            Menu.Add("drawSelectedTarget", new CheckBox("Draw a circle around selected target"));
            Menu.Add("drawNotifications", new CheckBox("Draw notifications about selected target"));
            Menu.AddGroupLabel("Only Attack Selected Target Settings");
            Menu.Add("onlySelectedTargetEnabled", new CheckBox("Enable only attack selected target", false));
            Menu.Add("onlySelectedTargetKey", new KeyBind("Only attack selected target toggle", false, KeyBind.BindTypes.PressToggle, 'Z')).OnValueChange +=
                delegate(ValueBase <bool> sender, ValueBase <bool> .ValueChangeArgs args)
            {
                if (OnlySelectedTargetEnabled)
                {
                    if (DrawNotifications)
                    {
                        Notifications.Notifications.Show(args.NewValue
                                ? new SimpleNotification("Target Selector", "Only attack selected target enabled.")
                                : new SimpleNotification("Target Selector", "Only attack selected target disabled."));
                    }
                }
            };

            #endregion

            #region Event Handling

            // TODO: Reenable when functioning

            /*Hud.OnTargetChange += delegate(HudChangeTargetEventArgs args)
             * {
             *  var target = args.Target as AIHeroClient;
             *  if (target != null && target.IsEnemy)
             *  {
             *      SelectedTarget = target;
             *  }
             * };*/
            // TODO: Disable when above functioning
            Messages.RegisterEventHandler(delegate(Messages.LeftButtonDown args)
            {
                if (!MenuGUI.IsChatOpen && !MainMenu.IsMouseInside && SelectedEnabled)
                {
                    var target = EntityManager.Heroes.Enemies.FirstOrDefault(o => o.IsValidTarget() && o.IsInRange(Game.ActiveCursorPos, 100));
                    if (DrawNotifications)
                    {
                        if (target != null)
                        {
                            Notifications.Notifications.Show(new SimpleNotification("Target Selector", "Selected " + target.ChampionName + " as target."));
                        }
                        else if (SelectedTarget != null)
                        {
                            Notifications.Notifications.Show(new SimpleNotification("Target Selector", "Unselected " + SelectedTarget.ChampionName + " as target."));
                        }
                    }
                    SelectedTarget = target;
                }
            });
            Drawing.OnDraw += delegate
            {
                if (SelectedEnabled && DrawCircleAroundSelected && SelectedTarget.IsValidTarget())
                {
                    Circle.Draw(Color.Red, OnlySelectedTarget ? 120 : 80, OnlySelectedTarget ? 15 : 5, SelectedTarget.Position);
                }
            };

            #endregion
        }
        public static AIHeroClient GetTarget(IEnumerable <AIHeroClient> possibleTargets, DamageType damageType)
        {
            var aiHeroClients = possibleTargets.ToList();
            var validTargets  = aiHeroClients.Where(h => !h.HasUndyingBuff(true)).ToList();

            if (validTargets.Count > 0)
            {
                aiHeroClients.Clear();
                aiHeroClients.AddRange(validTargets);
            }
            var selectedTargetIsValid = SelectedEnabled && SelectedTarget.IsValidTarget();

            if (selectedTargetIsValid)
            {
                if (OnlySelectedTarget)
                {
                    return(SelectedTarget);
                }
            }
            switch (aiHeroClients.Count)
            {
            case 0:
                return(null);

            case 1:
                return(aiHeroClients[0]);
            }
            if (selectedTargetIsValid)
            {
                if (aiHeroClients.Contains(SelectedTarget))
                {
                    return(SelectedTarget);
                }
            }
            switch (ActiveMode)
            {
            case TargetSelectorMode.NearMouse:
                return(aiHeroClients.OrderBy(h => h.Distance(Game.ActiveCursorPos, true)).FirstOrDefault());

            case TargetSelectorMode.LessCast:
                return(aiHeroClients.OrderByDescending(h => GetReducedPriority(h) * Player.Instance.CalculateDamageOnUnit(h, DamageType.Magical, 100) / h.Health).FirstOrDefault());

            case TargetSelectorMode.LessAttack:
                return(aiHeroClients.OrderByDescending(h => GetReducedPriority(h) * Player.Instance.CalculateDamageOnUnit(h, DamageType.Physical, 100) / h.Health).FirstOrDefault());

            case TargetSelectorMode.HighestPriority:
                return(aiHeroClients.OrderByDescending(GetPriority).FirstOrDefault());

            case TargetSelectorMode.MostAbilityPower:
                return(aiHeroClients.OrderByDescending(unit => unit.TotalMagicalDamage).FirstOrDefault());

            case TargetSelectorMode.MostAttackDamage:
                return(aiHeroClients.OrderByDescending(unit => unit.TotalAttackDamage).FirstOrDefault());

            case TargetSelectorMode.LeastHealth:
                return(aiHeroClients.OrderBy(unit => unit.Health).FirstOrDefault());

            case TargetSelectorMode.Closest:
                return(aiHeroClients.OrderBy(unit => unit.Distance(Player.Instance, true)).FirstOrDefault());

            case TargetSelectorMode.MostStack:
                return
                    (aiHeroClients.OrderByDescending(
                         h =>
                         (BuffStackNames.Sum(pair => pair.Key == Player.Instance.Hero || pair.Key == Champion.Unknown ? pair.Value.Sum(stack => Math.Max(h.GetBuffCount(stack), 0)) : 0) + 1) *
                         GetReducedPriority(h) * Player.Instance.CalculateDamageOnUnit(h, damageType == DamageType.Magical ? DamageType.Magical : DamageType.Physical, 100) / h.Health)
                     .FirstOrDefault());

            case TargetSelectorMode.Auto:
                return
                    (aiHeroClients.OrderByDescending(
                         h => GetReducedPriority(h) * Player.Instance.CalculateDamageOnUnit(h, damageType == DamageType.Magical ? DamageType.Magical : DamageType.Physical, 100) / h.Health)
                     .FirstOrDefault());
            }

            return(null);
        }
        private void PopulateUI()
        {
            bool deleteConfirmationCallback(InstalledDLCMod mod)
            {
                if (Utilities.IsGameRunning(SelectedTarget.Game))
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Cannot delete mods while {Utilities.GetGameName(SelectedTarget.Game)} is running.", $"Game is running", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(false);
                }
                if (SelectedTarget.ALOTInstalled)
                {
                    var res = Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Deleting {mod.ModName} while ALOT is installed will not cause the game to become broken, however you will not be able to install updates to ALOT without a full reinstallation (unsupported configuration).\n\nAre you sure you want to delete the DLC mod?", $"Deleting will put ALOT in unsupported configuration", MessageBoxButton.YesNo, MessageBoxImage.Error);
                    return(res == MessageBoxResult.Yes);
                }
                return(Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Remove {mod.ModName} from the game installation?", $"Confirm deletion", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes);
            }

            void notifyDeleted()
            {
                PopulateUI();
            }

            SelectedTarget.PopulateDLCMods(deleteConfirmationCallback, notifyDeleted);

            bool restoreBasegamefileConfirmationCallback(string filepath)
            {
                if (Utilities.IsGameRunning(SelectedTarget.Game))
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Cannot restore files while {Utilities.GetGameName(SelectedTarget.Game)} is running.", $"Game is running", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(false);
                }
                if (SelectedTarget.ALOTInstalled && filepath.RepresentsPackageFilePath())
                {
                    if (!Settings.DeveloperMode)
                    {
                        Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Restoring {Path.GetFileName(filepath)} while ALOT is installed is not allowed, as it will introduce invalid texture pointers into the installation.", $"Cannot restore package files", MessageBoxButton.OK, MessageBoxImage.Error);
                        return(false);
                    }
                    else
                    {
                        var res = Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Restoring {Path.GetFileName(filepath)} while ALOT is installed will very likely introduce invalid texture pointers into the installation, which may cause black textures or game crashes due to empty mips. Please ensure you know what you are doing before continuing.", $"Invalid texture pointers warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                        return(res == MessageBoxResult.Yes);
                    }
                }
                return(Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Restore {Path.GetFileName(filepath)}?", $"Confirm restoration", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes);
            }

            bool restoreSfarConfirmationCallback(string sfarPath)
            {
                if (Utilities.IsGameRunning(SelectedTarget.Game))
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Cannot restore files while {Utilities.GetGameName(SelectedTarget.Game)} is running.", $"Game is running", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(false);
                }

                if (SelectedTarget.ALOTInstalled)
                {
                    if (!Settings.DeveloperMode)
                    {
                        Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Restoring SFAR files while ALOT is installed is not allowed, as it will introduce invalid texture pointers into the installation.", $"Cannot restore SFAR files", MessageBoxButton.OK, MessageBoxImage.Error);
                        return(false);
                    }
                    else
                    {
                        var res = Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Restoring SFARs while ALOT is installed will introduce invalid texture pointers into the installation, which will cause black textures and possibly cause the game to crash. This operation will also delete all unpacked files from the directory. Please ensure you know what you are doing before continuing.", $"Invalid texture pointers warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                        return(res == MessageBoxResult.Yes);
                    }
                }
                //Todo: warn of unpacked file deletion
                return(Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Restore {sfarPath}?", $"Confirm restoration", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes);
            }

            void notifyStartingSfarRestoreCallback()
            {
                SFARBeingRestored = true;
            }

            void notifyStartingBasegameFileRestoreCallback()
            {
                BasegameFilesBeingRestored = true;
            }

            void notifyRestoredCallback(object itemRestored)
            {
                if (itemRestored is GameTarget.ModifiedFileObject mf)
                {
                    Application.Current.Dispatcher.Invoke(delegate { SelectedTarget.ModifiedBasegameFiles.Remove(mf); });
                    bool resetBasegameFilesBeingRestored = SelectedTarget.ModifiedBasegameFiles.Count == 0;
                    if (!resetBasegameFilesBeingRestored)
                    {
                        resetBasegameFilesBeingRestored = !SelectedTarget.ModifiedBasegameFiles.Any(x => x.Restoring);
                    }
                    if (resetBasegameFilesBeingRestored)
                    {
                        BasegameFilesBeingRestored = false;
                    }
                }
                else if (itemRestored is GameTarget.SFARObject ms)
                {
                    if (!ms.IsModified)
                    {
                        SelectedTarget.ModifiedSFARFiles.Remove(ms);
                    }
                    bool resetSfarsBeingRestored = SelectedTarget.ModifiedSFARFiles.Count == 0;
                    if (!resetSfarsBeingRestored)
                    {
                        resetSfarsBeingRestored = !SelectedTarget.ModifiedSFARFiles.Any(x => x.Restoring);
                    }
                    if (resetSfarsBeingRestored)
                    {
                        SFARBeingRestored = false;
                    }
                }
                else if (itemRestored == null)
                {
                    //restore failed.
                    bool resetSfarsBeingRestored = SelectedTarget.ModifiedSFARFiles.Count == 0;
                    if (!resetSfarsBeingRestored)
                    {
                        resetSfarsBeingRestored = !SelectedTarget.ModifiedSFARFiles.Any(x => x.Restoring);
                    }
                    if (resetSfarsBeingRestored)
                    {
                        SFARBeingRestored = false;
                    }
                    bool resetBasegameFilesBeingRestored = SelectedTarget.ModifiedBasegameFiles.Count == 0;
                    if (!resetBasegameFilesBeingRestored)
                    {
                        resetBasegameFilesBeingRestored = !SelectedTarget.ModifiedBasegameFiles.Any(x => x.Restoring);
                    }
                    if (resetBasegameFilesBeingRestored)
                    {
                        BasegameFilesBeingRestored = false;
                    }
                }
            }

            SelectedTarget.PopulateModifiedBasegameFiles(restoreBasegamefileConfirmationCallback,
                                                         restoreSfarConfirmationCallback,
                                                         notifyStartingSfarRestoreCallback,
                                                         notifyStartingBasegameFileRestoreCallback,
                                                         notifyRestoredCallback);
            SFARBeingRestored = false;
        }
Esempio n. 16
0
        // 「修理」コマンドを終了
        private void FinishFixCommand()
        {
            GUI.LockGUI();
            GUI.OpenMessageForm(SelectedTarget, SelectedUnit);

            var currentUnit = SelectedUnit;

            // 選択内容を変更
            Event.SelectedUnitForEvent   = SelectedUnit;
            Event.SelectedTargetForEvent = SelectedTarget;

            // 修理メッセージ&特殊効果
            if (currentUnit.IsMessageDefined("修理"))
            {
                currentUnit.PilotMessage("修理", msg_mode: "");
            }

            if (currentUnit.IsAnimationDefined("修理", currentUnit.FeatureName("修理装置")))
            {
                currentUnit.PlayAnimation("修理", currentUnit.FeatureName("修理装置"));
            }
            else
            {
                currentUnit.SpecialEffect("修理", currentUnit.FeatureName("修理装置"));
            }

            GUI.DisplaySysMessage(currentUnit.Nickname + "は" + SelectedTarget.Nickname + "に" + currentUnit.FeatureName("修理装置") + "を使った。");

            // 修理を実行
            var tmp = SelectedTarget.HP;

            switch (currentUnit.FeatureLevel("修理装置"))
            {
            case 1d:
            case -1:
            {
                SelectedTarget.RecoverHP(30d + 3d * SelectedUnit.MainPilot().SkillLevel("修理", ref_mode: ""));
                break;
            }

            case 2d:
            {
                SelectedTarget.RecoverHP(50d + 5d * SelectedUnit.MainPilot().SkillLevel("修理", ref_mode: ""));
                break;
            }

            case 3d:
            {
                SelectedTarget.RecoverHP(100d);
                break;
            }
            }

            if (Information.IsNumeric(GeneralLib.LIndex(currentUnit.FeatureData("修理装置"), 2)))
            {
                currentUnit.EN = currentUnit.EN - Conversions.ToInteger(GeneralLib.LIndex(currentUnit.FeatureData("修理装置"), 2));
            }

            GUI.DrawSysString(SelectedTarget.x, SelectedTarget.y, "+" + SrcFormatter.Format(SelectedTarget.HP - tmp));
            GUI.UpdateMessageForm(SelectedTarget, SelectedUnit);
            GUI.DisplaySysMessage(SelectedTarget.Nickname + "の" + Expression.Term("HP", SelectedTarget) + "が" + SrcFormatter.Format(SelectedTarget.HP - tmp) + "回復した。");

            // 経験値獲得
            currentUnit.GetExp(SelectedTarget, "修理", exp_mode: "");
            if (GUI.MessageWait < 10000)
            {
                GUI.Sleep(GUI.MessageWait);
            }

            GUI.CloseMessageForm();

            // 形態変化のチェック
            SelectedTarget.Update();
            SelectedTarget.CurrentForm().CheckAutoHyperMode();
            SelectedTarget.CurrentForm().CheckAutoNormalMode();

            // 行動終了
            WaitCommand();
        }
        private void PopulateUI()
        {
            bool deleteConfirmationCallback(InstalledDLCMod mod)
            {
                if (Utilities.IsGameRunning(SelectedTarget.Game))
                {
                    M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_interp_cannotDeleteModsWhileXIsRunning, Utilities.GetGameName(SelectedTarget.Game)), M3L.GetString(M3L.string_gameRunning), MessageBoxButton.OK, MessageBoxImage.Error);
                    return(false);
                }
                if (SelectedTarget.TextureModded)
                {
                    var res = M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_interp_deletingXwhileAlotInstalledUnsupported, mod.ModName), M3L.GetString(M3L.string_deletingWillPutAlotInUnsupportedConfig), MessageBoxButton.YesNo, MessageBoxImage.Error);
                    return(res == MessageBoxResult.Yes);
                }
                return(M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_interp_removeXFromTheGameInstallationQuestion, mod.ModName), M3L.GetString(M3L.string_confirmDeletion), MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes);
            }

            void notifyDeleted()
            {
                PopulateUI();
            }

            SelectedTarget.PopulateDLCMods(true, deleteConfirmationCallback, notifyDeleted);

            bool restoreBasegamefileConfirmationCallback(string filepath)
            {
                if (Utilities.IsGameRunning(SelectedTarget.Game))
                {
                    M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_interp_cannotRestoreFilesWhileXIsRunning, Utilities.GetGameName(SelectedTarget.Game)), M3L.GetString(M3L.string_gameRunning), MessageBoxButton.OK, MessageBoxImage.Error);
                    return(false);
                }
                if (SelectedTarget.TextureModded && filepath.RepresentsPackageFilePath())
                {
                    if (!Settings.DeveloperMode)
                    {
                        M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_interp_restoringXWhileAlotInstalledIsNotAllowed, Path.GetFileName(filepath)), M3L.GetString(M3L.string_cannotRestorePackageFiles), MessageBoxButton.OK, MessageBoxImage.Error);
                        return(false);
                    }
                    else
                    {
                        var res = M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_interp_restoringXwhileAlotInstalledLikelyBreaksThingsDevMode, Path.GetFileName(filepath)), M3L.GetString(M3L.string_invalidTexturePointersWarning), MessageBoxButton.YesNo, MessageBoxImage.Warning);
                        return(res == MessageBoxResult.Yes);
                    }
                }
                return(M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_interp_restoreXquestion, Path.GetFileName(filepath)), M3L.GetString(M3L.string_confirmRestoration), MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes);
            }

            bool restoreSfarConfirmationCallback(string sfarPath)
            {
                if (Utilities.IsGameRunning(SelectedTarget.Game))
                {
                    M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_interp_cannotRestoreFilesWhileXIsRunning, Utilities.GetGameName(SelectedTarget.Game)), M3L.GetString(M3L.string_gameRunning), MessageBoxButton.OK, MessageBoxImage.Error);
                    return(false);
                }

                if (SelectedTarget.TextureModded)
                {
                    if (!Settings.DeveloperMode)
                    {
                        M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_restoringSfarsAlotBlocked), M3L.GetString(M3L.string_cannotRestoreSfarFiles), MessageBoxButton.OK, MessageBoxImage.Error);
                        return(false);
                    }
                    else
                    {
                        var res = M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_restoringSfarsAlotDevMode), M3L.GetString(M3L.string_invalidTexturePointersWarning), MessageBoxButton.YesNo, MessageBoxImage.Warning);
                        return(res == MessageBoxResult.Yes);
                    }
                }
                //Todo: warn of unpacked file deletion
                return(M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_interp_restoreXquestion, sfarPath), M3L.GetString(M3L.string_confirmRestoration), MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes);
            }

            void notifyStartingSfarRestoreCallback()
            {
                SFARBeingRestored = true;
            }

            void notifyStartingBasegameFileRestoreCallback()
            {
                BasegameFilesBeingRestored = true;
            }

            void notifyRestoredCallback(object itemRestored)
            {
                if (itemRestored is GameTarget.ModifiedFileObject mf)
                {
                    Application.Current.Dispatcher.Invoke(delegate { SelectedTarget.ModifiedBasegameFiles.Remove(mf); });
                    bool resetBasegameFilesBeingRestored = SelectedTarget.ModifiedBasegameFiles.Count == 0;
                    if (!resetBasegameFilesBeingRestored)
                    {
                        resetBasegameFilesBeingRestored = !SelectedTarget.ModifiedBasegameFiles.Any(x => x.Restoring);
                    }
                    if (resetBasegameFilesBeingRestored)
                    {
                        BasegameFilesBeingRestored = false;
                    }
                }
                else if (itemRestored is GameTarget.SFARObject ms)
                {
                    if (!ms.IsModified)
                    {
                        SelectedTarget.ModifiedSFARFiles.Remove(ms);
                    }
                    bool resetSfarsBeingRestored = SelectedTarget.ModifiedSFARFiles.Count == 0;
                    if (!resetSfarsBeingRestored)
                    {
                        resetSfarsBeingRestored = !SelectedTarget.ModifiedSFARFiles.Any(x => x.Restoring);
                    }
                    if (resetSfarsBeingRestored)
                    {
                        SFARBeingRestored = false;
                    }
                }
                else if (itemRestored == null)
                {
                    //restore failed.
                    bool resetSfarsBeingRestored = SelectedTarget.ModifiedSFARFiles.Count == 0;
                    if (!resetSfarsBeingRestored)
                    {
                        resetSfarsBeingRestored = !SelectedTarget.ModifiedSFARFiles.Any(x => x.Restoring);
                    }
                    if (resetSfarsBeingRestored)
                    {
                        SFARBeingRestored = false;
                    }
                    bool resetBasegameFilesBeingRestored = SelectedTarget.ModifiedBasegameFiles.Count == 0;
                    if (!resetBasegameFilesBeingRestored)
                    {
                        resetBasegameFilesBeingRestored = !SelectedTarget.ModifiedBasegameFiles.Any(x => x.Restoring);
                    }
                    if (resetBasegameFilesBeingRestored)
                    {
                        BasegameFilesBeingRestored = false;
                    }
                }
            }

            SelectedTarget.PopulateModifiedBasegameFiles(restoreBasegamefileConfirmationCallback,
                                                         restoreSfarConfirmationCallback,
                                                         notifyStartingSfarRestoreCallback,
                                                         notifyStartingBasegameFileRestoreCallback,
                                                         notifyRestoredCallback);
            SFARBeingRestored = false;
        }
        private Composite CreateMainBehavior()
        {
            return(new PrioritySelector(

                       // If quest is done, behavior is done...
                       new Decorator(context => IsDone,
                                     new Action(context =>
            {
                _isBehaviorDone = true;
                QBCLog.Info("Finished");
            })),


                       // Stateful Operation:
                       new Switch <StateType_MainBehavior>(context => State_MainBehavior,
                                                           #region State: DEFAULT
                                                           new Action(context => // default case
            {
                QBCLog.MaintenanceError("StateType_MainBehavior({0}) is unhandled", State_MainBehavior);
                TreeRoot.Stop();
                _isBehaviorDone = true;
            }),
                                                           #endregion


                                                           #region State: Dropping Off Victim
                                                           new SwitchArgument <StateType_MainBehavior>(StateType_MainBehavior.DroppingOffVictim,
                                                                                                       new PrioritySelector(
                                                                                                           // If Watchman dropped off, go get another...
                                                                                                           new Decorator(context => !Me.HasAura(AuraId_RescueDrowningWatchman),
                                                                                                                         new Action(context =>
            {
                WoWMovement.MoveStop();
                _currentPath = null;
                SelectedTarget = null;
                State_MainBehavior = StateType_MainBehavior.PathingOutToVictim;
            })),

                                                                                                           // Move to drop off spot...
                                                                                                           new Decorator(context => Me.Location.Distance(PositionToMakeLandfall) > Navigator.PathPrecision,
                                                                                                                         new ActionRunCoroutine(
                                                                                                                             context => UtilityCoroutine.MoveTo(
                                                                                                                                 PositionToMakeLandfall,
                                                                                                                                 "back to shore")))
                                                                                                           )),
                                                           #endregion


                                                           #region State: Pathing Out to Victim
                                                           new SwitchArgument <StateType_MainBehavior>(StateType_MainBehavior.PathingOutToVictim,
                                                                                                       new PrioritySelector(
                                                                                                           // If our selected target is no good, find another...
                                                                                                           new Decorator(context => !IsViableDrowningWatchman(SelectedTarget),
                                                                                                                         new Action(context =>
            {
                QBCLog.Info("Finding new Drowning Watchman to save");
                _currentPath = null;
                SelectedTarget = FindDrowningWatchman();
            })),

                                                                                                           // Show user which target we're after...
                                                                                                           new Decorator(context => Me.CurrentTarget != SelectedTarget,
                                                                                                                         new Action(context => { SelectedTarget.Target(); })),

                                                                                                           // If we don't have a path to victim, find one...
                                                                                                           new Decorator(context => _currentPath == null,
                                                                                                                         new Action(context => { _currentPath = FindPath(Me.Location, SelectedTarget.Location); })),

                                                                                                           // If path completely consumed, we're done...
                                                                                                           new Decorator(context => _currentPath.Count() <= 0,
                                                                                                                         new Action(context => { State_MainBehavior = StateType_MainBehavior.Rescuing; })),

                                                                                                           // If we've arrived at the current waypoint, dequeue it...
                                                                                                           new Decorator(context => Navigator.AtLocation(_currentPath.Peek()),
                                                                                                                         new Action(context => { _currentPath.Dequeue(); })),

                                                                                                           // Follow the prescribed path...
                                                                                                           new ActionRunCoroutine(
                                                                                                               context => UtilityCoroutine.MoveTo(
                                                                                                                   _currentPath.Peek(),
                                                                                                                   "out to Drowned Watcman"))
                                                                                                           )),
                                                           #endregion


                                                           #region State: Rescuing
                                                           new SwitchArgument <StateType_MainBehavior>(StateType_MainBehavior.Rescuing,
                                                                                                       new PrioritySelector(
                                                                                                           // If we've got the Watchman, start heading in...
                                                                                                           new Decorator(context => Me.HasAura(AuraId_RescueDrowningWatchman),
                                                                                                                         new Action(context =>
            {
                _currentPath = null;
                State_MainBehavior = StateType_MainBehavior.PathingIntoShore;
            })),

                                                                                                           // If our selected target is no good, find another...
                                                                                                           new Decorator(context => !IsViableDrowningWatchman(SelectedTarget),
                                                                                                                         new Action(context =>
            {
                _currentPath = null;
                SelectedTarget = null;
                State_MainBehavior = StateType_MainBehavior.PathingOutToVictim;
            })),

                                                                                                           // Go get a fresh Drowning Watchman...
                                                                                                           UtilityBehavior_InteractWithMob(context => SelectedTarget)
                                                                                                           )),
                                                           #endregion


                                                           #region State: Pathing Into Shore
                                                           new SwitchArgument <StateType_MainBehavior>(StateType_MainBehavior.PathingIntoShore,
                                                                                                       new PrioritySelector(
                                                                                                           // If we don't have a path, find the correct one...
                                                                                                           new Decorator(context => _currentPath == null,
                                                                                                                         new Action(context => { _currentPath = FindPath(Me.Location, PositionToMakeLandfall); })),

                                                                                                           // If path completely consumed, we're done...
                                                                                                           new Decorator(context => _currentPath.Count() <= 0,
                                                                                                                         new Action(context => { State_MainBehavior = StateType_MainBehavior.DroppingOffVictim; })),

                                                                                                           // If we've lost the Watchman we rescued, go fetch another...
                                                                                                           new Decorator(context => !Me.HasAura(AuraId_RescueDrowningWatchman),
                                                                                                                         new Action(context =>
            {
                _currentPath = null;
                SelectedTarget = null;
                State_MainBehavior = StateType_MainBehavior.PathingOutToVictim;
            })),

                                                                                                           // If we've arrived at the current waypoint, dequeue it...
                                                                                                           new Decorator(context => Navigator.AtLocation(_currentPath.Peek()),
                                                                                                                         new Action(context => { _currentPath.Dequeue(); })),

                                                                                                           // Follow the prescribed path...
                                                                                                           new ActionRunCoroutine(
                                                                                                               context => UtilityCoroutine.MoveTo(
                                                                                                                   _currentPath.Peek(),
                                                                                                                   "in to drop off Drowned Watchman"))
                                                                                                           ))
                                                           #endregion
                                                           )));
        }
 private bool CanRestoreSPSFARs()
 {
     return(IsPanelOpen && !Utilities.IsGameRunning(SelectedTarget.Game) && SelectedTarget.HasModifiedSPSFAR() && !SFARBeingRestored);
 }
Esempio n. 20
0
        // 「待機」コマンド
        // 他のコマンドの終了処理にも使われる
        private void WaitCommand(bool WithoutAction = false)
        {
            LogDebug();

            // コマンド終了時はターゲットを解除
            SelectedTarget = null;

            // ユニットにパイロットが乗っていない?
            if (SelectedUnit.CountPilot() == 0)
            {
                CommandState = "ユニット選択";
                GUI.RedrawScreen();
                Status.ClearUnitStatus();
                return;
            }

            if (!WithoutAction)
            {
                // 残り行動数を減少させる
                SelectedUnit.UseAction();

                // 持続期間が「移動」のスペシャルパワー効果を削除
                if (Strings.InStr(CommandState, "移動後") > 0)
                {
                    SelectedUnit.RemoveSpecialPowerInEffect("移動");
                }
            }

            CommandState = "ユニット選択";

            // アップデート
            SelectedUnit.Update();
            SRC.PList.UpdateSupportMod(SelectedUnit);

            // ユニットが既に出撃していない?
            if (SelectedUnit.Status != "出撃")
            {
                GUI.RedrawScreen();
                Status.ClearUnitStatus();
                return;
            }

            GUI.LockGUI();
            GUI.RedrawScreen();
            var p = SelectedUnit.Pilots.First();

            // 接触イベント
            foreach (var unit in Map.AdjacentUnit(SelectedUnit))
            {
                SelectedTarget = unit;
                Event.HandleEvent("接触", SelectedUnit.MainPilot().ID, SelectedTarget.MainPilot().ID);
                SelectedTarget = null;
                if (SRC.IsScenarioFinished)
                {
                    SRC.IsScenarioFinished = false;
                    return;
                }

                if (SelectedUnit.Status != "出撃")
                {
                    GUI.RedrawScreen();
                    Status.ClearUnitStatus();
                    GUI.UnlockGUI();
                    return;
                }
            }

            // 進入イベント
            Event.HandleEvent("進入", SelectedUnit.MainPilot().ID, "" + SelectedUnit.x, "" + SelectedUnit.y);
            if (SRC.IsScenarioFinished)
            {
                SRC.IsScenarioFinished = false;
                return;
            }

            if (SelectedUnit.CountPilot() == 0)
            {
                GUI.RedrawScreen();
                Status.ClearUnitStatus();
                GUI.UnlockGUI();
                return;
            }

            // 行動終了イベント
            Event.HandleEvent("行動終了", SelectedUnit.MainPilot().ID);
            if (SRC.IsScenarioFinished)
            {
                SRC.IsScenarioFinished = false;
                return;
            }

            if (SelectedUnit.CountPilot() == 0)
            {
                GUI.RedrawScreen();
                Status.ClearUnitStatus();
                GUI.UnlockGUI();
                return;
            }

            if (p.Unit is object)
            {
                SelectedUnit = p.Unit;
            }

            if (SelectedUnit.Action > 0 && SelectedUnit.CountPilot() > 0)
            {
                // カーソル自動移動
                if (SRC.AutoMoveCursor)
                {
                    GUI.MoveCursorPos("ユニット選択", SelectedUnit);
                }
            }

            // ハイパーモード・ノーマルモードの自動発動をチェック
            SelectedUnit.CurrentForm().CheckAutoHyperMode();
            SelectedUnit.CurrentForm().CheckAutoNormalMode();
            if (GUI.IsPictureVisible || GUI.IsCursorVisible)
            {
                GUI.RedrawScreen();
            }

            GUI.UnlockGUI();

            //// ステータスウィンドウの表示内容を更新
            //if (SelectedUnit.Status == "出撃" && GUI.MainWidth == 15)
            //{
            //    Status.DisplayUnitStatus(SelectedUnit);
            //}
            //else
            //{
            //    Status.ClearUnitStatus();
            //}
        }