/// <summary> /// 拷貝整個髮飾品資料 /// </summary> /// <param name="sourceCtrl">來源ChaControl</param> /// <param name="targetCtrl">目標ChaControl</param> /// <returns>拷貝成功</returns> public static bool CopyAllHairAcc(ChaControl sourceCtrl, ChaControl targetCtrl) { if (sourceCtrl == null || targetCtrl == null) { Logger.LogError($"CopyAllHairAcc input not correct!"); return(false); } if (null != GetDataFromExtData(sourceCtrl, out Dictionary <int, object> dict) && null != dict) { for (int i = 0; i < dict.Count; i++) { dict[dict.Keys.ElementAt(i)] = CopyHairAccInfoObject(dict.Values.ElementAt(i)); //dict[dict.Keys.ElementAt(i)] = (dict.Values.ElementAt(i)); } SetToExtData(targetCtrl, dict); targetCtrl.ChangeAccessory(true); Logger.LogDebug($"Copy all HairAcc ({dict.Count}): {sourceCtrl.fileParam.fullname} -> {targetCtrl.fileParam.fullname} "); return(true); } else { Logger.LogDebug($"CopyAllHairAcc input not found!"); return(false); } }
internal void Awake() { this.FPSBoost(); try { if (FindObjectsOfType <ModEntryPoint>().Length > 1) { Logger.LogWarning(string.Format("Another instance of {0} was instantiated. Will destroy this: {1}", typeof(ModEntryPoint), gameObject.GetInstanceID() )); DestroyImmediate(this); } else { new Harmony(MOD_GUID).PatchAll(System.Reflection.Assembly.GetExecutingAssembly()); Logger.LogInfo("Successfully patched via Harmony."); } } catch (Exception arg) { Logger.LogError(string.Format("Failed to patch via Harmony. Error: {0}", arg)); } }
private void Awake() { _logger = Logger; using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TinkersSatchel.tinkerssatchel_assets")) { resources = AssetBundle.LoadFromStream(stream); } try { UnstubShaders(); } catch (Exception ex) { _logger.LogError($"Shader unstub failed: {ex} {ex.Message}"); } cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true); var modInfo = new T2Module.ModInfo { displayName = "Tinker's Satchel", longIdentifier = "TinkersSatchel", shortIdentifier = "TKSAT", mainConfigFile = cfgFile }; allModules = T2Module.InitAll <T2Module>(modInfo); var earlyLoad = new[] { CommonCode.instance }; T2Module.SetupAll_PluginAwake(earlyLoad); T2Module.SetupAll_PluginAwake(allModules.Except(earlyLoad)); }
public override void Load() { try { Logger = Log; GameOptionsData.RecommendedImpostors = GameOptionsData.MaxImpostors = Enumerable.Repeat <int>(255, 255).ToArray <int>(); Logger.LogMessage("Patching harmony..."); Logger.LogInfo("Succesfully loaded CorsacHats"); Attribute[] attrs = Attribute.GetCustomAttributes(typeof(MyHats.HatManagerHatsPatch)); foreach (Attribute attr in attrs) { Logger.LogMessage($"Looking {attr.GetType()}"); } if (attrs.Length == 0) { Logger.LogError("HarmonyPatchers not found."); } _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly()); Logger.LogMessage($"Is patched? {Harmony.HasAnyPatches(_harmony.Id)}"); } catch (Exception e) { Log.LogError(e); throw e; } }
public static void SavePins() { var mapPinsFile = Path.Combine(worldDataPath, "pins.csv"); try { File.WriteAllLines(mapPinsFile, mapDataServer.pins); // harmonyLog.Log("WebMap: Wrote pins file"); } catch { harmonyLog.LogError("WebMap: FAILED TO WRITE PINS FILE!"); } }
public override void Load() { log = Log; log.LogMessage("Loading..."); if (!AutoUpdate.CheckUpdate()) { log.LogError("Not Loaded... old version and not have update"); return; } ClassInjector.RegisterTypeInIl2Cpp <MyClass>(); MyOptions.CustomGameOptions = new MyOptions(); ClientSocket.BuildUri(""); _harmony.PatchAll(); log.LogMessage("Loaded..."); }
public void Awake() { _logger = Logger; SetupDeployableSlots(); ModifyPrefabs(); if (!scanner.GetComponent <Deployable>()) { _logger.LogError("f**k"); } On.RoR2.EquipmentSlot.FireScanner += EquipmentSlot_FireScanner; On.RoR2.EquipmentSlot.FireGateway += EquipmentSlot_FireGateway; On.RoR2.EquipmentSlot.FireSaw += EquipmentSlot_FireSaw; On.RoR2.EquipmentSlot.FireBlackhole += EquipmentSlot_FireBlackhole; _logger.LogMessage($"Modded deployable count: {DeployableAPI.ModdedDeployableSlotCount}"); }
internal static bool Awake() { //載入font3DMaterial,為了解決UI文字穿透其他物品的問題 //因為文字無法編輯Shader,只能做Material來用 if (AssetBundle.LoadFromMemory(Properties.Resources.text) is AssetBundle assetBundle) { Font3DMaterial = assetBundle.LoadAsset <Material>("Font3DMaterial"); Font3DMaterial.color = Color.white; assetBundle.Unload(false); if (GetDynamicFontNames().Count != 0) { return(true); } } else { Logger.LogError("Load assetBundle faild"); } return(false); }
public CustomWeaponData(string filename) { FileName = filename; if (filename == "_default") { Descriptor = new WeaponDescriptor { AuthorName = "Pupuya Games", WeaponName = "Default", DisableEffect = false, }; } else { try { AssetBundle = AssetBundle.LoadFromFile(filename); Weapon = AssetBundle.LoadAsset <GameObject>("_CustomWeapon"); Weapon.SetActive(false); Descriptor = Weapon.GetComponent <WeaponDescriptor>(); } catch { var logger = new BepInEx.Logging.ManualLogSource("CustomWeaponData"); BepInEx.Logging.Logger.Sources.Add(logger); logger.LogError($"Failed loading AssetBundle: {filename}"); Weapon = null; Descriptor = new WeaponDescriptor { AuthorName = filename, WeaponName = "Invalid weapon", }; FileName = "_default"; } } }
void Awake() { instance = this; log = Logger; populateAss(); if (_hitboxBoxPrefab == null || _hitboxNotBoxPrefabTall == null || _hitboxNotBoxPrefab == null) { log.LogError($"unable to get a hitboxprefab from the bundle. Timesweeper did an oops | box: {_hitboxBoxPrefab != null}, capsule: {_hitboxNotBoxPrefabTall != null}, sphere: {_hitboxNotBoxPrefab != null}"); return; } doConfig(); if (RiskOfOptionsCompat.enabled) { RiskOfOptionsCompat.doOptions(); } else { setDefaultOptions(); } EnigmaticThunder.Modules.CommandHelper.AddToConsoleWhenReady(); //createPool(hitPoolStart, _revealerPool, false); //createPool(blastPoolStart, _blastPool, true); On.RoR2.BodyCatalog.Init += BodyCatalog_Init; On.RoR2.OverlapAttack.Fire += OverlapAttack_Fire; On.RoR2.BlastAttack.Fire += BlastAttack_Fire; On.RoR2.HurtBox.Awake += HurtBox_Awake; }
public static void ReadConfigPkg(ZPackage pkg) { if (!ZNet.IsServer()) { int entries = 0; while (pkg.GetPos() != pkg.Size()) { string configKey = pkg.ReadString(); string stringVal = pkg.ReadString(); entries++; if (Config.Instance._configEntries.ContainsKey(configKey)) { Config.Instance._configEntries[configKey].SetSerializedValue(stringVal); Logger.LogInfo($"Applied Server Authoritative config pair => {configKey}: {stringVal}"); } else { Logger.LogError($"Recieved config key we dont have locally. Possible Version Mismatch. {configKey}: {stringVal}"); } } Logger.LogInfo($"Applied {entries} config pairs"); } }
public static void Debug(object obj, int level, int line, string caller, string path) { var msg = $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {path.Split('\\').Last()} {caller}:{line} {obj}"; switch (level) { case 0: log.LogMessage(msg); break; case 1: log.LogWarning(msg); break; case 2: log.LogError(msg); break; default: log.LogFatal(msg); break; } }
private static IEnumerable <string> TellBepinAbsolutelyNothingBecauseThePluginsFolderIsntManaged() { Logger.LogInfo($"Collecting information for new MMHook"); string oldHash = null; int modsWithRefs = 0; foreach (string path in PluginPaths) { foreach (var pluginDll in Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories)) { try { using (var ass = AssemblyDefinition.ReadAssembly(pluginDll)) { if (ass.Name.Name == "MMHOOK_Assembly-CSharp") { oldHash = CollectHash(ass); mmhLocation = pluginDll; continue; } foreach (var refer in ass.MainModule.AssemblyReferences) { if (refer.Name == "MMHOOK_Assembly-CSharp") { CollectMethodDefinitions(ass); modsWithRefs++; break; } } } } catch (Exception e) { Logger.LogError($"Error on: {pluginDll}"); Logger.LogError(e); } } } if (mmhLocation == null) { Logger.LogMessage("No MMHOOK found. I can't make lighter what's already 0."); return(Array.Empty <string>()); } if (modsWithRefs == 0) { Logger.LogMessage("No plugins to patch MMHook for."); mmhLocation = null; return(Array.Empty <string>()); } Logger.LogMessage($"Found {modsWithRefs} mods with a MMHook dependency."); Logger.LogInfo($"Number of neededtypes for hooks : {neededTypes.Count}"); neededTypes.Sort(); hash = neededTypes.MakeContentHashCode(); if (oldHash == hash.ToString()) { Logger.LogMessage($"LighterhHook has already run for these mods. Using that old file again."); mmhLocation = null; } else { if (oldHash == null) { Logger.LogDebug("Backing up vanilla MMHook"); File.Delete(mmhLocation + ".backup"); File.Move(mmhLocation, mmhLocation + ".backup"); } } return(Array.Empty <string>()); }
private static void ExceptionHandler(object sender, UnhandledExceptionEventArgs e) => log.LogError("\r\n\r\nUnhandled Exception:" + (e.ExceptionObject as Exception).ToString());
/// <summary> /// 繪製轉場圖片 /// </summary> /// <param name="_step">繪製完後要進入的腳本位置</param> /// <param name="sceneName">Scene名稱</param> private static void DrawSlidePic(int _step) { GameObject parent; switch (KK_FBIOpenUp.nowGameMode) { case KK_FBIOpenUp.GameMode.Studio: parent = GameObject.Find("StudioScene/Canvas Main Menu"); break; case KK_FBIOpenUp.GameMode.MainGame: parent = GameObject.Find("ActionScene/UI/ActionMenuCanvas/ModeAnimation"); break; case KK_FBIOpenUp.GameMode.Maker: parent = GameObject.Find("CustomScene/CustomRoot/FrontUIGroup/CustomUIGroup/CvsCoordinateType/redBagBtn"); break; //FreeH死都不成功,放棄 //case KK_FBIOpenUp.GameMode.FreeH: // parent = GameObject.Find("CommonSpace"); // break; default: parent = GameObject.FindObjectsOfType <GameObject>()[0]; //Not tested break; } GameObject gameObject = new GameObject(); gameObject.transform.SetParent(parent.transform, false); gameObject.SetActive(false); if (null != shiftPicture) { GameObject.Destroy(shiftPicture.Transform.parent.gameObject); shiftPicture.image = null; shiftPicture.video = null; shiftPicture = null; } shiftPicture = new ShiftPicture(); //如果影片不存在,用熊吉代替 bool noVideoFallback = _step == 20 && null == KK_FBIOpenUp.videoPath; if (noVideoFallback) { _step = 2; } switch (_step) { case 1: //小學生真是太棒了 shiftPicture.type = ShiftPicture.Type.picture; shiftPicture.image = UIUtility.CreateImage("", gameObject.transform, Extension.Extension.LoadNewSprite("KK_FBIOpenUp.Resources.saikodaze.jpg", 800, 657)); shiftPicture.image.rectTransform.sizeDelta = new Vector2(Screen.height / 1.5f * 800 / 657, Screen.height / 1.5f); Right2Center(); break; case 2: //熊吉逮捕 shiftPicture.type = ShiftPicture.Type.picture; shiftPicture.image = UIUtility.CreateImage("", gameObject.transform, Extension.Extension.LoadNewSprite("KK_FBIOpenUp.Resources.Kumakichi.jpg", 640, 480)); shiftPicture.image.rectTransform.sizeDelta = new Vector2(Screen.height / 1.5f * 640 / 480, Screen.height / 1.5f); Left2Center(); break; case 10: //幼女退光線 shiftPicture.type = ShiftPicture.Type.picture; shiftPicture.image = UIUtility.CreateImage("", gameObject.transform, Extension.Extension.LoadNewSprite("KK_FBIOpenUp.Resources.beam.png", 700, 700)); shiftPicture.image.rectTransform.sizeDelta = new Vector2(Screen.height / 1.25f, Screen.height / 1.25f); Right2Center(); break; case 20: //FBI Open Up影片 shiftPicture.type = ShiftPicture.Type.video; shiftPicture.video = UIUtility.CreateRawImage("", gameObject.transform); shiftPicture.video.rectTransform.sizeDelta = new Vector2(Screen.height / 1.5f, Screen.height / 1.5f); UnityEngine.Video.VideoPlayer videoPlayer = gameObject.AddComponent <UnityEngine.Video.VideoPlayer>(); AudioSource audioSource = gameObject.AddComponent <AudioSource>(); videoPlayer.playOnAwake = false; audioSource.playOnAwake = false; videoPlayer.renderMode = UnityEngine.Video.VideoRenderMode.APIOnly; //videoPlayer.url= "../UserData/audio/FBI.mp4"; videoPlayer.url = KK_FBIOpenUp.videoPath; //Set Audio Output to AudioSource videoPlayer.audioOutputMode = UnityEngine.Video.VideoAudioOutputMode.AudioSource; //Assign the Audio from Video to AudioSource to be played videoPlayer.EnableAudioTrack(0, true); videoPlayer.SetTargetAudioSource(0, audioSource); Logger.LogDebug($"{videoPlayer.url}"); videoPlayer.isLooping = true; //先把他移到螢幕外啟用,否則未啟用無法Prepare,而直接啟用會出現白色畫面 shiftPicture.Transform.position = new Vector3(-2 * Screen.width, Screen.height / 2); gameObject.SetActive(true); videoPlayer.Prepare(); videoPlayer.prepareCompleted += (source) => { ///TODO 這實際上沒有辦法真的catch到錯誤,待修 if (videoPlayer.texture == null) { Logger.LogError("Video not found"); GameObject.Destroy(shiftPicture.Transform.parent.gameObject); shiftPicture.video = null; shiftPicture = null; _step = 0; return; } shiftPicture.video.texture = videoPlayer.texture; videoTimer = 2; videoPlayer.Play(); audioSource.Play(); //影片太大聲QQ audioSource.volume = KK_FBIOpenUp.videoVolume; Left2Center(); }; break; } //如果影片不存在,用熊吉代替 if (noVideoFallback) { _step = 20; } step = _step; Logger.LogDebug("Draw Slide Pic"); void Right2Center() { //Right To Center shiftPicture.Transform.position = new Vector3(Screen.width + shiftPicture.Width / 2, Screen.height / 2); shiftPicture.targetPosition = new Vector3(Screen.width / 2, Screen.height / 2); gameObject.SetActive(true); } void Left2Center() { //Left To Center shiftPicture.Transform.position = new Vector3(-1 * (Screen.width + shiftPicture.Width / 2), Screen.height / 2); shiftPicture.targetPosition = new Vector3(Screen.width / 2, Screen.height / 2); gameObject.SetActive(true); } }
//The Awake() method is run at the very start when the game is initialized. public void Awake() { harmony = new Harmony("no.runnane.valheim.webmap"); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); harmonyLog = Logger; var pluginPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); WebMapConfig.readConfigFile(Path.Combine(pluginPath, "config.json")); var mapDataPath = Path.Combine(pluginPath, "map_data"); Directory.CreateDirectory(mapDataPath); worldDataPath = Path.Combine(mapDataPath, WebMapConfig.getWorldName()); Directory.CreateDirectory(worldDataPath); mapDataServer = new MapDataServer(); mapDataServer.ListenAsync(); var mapImagePath = Path.Combine(worldDataPath, "map"); try { mapDataServer.mapImageData = File.ReadAllBytes(mapImagePath); } catch (Exception e) { Logger.LogError("WebMap: Failed to read map image data from disk. " + e.Message); } var fogImagePath = Path.Combine(worldDataPath, "fog.png"); try { var fogTexture = new Texture2D(WebMapConfig.TEXTURE_SIZE, WebMapConfig.TEXTURE_SIZE); var fogBytes = File.ReadAllBytes(fogImagePath); fogTexture.LoadImage(fogBytes); mapDataServer.fogTexture = fogTexture; } catch (Exception e) { Logger.LogWarning("WebMap: Failed to read fog image data from disk... Making new fog image..." + e.Message); var fogTexture = new Texture2D(WebMapConfig.TEXTURE_SIZE, WebMapConfig.TEXTURE_SIZE, TextureFormat.RGB24, false); var fogColors = new Color32[WebMapConfig.TEXTURE_SIZE * WebMapConfig.TEXTURE_SIZE]; for (var t = 0; t < fogColors.Length; t++) { fogColors[t] = Color.black; } fogTexture.SetPixels32(fogColors); var fogPngBytes = fogTexture.EncodeToPNG(); mapDataServer.fogTexture = fogTexture; try { File.WriteAllBytes(fogImagePath, fogPngBytes); } catch (Exception e2) { harmonyLog.LogError("WebMap: FAILED TO WRITE FOG FILE! " + e2); } } InvokeRepeating("UpdateFogTexture", WebMapConfig.UPDATE_FOG_TEXTURE_INTERVAL, WebMapConfig.UPDATE_FOG_TEXTURE_INTERVAL); InvokeRepeating("SaveFogTexture", WebMapConfig.SAVE_FOG_TEXTURE_INTERVAL, WebMapConfig.SAVE_FOG_TEXTURE_INTERVAL); InvokeRepeating("SavePinsIfNeeded", WebMapConfig.UPDATE_FOG_TEXTURE_INTERVAL, WebMapConfig.UPDATE_FOG_TEXTURE_INTERVAL); InvokeRepeating("BroadcastWebsocket", WebMapConfig.PLAYER_UPDATE_INTERVAL, WebMapConfig.PLAYER_UPDATE_INTERVAL); var mapPinsFile = Path.Combine(worldDataPath, "pins.csv"); try { var pinsLines = File.ReadAllLines(mapPinsFile); mapDataServer.pins = new List <string>(pinsLines); } catch (Exception e) { harmonyLog.LogError("WebMap: Failed to read pins.csv from disk. " + e.Message); } }
public static void Modify() { foreach (var body in BodyCatalog.allBodyPrefabs.ToList()) { if (!body) { continue; } if (bannedBodyNames.Contains(body.name)) { _logger.LogWarning($"Skipping {body.name}!"); continue; } _logger.LogMessage($"Working on {body.name}"); var skillLocator = body.GetComponent <SkillLocator>(); if (!skillLocator) { _logger.LogError("No SkillLocator, continuing."); continue; } var esmList = body.GetComponents <EntityStateMachine>().ToList(); if (esmList.Count <= 0) { _logger.LogWarning("No Entity State Machines, continuing."); continue; } foreach (var entityStateMachines in body.GetComponents <EntityStateMachine>().ToList()) { if (entityStateMachines.customName == "Body") { continue; } Destroy(entityStateMachines); } var primaryState = CreateEntityStateMachine(body, primaryName); var secondaryState = CreateEntityStateMachine(body, secondaryName); var utilityState = CreateEntityStateMachine(body, utilityName); var specialState = CreateEntityStateMachine(body, specialName); var networkStateMachine = body.GetComponent <NetworkStateMachine>(); if (networkStateMachine) { networkStateMachine.stateMachines = new EntityStateMachine[] { primaryState, secondaryState, utilityState, specialState }; } if (skillLocator.primary) { //skillLocator.primary.skillDef.activationStateMachineName = primaryState.customName; foreach (var variant in skillLocator.primary.skillFamily.variants) { _logger.LogMessage($"Modifying PRIMARY skillDef {variant.skillDef.skillNameToken}"); variant.skillDef.activationStateMachineName = primaryState.customName; } } if (skillLocator.secondary) { //skillLocator.secondary.skillDef.activationStateMachineName = primaryState.customName; foreach (var variant in skillLocator.secondary.skillFamily.variants) { _logger.LogMessage($"Modifying SECONDARY skillDef {variant.skillDef.skillNameToken}"); variant.skillDef.activationStateMachineName = primaryState.customName; } } if (skillLocator.utility) { //skillLocator.utility.skillDef.activationStateMachineName = primaryState.customName; foreach (var variant in skillLocator.utility.skillFamily.variants) { _logger.LogMessage($"Modifying UTILITY skillDef {variant.skillDef.skillNameToken}"); variant.skillDef.activationStateMachineName = primaryState.customName; } } if (skillLocator.special) { //skillLocator.special.skillDef.activationStateMachineName = primaryState.customName; foreach (var variant in skillLocator.special.skillFamily.variants) { _logger.LogMessage($"Modifying SPECIAL skillDef {variant.skillDef.skillNameToken}"); variant.skillDef.activationStateMachineName = primaryState.customName; } } } }
public static void ObjectDB_Awake_QuickSmeltPatch(ref ObjectDB __instance) { if (!TripleBronze.CraftBarsInForgeEnabled) { return; } if (!IsObjectDBGood()) { return; } List <CraftingStation> craftingStations = __instance.m_recipes .Where(r => r != null) .Select(i => i.m_craftingStation) .Where(r => r != null) .Distinct() .ToList(); ItemDrop woodDrop = __instance.GetItemPrefab(@"Wood")?.GetComponent <ItemDrop>(); ItemDrop coalDrop = __instance.GetItemPrefab(@"Coal")?.GetComponent <ItemDrop>(); ItemDrop copperOreDrop = __instance.GetItemPrefab(@"CopperOre")?.GetComponent <ItemDrop>(); ItemDrop copperDrop = __instance.GetItemPrefab(@"Copper")?.GetComponent <ItemDrop>(); ItemDrop tinOreDrop = __instance.GetItemPrefab(@"TinOre")?.GetComponent <ItemDrop>(); ItemDrop tinDrop = __instance.GetItemPrefab(@"Tin")?.GetComponent <ItemDrop>(); ItemDrop ironOreDrop = __instance.GetItemPrefab(@"IronOre")?.GetComponent <ItemDrop>(); ItemDrop ironScrapDrop = __instance.GetItemPrefab(@"IronScrap")?.GetComponent <ItemDrop>(); ItemDrop ironDrop = __instance.GetItemPrefab(@"Iron")?.GetComponent <ItemDrop>(); ItemDrop silverOreDrop = __instance.GetItemPrefab(@"SilverOre")?.GetComponent <ItemDrop>(); ItemDrop silverDrop = __instance.GetItemPrefab(@"Silver")?.GetComponent <ItemDrop>(); ItemDrop blackMetalScrapDrop = __instance.GetItemPrefab(@"BlackMetalScrap")?.GetComponent <ItemDrop>(); ItemDrop blackMetalDrop = __instance.GetItemPrefab(@"BlackMetal")?.GetComponent <ItemDrop>(); ItemDrop flametalOreDrop = __instance.GetItemPrefab(@"FlametalOre")?.GetComponent <ItemDrop>(); ItemDrop flametalDrop = __instance.GetItemPrefab(@"Flametal")?.GetComponent <ItemDrop>(); if (woodDrop == null) { logger.LogError($"woodDrop is null!"); return; } if (coalDrop == null) { logger.LogError($"coalDrop is null!"); return; } if (copperOreDrop == null) { logger.LogError($"copperOreDrop is null!"); return; } if (copperDrop == null) { logger.LogError($"copperDrop is null!"); return; } if (tinOreDrop == null) { logger.LogError($"tinOreDrop is null!"); return; } if (tinDrop == null) { logger.LogError($"tinDrop is null!"); return; } if (ironScrapDrop == null) { logger.LogError($"ironScrapDrop is null!"); return; } if (ironOreDrop == null) { logger.LogError($"ironOreDrop is null!"); return; } if (ironDrop == null) { logger.LogError($"ironDrop is null!"); return; } if (silverOreDrop == null) { logger.LogError($"silverOreDrop is null!"); return; } if (silverDrop == null) { logger.LogError($"silverDrop is null!"); return; } if (blackMetalScrapDrop == null) { logger.LogError($"blackMetalScrapDrop is null!"); return; } if (blackMetalDrop == null) { logger.LogError($"blackMetalDrop is null!"); return; } if (flametalOreDrop == null) { logger.LogError($"flametalOreDrop is null!"); return; } if (flametalDrop == null) { logger.LogError($"flametalDrop is null!"); return; } CraftingStation forge = craftingStations.Find(c => c.m_name.Contains(@"forge")); CraftingStation workbench = craftingStations.Find(c => c.m_name.Contains(@"workbench")); Recipe coalRecipe = MakeRecipe(Tuple.Create(workbench, 2), null, Tuple.Create(coalDrop, 1), Tuple.Create(woodDrop, 1)); Recipe copperBarRecipe = MakeRecipe(Tuple.Create(forge, 2), null, Tuple.Create(copperDrop, 1), Tuple.Create(coalDrop, (int)TripleBronze.CoalPerBar), Tuple.Create(copperOreDrop, 1)); Recipe tinBarRecipe = MakeRecipe(Tuple.Create(forge, 3), null, Tuple.Create(tinDrop, 1), Tuple.Create(coalDrop, (int)TripleBronze.CoalPerBar), Tuple.Create(tinOreDrop, 1)); Recipe ironBarRecipe1 = MakeRecipe(Tuple.Create(forge, 4), null, Tuple.Create(ironDrop, 1), Tuple.Create(coalDrop, (int)TripleBronze.CoalPerBar), Tuple.Create(ironScrapDrop, 1)); Recipe ironBarRecipe2 = MakeRecipe(Tuple.Create(forge, 4), null, Tuple.Create(ironDrop, 1), Tuple.Create(coalDrop, (int)TripleBronze.CoalPerBar), Tuple.Create(ironOreDrop, 1)); Recipe silverBarRecipe = MakeRecipe(Tuple.Create(forge, 4), null, Tuple.Create(silverDrop, 1), Tuple.Create(coalDrop, (int)TripleBronze.CoalPerBar), Tuple.Create(silverOreDrop, 1)); Recipe blackMetalBarRecipe = MakeRecipe(Tuple.Create(forge, 5), null, Tuple.Create(blackMetalDrop, 1), Tuple.Create(coalDrop, (int)TripleBronze.CoalPerBar), Tuple.Create(blackMetalScrapDrop, 1)); Recipe flametalBarRecipe = MakeRecipe(Tuple.Create(forge, 4), null, Tuple.Create(flametalDrop, 1), Tuple.Create(coalDrop, (int)TripleBronze.CoalPerBar), Tuple.Create(flametalOreDrop, 1)); Recipe[] recipes = new[] { coalRecipe, copperBarRecipe, tinBarRecipe, ironBarRecipe1, ironBarRecipe2, silverBarRecipe, blackMetalBarRecipe, flametalBarRecipe }; var howManyRecipesAlreadyHave = __instance.m_recipes.Count(recipe => recipes.Contains(recipe)); if (howManyRecipesAlreadyHave < recipes.Length) { __instance.m_recipes.RemoveAll(recipe => recipes.Contains(recipe)); } __instance.m_recipes.AddRange(recipes); }
void Awake() { Logger = base.Logger; if (Application.platform == RuntimePlatform.WindowsPlayer) { _speedyassets = AssetBundle.LoadFromMemory(Properties.Resources.speedyassets); if (!_speedyassets) { Logger.LogError($"Failed to read AssetBundle stream"); return; } } Config.init(this, true); _hudDynamicStatusText = Config.Bind("Hud", "EnableDynamicStatusText", true, "Show surface type text as status effect name", false); _hudShowEffectPercent = Config.Bind("Hud", "ShowStatusEffectPercent", true, "Show the status effect buff/debuff %", false); _showHudStatus = Config.Bind("Hud", "ShowStatusIcon", true, "Show the speedypaths status icon in the hud", false); _hudStatusText = Config.Bind("Hud", "StatusText", "Speedy Path", "Text shown above the status icon", false); _hudPosIconThresholds.Add(Config.Bind("Hud", "BuffIcon +1", 1.0f, "Speed buff threshold to show lvl 1 buff icon")); _hudPosIconThresholds.Add(Config.Bind("Hud", "BuffIcon +2", 1.39f, "Speed buff threshold to show lvl 2 buff icon")); _hudNegIconThresholds.Add(Config.Bind("Hud", "DebuffIcon -1", 1.0f, "Speed buff threshold to show lvl 1 debuff icon")); _hudNegIconThresholds.Add(Config.Bind("Hud", "DebuffIcon -2", 0.79f, "Speed buff threshold to show lvl 2 debuff icon")); _speedModifiers[GroundType.PathDirt] = Config.Bind("SpeedModifiers", "DirtPathSpeed", 1.15f, "Modifier for speed while on dirt paths"); _speedModifiers[GroundType.PathStone] = Config.Bind("SpeedModifiers", "StonePathSpeed", 1.4f, "Modifier for speed while on stone paths"); _speedModifiers[GroundType.Cultivated] = Config.Bind("SpeedModifiers", "CultivatedSpeed", 1.0f, "Modifier for speed while on Cultivated land"); _speedModifiers[GroundType.StructureWood] = Config.Bind("SpeedModifiers", "StructureWoodSpeed", 1.15f, "Modifier for speed while on wood structures"); _speedModifiers[GroundType.StructureHardWood] = Config.Bind("SpeedModifiers", "StructureHardWoodSpeed", 1.15f, "Modifier for speed while on core wood structures"); _speedModifiers[GroundType.StructureStone] = Config.Bind("SpeedModifiers", "StructureStoneSpeed", 1.4f, "Modifier for speed while on stone structures"); _speedModifiers[GroundType.StructureIron] = Config.Bind("SpeedModifiers", "StructureIronSpeed", 1.4f, "Modifier for speed while on ironwood structures"); _staminaModifiers[GroundType.PathDirt] = Config.Bind("StaminaModifiers", "DirtPathStamina", 0.8f, "Modifier for stamina while on dirt paths"); _staminaModifiers[GroundType.PathStone] = Config.Bind("StaminaModifiers", "StonePathStamina", 0.7f, "Modifier for stamina while on stone paths"); _staminaModifiers[GroundType.Cultivated] = Config.Bind("StaminaModifiers", "CultivatedStamina", 1.0f, "Modifier for stamina while on Cultivated land"); _staminaModifiers[GroundType.StructureWood] = Config.Bind("StaminaModifiers", "StructureWoodStamina", 0.8f, "Modifier for stamina while on wood structures"); _staminaModifiers[GroundType.StructureHardWood] = Config.Bind("StaminaModifiers", "StructureHardWoodStamina", 0.8f, "Modifier for stamina while on core wood structures"); _staminaModifiers[GroundType.StructureStone] = Config.Bind("StaminaModifiers", "StructureStoneStamina", 0.7f, "Modifier for stamina while on stone structures"); _staminaModifiers[GroundType.StructureIron] = Config.Bind("StaminaModifiers", "StructureIronStamina", 0.7f, "Modifier for stamina while on ironwood structures"); //Should handle new biomes automagically foreach (Heightmap.Biome biome in Enum.GetValues(typeof(Heightmap.Biome))) { if (biome == Heightmap.Biome.BiomesMax) { break; } _untamedSpeedModifiers[biome] = Config.Bind("SpeedModifiers_Biomes", "Untamed_" + biome.ToString() + "_Speed", 1.0f, "Speed modifier for uncleared ground in " + biome.ToString() + " Biomes"); _untamedStaminaModifiers[biome] = Config.Bind("StaminaModifiers_Biomes", "Untamed_" + biome.ToString() + "_Stamina", 1.0f, "Stamina modifier for uncleared ground in " + biome.ToString() + " Biomes"); _biomeTypeStrings[biome] = Config.Bind("Strings", "Biome_" + biome.ToString(), "default", "Dynamic status mapping for " + biome.ToString() + " groundcover. 'default' uses localized biome name."); } _groundTypeStrings[GroundType.PathDirt] = Config.Bind("Strings", "PathDirt", "Dirt Path", "Dynamic status mapping for dirt paths"); _groundTypeStrings[GroundType.PathStone] = Config.Bind("Strings", "PathStone", "Stone Path", "Dynamic status mapping for stone paths"); _groundTypeStrings[GroundType.Cultivated] = Config.Bind("Strings", "Cultivated", "Cultivated", "Dynamic status mapping for Cultivated land"); _groundTypeStrings[GroundType.StructureWood] = Config.Bind("Strings", "StructureWood", "Wood", "Dynamic status mapping for wood structures"); _groundTypeStrings[GroundType.StructureHardWood] = Config.Bind("Strings", "StructureHardWood", "Hardwood", "Dynamic status mapping for core wood structures"); _groundTypeStrings[GroundType.StructureStone] = Config.Bind("Strings", "StructureStone", "Stone", "MDynamic status mapping for stone structures"); _groundTypeStrings[GroundType.StructureIron] = Config.Bind("Strings", "StructureIron", "Iron", "Dynamic status mapping for ironwood structures"); if (m_pieceLayer == 0) { m_pieceLayer = LayerMask.NameToLayer("piece"); } _speedSprites.Add(_speedyassets.LoadAsset <Sprite>("assets/nex.speedypaths/speedypaths_1.png")); _speedSprites.Add(_speedyassets.LoadAsset <Sprite>("assets/nex.speedypaths/speedypaths_2.png")); _speedSprites.Add(_speedyassets.LoadAsset <Sprite>("assets/nex.speedypaths/speedypaths_n1.png")); _speedSprites.Add(_speedyassets.LoadAsset <Sprite>("assets/nex.speedypaths/speedypaths_n2.png")); Harmony.CreateAndPatchAll(typeof(SpeedyPathsClientMod)); }
public static void CopyKCOXData(ChaControl sourceChaCtrl, ChaControl targetChaCtrl, int kind, bool?main = true) { if (sourceChaCtrl != KCOX_Support.sourceChaCtrl || targetChaCtrl != KCOX_Support.targetChaCtrl) { if (!GetControllerAndBackupData(sourceChaCtrl, targetChaCtrl)) { Logger.LogError("Skip on KCOX Controller not found."); CleanKCOXBackup(); return; } } string name = ""; switch (main) { case true: name = MainClothesNames[kind]; switch (kind) { case 0: //換上衣時處理sub和BodyMask、InnerMask for (int i = 0; i < 3; i++) { CopyKCOXData(sourceChaCtrl, targetChaCtrl, i, false); } for (int i = 0; i < 2; i++) { CopyKCOXData(sourceChaCtrl, targetChaCtrl, i, null); } break; case 2: //換胸罩時處理BraMask CopyKCOXData(sourceChaCtrl, targetChaCtrl, 2, null); break; } break; case false: name = SubClothesNames[kind]; break; case null: name = MaskKind[kind]; break; } bool exist = SourceKCOXBackup.TryGetValue(name, out object tex); //KCOXController.Invoke("SetOverlayTex", new object[] { tex, name }); ChaFileDefine.CoordinateType coordinateType = (ChaFileDefine.CoordinateType)targetChaCtrl.fileStatus.coordinateType; Dictionary <ChaFileDefine.CoordinateType, object> _allOverlayTextures = TargetKCOXController.GetField("_allOverlayTextures").ToDictionary <ChaFileDefine.CoordinateType, object>(); if (TargetKCOXController.GetProperty("CurrentOverlayTextures").ToDictionary <string, object>().TryGetValue(name, out object clothesTexData)) { if (!exist || tex == null || (bool)tex.Invoke("IsEmpty")) { clothesTexData.Invoke("Clear"); clothesTexData.SetField("Override", false); _allOverlayTextures[coordinateType].Invoke("Remove", new object[] { name }); Logger.LogDebug($"->Clear Overlay/Mask: {name}"); } else { clothesTexData.SetProperty("Texture", tex.GetProperty("Texture")); if (null != tex.GetField("Override")) { clothesTexData.SetField("Override", tex.GetField("Override")); } Logger.LogDebug($"->Replace Overlay/Mask: {name}"); } } else { if (exist && tex != null && !(bool)tex.Invoke("IsEmpty")) { _allOverlayTextures[coordinateType].Invoke("Add", new object[] { name, tex }); Logger.LogDebug($"->Add Overlay/Mask: {name}"); } } }