private void Start() { var UIController = GroupSettingSceneUIController.Instance; StartButton = UIController.MainMenu.AddCell(); DoneButton = UIController.MainMenu.AddCell(); ResetButton = UIController.MainMenu.AddCell(); LoadButton = UIController.MainMenu.AddCell(); StartButton.Text.text = "Press to Start"; LoadButton.Text.text = "Load Saved Formation"; StartButton.Button.onClick.AddListener(OnStartPressed); DoneButton.Button.onClick.AddListener(OnDonePressed); ResetButton.Button.onClick.AddListener(OnResetPressed); LoadButton.Button.onClick.AddListener(OnLoadPressed); SaveDataController.TryLoad(DataName.SavedFormation, out List <List <PosVector> > Data); SavedFormation.Update(Data); SavedFormationList = SavedFormation.SavedList; for (int i = 0; i < SavedFormation.AllowedCount; i++) { var button = UIController.TopRightMenu.AddCell(); int ID = i; button.Button.onClick.AddListener(delegate { OnSlotPressed(ID); }); SavedFormationButtons.Add(button); } }
public static void Update(List <List <PosVector> > loadedData) { DidInit = true; SavedList = new List <SavedFormation>(); if (loadedData == null) { loadedData = new List <List <PosVector> >(); } for (int i = 0; i < AllowedCount; i++) { SavedFormation formation = new SavedFormation() { ID = i, Name = "Formation " + i.ToString(), Used = i < loadedData.Count, Posistions = i < loadedData.Count ? loadedData[i] : new List <PosVector>() }; SavedList.Add(formation); } }
static bool Prefix(PartyVM __instance, SelectorVM <SelectorItemVM> s) { try { if (!__instance.CurrentCharacter.IsPrisoner && s.SelectedIndex != (int)__instance.CurrentCharacter.Character.CurrentFormationClass) { var newFormation = (FormationClass)s.SelectedIndex; var name = __instance.CurrentCharacter.Character.Name.ToString(); var savedFormation = new SavedFormation() { TroopName = name, Formation = newFormation }; PartyManagerSettings.Settings.SavedFormations[name] = savedFormation; PartyManagerSettings.Settings.SaveSettings(); GenericHelpers.LogDebug("PartyVMUpdateCurrentCharacterFormationPatch", $"{name}:{newFormation}"); } } catch (Exception e) { GenericHelpers.LogException("PartyVMUpdateCurrentCharacterFormationPatch", e); } return(true); }