private IEnumerator AssignKey(object keyName) { waitingForKey = true; yield return(WaitForKey()); int isFirst = 0; int keyCount = 0; for (int i = 0; i < hotkeyButtons.Count; i++) { if (hotkeyButtons[i].Equals(newKey)) { if (keyCount == 0) { isFirst = i; } keyCount++; } } if (keyCount > 0 && isFirst != selected) { BZLogger.Warn("Duplicate keybind found, swapping keys..."); hotkeyButtons[isFirst] = hotkeyButtons[selected]; guiItem_Buttons[isFirst].Name = hotkeyButtons[selected]; } hotkeyButtons[selected] = newKey; guiItem_Buttons[selected].Name = hotkeyButtons[selected]; selected = -1; yield return(null); }
internal static void Config_Load() { BZLogger.Debug("Method call: SEzConfig.Config_Load()"); PROGRAM_VERSION = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; if (!Config_Check()) { Config_CreateDefault(); } try { Hotkeys_Config = ParserHelper.GetAllKeyValuesFromSection(FILENAME, "Hotkeys", SECTION_HOTKEYS); int.TryParse(ParserHelper.GetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[0]), out int result); MAXSLOTS = result < 5 || result > 12 ? 12 : result; EXTRASLOTS = MAXSLOTS - 4; TEXTCOLOR = ColorHelper.GetColor(ParserHelper.GetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[1])); SLOT_LAYOUT = ParserHelper.GetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[2]) == "Circle" ? SlotLayout.Circle : SlotLayout.Grid; isSeatruckArmsExists = BZCommon.ReflectionHelper.IsNamespaceExists("SeaTruckArms"); isSeatruckScannerModuleExists = BZCommon.ReflectionHelper.IsNamespaceExists("SeaTruckScannerModule"); BZLogger.Log("Configuration loaded."); } catch { BZLogger.Error("An error occurred while loading the configuration file!"); } }
public void Awake() { Instance = this; ALLSLOTS_Text.Clear(); uGUI_Equipment uGUIequipment = gameObject.GetComponent <uGUI_Equipment>(); Dictionary <string, uGUI_EquipmentSlot> ALLSLOTS = (Dictionary <string, uGUI_EquipmentSlot>)uGUIequipment.GetPrivateField("allSlots"); BZLogger.Debug("uGUI_SlotTextHandler processing ALLSLOTS..."); foreach (KeyValuePair <string, uGUI_EquipmentSlot> item in ALLSLOTS) { BZLogger.Debug($"slot name: {item.Key}"); if (SlotHelper.ALLSLOTS.TryGetValue(item.Key, out SlotData slotData)) { TextMeshProUGUI TMProText = AddTextToSlot(item.Value.transform, slotData); ALLSLOTS_Text.Add(slotData.SlotID, TMProText); } } BZLogger.Log("uGUI_SlotTextHandler added."); }
internal static void SetKeyBindings() { KEYBINDINGS = new Dictionary <string, KeyCode>(); bool sync = false; foreach (KeyValuePair <string, string> kvp in Section_hotkeys) { try { KeyCode keyCode = (KeyCode)Enum.Parse(typeof(KeyCode), kvp.Value); KEYBINDINGS.Add(kvp.Key, keyCode); } catch (ArgumentException) { BZLogger.Warn(PROGRAM_NAME, $"({kvp.Value}) is not a valid KeyCode! Setting default value!"); for (int i = 0; i < DEFAULT_CONFIG.Count; i++) { if (DEFAULT_CONFIG[i].Key.Equals(kvp.Key)) { KEYBINDINGS.Add(kvp.Key, (KeyCode)Enum.Parse(typeof(KeyCode), DEFAULT_CONFIG[i].Value, true)); sync = true; } } } } if (sync) { SyncConfig(); } }
private void OnDestroy() { BZLogger.Debug("WaterRideManager", "Removing unused handlers..."); modules.onEquip -= OnEquip; modules.onUnequip -= OnUnEquip; }
internal static void SLOTKEYBINDINGS_Update() { BZLogger.Debug("Method call: SEzConfig.SLOTKEYBINDINGS_Update()"); SLOTKEYBINDINGS.Clear(); SLOTKEYSLIST.Clear(); SLOTKEYBINDINGS.Add(SlotConfigID.Slot_1, GameInput.GetBindingName(GameInput.Button.Slot1, GameInput.BindingSet.Primary)); SLOTKEYBINDINGS.Add(SlotConfigID.Slot_2, GameInput.GetBindingName(GameInput.Button.Slot2, GameInput.BindingSet.Primary)); SLOTKEYBINDINGS.Add(SlotConfigID.Slot_3, GameInput.GetBindingName(GameInput.Button.Slot3, GameInput.BindingSet.Primary)); SLOTKEYBINDINGS.Add(SlotConfigID.Slot_4, GameInput.GetBindingName(GameInput.Button.Slot4, GameInput.BindingSet.Primary)); SLOTKEYBINDINGS.Add(SlotConfigID.Slot_5, GameInput.GetBindingName(GameInput.Button.Slot5, GameInput.BindingSet.Primary)); SLOTKEYBINDINGS.Add(SlotConfigID.Slot_6, Hotkeys_Config[SlotConfigID.Slot_6.ToString()]); SLOTKEYBINDINGS.Add(SlotConfigID.Slot_7, Hotkeys_Config[SlotConfigID.Slot_7.ToString()]); SLOTKEYBINDINGS.Add(SlotConfigID.Slot_8, Hotkeys_Config[SlotConfigID.Slot_8.ToString()]); SLOTKEYBINDINGS.Add(SlotConfigID.Slot_9, Hotkeys_Config[SlotConfigID.Slot_9.ToString()]); SLOTKEYBINDINGS.Add(SlotConfigID.Slot_10, Hotkeys_Config[SlotConfigID.Slot_10.ToString()]); SLOTKEYBINDINGS.Add(SlotConfigID.Slot_11, Hotkeys_Config[SlotConfigID.Slot_11.ToString()]); SLOTKEYBINDINGS.Add(SlotConfigID.Slot_12, Hotkeys_Config[SlotConfigID.Slot_12.ToString()]); SLOTKEYBINDINGS.Add(SlotConfigID.SeaTruckArmLeft, Hotkeys_Config[SlotConfigID.SeaTruckArmLeft.ToString()]); SLOTKEYBINDINGS.Add(SlotConfigID.SeaTruckArmRight, Hotkeys_Config[SlotConfigID.SeaTruckArmRight.ToString()]); foreach (KeyValuePair <SlotConfigID, string> kvp in SLOTKEYBINDINGS) { SLOTKEYSLIST.Add(kvp.Value); } }
private static bool Config_Check() { BZLogger.Debug("Method call: SEzConfig.Config_Check()"); if (!File.Exists(FILENAME)) { BZLogger.Error("Configuration file open error!"); return(false); } CONFIG_VERSION = ParserHelper.GetKeyValue(FILENAME, "SlotExtenderZero", "Version"); if (!CONFIG_VERSION.Equals(PROGRAM_VERSION)) { BZLogger.Error("Configuration file version error!"); return(false); } if (!ParserHelper.IsSectionKeysExists(FILENAME, "Hotkeys", SECTION_HOTKEYS)) { BZLogger.Error("Configuration file [Hotkeys] section error!"); return(false); } if (!ParserHelper.IsSectionKeysExists(FILENAME, "Settings", SECTION_SETTINGS)) { BZLogger.Error("Configuration file [Settings] section error!"); return(false); } return(true); }
private static void GameInput_OnBindingsChanged() { BZLogger.Debug("Method call: Main.GameInput_OnBindingsChanged()"); // SlotExtender Update() method now disabled until all keybinding updates are complete isKeyBindigsUpdate = true; // updating slot key bindings SEzConfig.SLOTKEYBINDINGS_Update(); // synchronizing keybindings to config file SEzConfig.SLOTKEYBINDINGS_SyncToAll(); // updating ALLSLOTS dictionary SlotHelper.ALLSLOTS_Update(); // updating SlotTextHandler if (uGUI_SlotTextHandler.Instance != null) { uGUI_SlotTextHandler.Instance.UpdateSlotText(); } // SlotExtender Update() method now enabled isKeyBindigsUpdate = false; }
internal static void KEYBINDINGS_Set() { BZLogger.Debug("Method call: SEConfig.KEYBINDINGS_Set()"); KEYBINDINGS = new Dictionary <string, KeyCode>(); bool sync = false; foreach (KeyValuePair <string, string> kvp in Hotkeys_Config) { try { KEYBINDINGS.Add(kvp.Key, InputHelper.StringToKeyCode(kvp.Value)); } catch (ArgumentException) { BZLogger.Warn($"[{kvp.Value}] is not a valid KeyCode! Setting default value!"); for (int i = 0; i < DEFAULT_CONFIG.Count; i++) { if (DEFAULT_CONFIG[i].Key.Equals(kvp.Key)) { KEYBINDINGS.Add(kvp.Key, InputHelper.StringToKeyCode(DEFAULT_CONFIG[i].Value)); sync = true; } } } } if (sync) { KEYBINDINGS_ToConfig(); } }
private void OnDestroy() { BZLogger.Debug("Removing unused handlers..."); helper.onUpgradeModuleEquip -= OnUpgradeModuleChanged; helper.onUpgradeModuleUnEquip -= OnUpgradeModuleChanged; }
protected internal SeaTruckArms_Graphics() { GraphicsRoot = new GameObject("SeaTruckArmsRoot"); BZLogger.Log($"API message: Graphics root GameObject created: {GraphicsRoot.name}, ID: {GraphicsRoot.GetInstanceID()}"); //SceneManager.MoveGameObjectToScene(GraphicsRoot, SceneManager.GetSceneByName("StartScreen")); GraphicsRoot.AddComponent <Indestructible>(); CoroutineHost.StartCoroutine(LoadPipeResourcesAsync()); CoroutineHost.StartCoroutine(LoadExosuitResourcesAsync()); RegisterBaseArms(); RegisterBaseArmHandlers(); InitializeTextures(); CoroutineHost.StartCoroutine(InitializeArmSocketGraphics()); CoroutineHost.StartCoroutine(InitializeArmsGraphics()); GraphicsRoot.AddComponent <ArmRegistrationListener>(); }
private IEnumerator AssignKey(object keyName) { waitingForKey = true; yield return(WaitForKey()); int isFirst = 0; int keyCount = 0; for (int i = 0; i < HotkeyButtons.Count; i++) { if (HotkeyButtons[i].Equals(newKey.ToString())) { if (keyCount == 0) { isFirst = i; } keyCount++; } } if (keyCount > 0 && isFirst != selected) { BZLogger.Log($"[{CmZConfig.PROGRAM_NAME}] Error! Duplicate keybind found, swapping keys..."); HotkeyButtons[isFirst] = HotkeyButtons[selected]; buttonInfo[isFirst].Name = HotkeyButtons[selected]; } HotkeyButtons[selected] = newKey.ToString(); buttonInfo[selected].Name = HotkeyButtons[selected]; selected = -1; yield return(null); }
public static void Load() { //load and init config from file QSEzConfig.LoadConfig(); isExists_SlotExtenderZero = ReflectionHelper.IsNamespaceExists("SlotExtenderZero"); if (isExists_SlotExtenderZero) { BZLogger.Log("SlotExtenderZero found! trying to work together.."); } try { Assembly assembly = Assembly.GetExecutingAssembly(); Harmony.CreateAndPatchAll(assembly, $"BelowZero.{assembly.GetName().Name}.mod"); BZLogger.Log("Harmony Patches installed"); SceneManager.sceneLoaded += new UnityAction <Scene, LoadSceneMode>(OnSceneLoaded); //CoroutineHost.StartCoroutine(WaitForUGUI()); IngameMenuHandler.Main.RegisterOnQuitEvent(OnQuitEvent); } catch (Exception ex) { Debug.LogException(ex); } }
internal static void InitSLOTKEYS() { SLOTKEYS.Clear(); SLOTKEYSLIST.Clear(); SLOTKEYS.Add("Slot1", GameInput.GetBindingName(GameInput.Button.Slot1, GameInput.BindingSet.Primary)); SLOTKEYS.Add("Slot2", GameInput.GetBindingName(GameInput.Button.Slot2, GameInput.BindingSet.Primary)); SLOTKEYS.Add("Slot3", GameInput.GetBindingName(GameInput.Button.Slot3, GameInput.BindingSet.Primary)); SLOTKEYS.Add("Slot4", GameInput.GetBindingName(GameInput.Button.Slot4, GameInput.BindingSet.Primary)); SLOTKEYS.Add("Slot5", GameInput.GetBindingName(GameInput.Button.Slot5, GameInput.BindingSet.Primary)); SLOTKEYS.Add("Slot6", InputHelper.KeyCodeToString(KEYBINDINGS[SECTION_Hotkeys[0]])); SLOTKEYS.Add("Slot7", InputHelper.KeyCodeToString(KEYBINDINGS[SECTION_Hotkeys[1]])); SLOTKEYS.Add("Slot8", InputHelper.KeyCodeToString(KEYBINDINGS[SECTION_Hotkeys[2]])); SLOTKEYS.Add("Slot9", InputHelper.KeyCodeToString(KEYBINDINGS[SECTION_Hotkeys[3]])); SLOTKEYS.Add("Slot10", InputHelper.KeyCodeToString(KEYBINDINGS[SECTION_Hotkeys[4]])); SLOTKEYS.Add("Slot11", InputHelper.KeyCodeToString(KEYBINDINGS[SECTION_Hotkeys[5]])); SLOTKEYS.Add("Slot12", InputHelper.KeyCodeToString(KEYBINDINGS[SECTION_Hotkeys[6]])); foreach (KeyValuePair <string, string> kvp in SLOTKEYS) { BZLogger.Debug($"Adding slotkey [{kvp.Value}] to slot [{kvp.Key}]"); SLOTKEYSLIST.Add(kvp.Value); } }
internal static void LoadConfig() { PROGRAM_VERSION = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; if (!CheckConfig()) { CreateDefaultConfigFile(); } try { Section_hotkeys = ParserHelper.GetAllKeyValuesFromSection(FILENAME, SECTIONS[0], SECTION_Hotkeys); int.TryParse(ParserHelper.GetKeyValue(FILENAME, SECTIONS[1], SECTION_Settings[0]), out int result); MAXSLOTS = result < 5 || result > 12 ? 12 : result; TEXTCOLOR = ColorHelper.GetColor(ParserHelper.GetKeyValue(FILENAME, SECTIONS[1], SECTION_Settings[1])); BZLogger.Log("Configuration loaded."); } catch { BZLogger.Error("An error occurred while loading the configuration file!"); } }
internal static void SetKeyBindings() { KEYBINDINGS = new Dictionary <string, KeyCode>(); bool sync = false; foreach (KeyValuePair <string, string> kvp in Section_hotkeys) { try { KEYBINDINGS.Add(kvp.Key, InputHelper.StringToKeyCode(kvp.Value)); } catch (ArgumentException) { BZLogger.Warn($"({kvp.Value}) is not a valid KeyCode! Setting default value!"); for (int i = 0; i < DEFAULT_CONFIG.Count; i++) { if (DEFAULT_CONFIG[i].Key.Equals(kvp.Key)) { KEYBINDINGS.Add(kvp.Key, InputHelper.StringToKeyCode(DEFAULT_CONFIG[i].Value)); sync = true; } } } } if (sync) { SyncConfig(); } }
private static bool CheckConfig() { if (!File.Exists(FILENAME)) { BZLogger.Error("Configuration file open error!"); return(false); } CONFIG_VERSION = ParserHelper.GetKeyValue(FILENAME, "QuickSlotExtenderZero", "Version"); if (!CONFIG_VERSION.Equals(PROGRAM_VERSION)) { BZLogger.Error("Configuration file version error!"); return(false); } if (!ParserHelper.IsSectionKeysExists(FILENAME, SECTIONS[0], SECTION_Hotkeys)) { BZLogger.Error($"Configuration {SECTIONS[0]} section error!"); return(false); } if (!ParserHelper.IsSectionKeysExists(FILENAME, SECTIONS[1], SECTION_Settings)) { BZLogger.Error($"Configuration {SECTIONS[1]} section error!"); return(false); } return(true); }
internal static void LoadConfig() { PROGRAM_VERSION = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; if (!File.Exists(FILENAME)) { CreateDefaultConfigFile(); } else { CONFIG_VERSION = ParserHelper.GetKeyValue(FILENAME, PROGRAM_NAME, "Version"); if (CONFIG_VERSION.Equals(PROGRAM_VERSION)) { BZLogger.Log("Configuration file version match with program version."); } else { CreateDefaultConfigFile(); } } Section_hotkeys = ParserHelper.GetAllKeyValuesFromSection(FILENAME, SECTIONS[1], SECTION_HOTKEYS); string autostart = ParserHelper.GetKeyValue(FILENAME, SECTIONS[0], SECTION_SETTINGS[0]); if (!bool.TryParse(autostart, out AUTOSTART)) { AUTOSTART = false; } BZLogger.Log("Configuration loaded."); }
public static void DebugComponent(Component component) { List<string> keywords = new List<string>(); BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreReturn; keywords.Add("Properties:"); foreach (PropertyInfo propertyInfo in component.GetType().GetProperties(bindingFlags)) { keywords.Add($"{propertyInfo.Name} [{propertyInfo.GetValue(component, bindingFlags, null, null, null).ToString()}]"); } keywords.Add("Fields:"); foreach (FieldInfo fieldInfo in component.GetType().GetFields(bindingFlags)) { keywords.Add($"{fieldInfo.Name} [{fieldInfo.GetValue(component).ToString()}]"); } foreach (string key in keywords) { BZLogger.Log($"{key}"); } }
private void Start() { //get player instance PlayerMain = Player.main; PdaMain = PlayerMain.GetPDA(); //forced triggering the Awake method in uGUI_Equipment for patching PdaMain.Open(); PdaMain.Close(); //add and start a handler to check the player mode if changed PlayerMain.playerModeChanged.AddHandler(gameObject, new Event <Player.Mode> .HandleFunction(OnPlayerModeChanged)); string vehicleName = string.Empty; if (ThisVehicle) { isActive = (PlayerMain.GetVehicle() == ThisVehicle); vehicleName = ThisVehicle.vehicleName; } else if (helper.isReady) { isActive = (PlayerMain.GetComponentInParent <SeaTruckUpgrades>() == helper.TruckUpgrades); vehicleName = helper.TruckName; } BZLogger.Log($"Broadcasting message: 'WakeUp', Name: {vehicleName}, Instance ID: {gameObject.GetInstanceID()}"); gameObject.BroadcastMessage("WakeUp"); }
/// <summary> /// INTERNAL ARM SPAWNING METHOD, DON'T OVERRIDE! Use ModifyGameObject() instead! /// Initializes the visual appearance of the arm in the open world or in the inventory. /// </summary> public override IEnumerator GetGameObjectAsync(IOut <GameObject> gameObject) { CoroutineTask <GameObject> request = CraftData.GetPrefabForTechTypeAsync(PrefabForClone); yield return(request); GameObject result = request.GetResult(); if (result == null) { BZLogger.Warn("API message: Cannot instantiate prefab from TechType!"); yield break; } PrefabClone = Object.Instantiate(result); PrefabClone.name = TechTypeName; if (ArmTemplate == ArmTemplate.ClawArm) { OverrideClawArm(); } PrefabClone.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f); PostModify(); gameObject.Set(PrefabClone); yield break; }
public void ConsumePower(float amount) { if (GameModeUtils.RequiresPower()) { float totalPower = TotalCanProvide(out int sourceCount); if (sourceCount > 0) { amount = (amount > totalPower) ? totalPower : amount; amount = amount / sourceCount; BZLogger.Debug($"consume power: amount: {amount}, sources: {sourceCount}"); foreach (KeyValuePair <string, IBattery> kvp in batteries) { if (kvp.Value != null && kvp.Value.charge > 0f) { kvp.Value.charge += -Mathf.Min(amount, kvp.Value.charge); if (slots.TryGetValue(kvp.Key, out SlotDefinition definition)) { UpdateVisuals(definition, kvp.Value.charge / kvp.Value.capacity, equipment.GetItemInSlot(kvp.Key).item.GetTechType()); } } } } } }
internal static void Postfix(Inventory __instance) { __instance.equipment.AddSlots(SlotHelper.NewChipSlotIDs); BZLogger.Log("Inventory Chip Slots Patched."); Main.ChipSlotsPatched = true; }
private void ClearEquipment() { foreach (Battery battery in EquipmentRoot.GetComponentsInChildren <Battery>(true)) { BZLogger.Warn($"Removing unassigned Battery: {battery.GetComponent<PrefabIdentifier>().Id}"); DestroyImmediate(battery.gameObject); } }
public CoroutineTask <GameObject> SpawnFragmentAsync(Transform parent, Vector3 position, Quaternion rotation, bool awake) { BZLogger.Debug($"SpawnFragmentAsync called for: {TechTypeName}"); TaskResult <GameObject> taskResult = new TaskResult <GameObject>(); return(new CoroutineTask <GameObject>(InstantiateFragmentAsync(taskResult, parent, position, rotation, awake), taskResult)); }
private void OnDestroy() { BZLogger.Debug("Removing unused handlers..."); helper.TruckEquipment.isAllowedToRemove -= IsAllowedToRemove; helper.TruckEquipment.onEquip -= OnEquip; helper.TruckEquipment.onUnequip -= OnUnequip; }
public void Awake() { helper = SeatruckServices.Main.GetSeaTruckHelper(gameObject); BZLogger.Debug("Adding slot listener handlers..."); helper.onUpgradeModuleEquip += OnUpgradeModuleChanged; helper.onUpgradeModuleUnEquip += OnUpgradeModuleChanged; }
public void Awake() { hoverbike = GetComponent <Hoverbike>(); modules = hoverbike.modules; BZLogger.Debug("WaterRideManager", "Adding slot listener handlers..."); modules.onEquip += OnEquip; modules.onUnequip += OnUnEquip; }
internal static void Config_Write() { BZLogger.Debug("Method call: SEzConfig.WriteConfig()"); ParserHelper.SetAllKeyValuesInSection(FILENAME, "Hotkeys", Hotkeys_Config); ParserHelper.SetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[0], MAXSLOTS.ToString()); ParserHelper.SetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[1], ColorHelper.GetColorName(TEXTCOLOR)); ParserHelper.SetKeyValue(FILENAME, "Settings", SECTION_SETTINGS[2], SLOT_LAYOUT.ToString()); BZLogger.Log("Configuration saved."); }
internal static void KEYBINDINGS_ToConfig() { BZLogger.Debug("Method call: SEConfig.KEYBINDINGS_ToConfig()"); foreach (string key in SECTION_HOTKEYS) { Hotkeys_Config[key] = InputHelper.KeyCodeToString(KEYBINDINGS[key]); } Config_Write(); }