public void OnLoad() { Harmony harmony = new Harmony("cappycot.filmthedepths"); harmony.PatchAll(Assembly.GetExecutingAssembly()); AdvLogger.LogInfo("Film The Depths is ready."); }
static void ObjLoadMenu() { string pth = UnityEditor.EditorUtility.OpenFilePanel("Import OBJ", "", "obj"); if (!string.IsNullOrEmpty(pth)) { System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch(); s.Start(); LoadOBJFile(pth); AdvLogger.LogInfo("OBJ load took " + s.ElapsedMilliseconds + "ms"); s.Stop(); } }
public static Texture2D LoadDDSManual(string ddsPath) { try { byte[] ddsBytes = File.ReadAllBytes(ddsPath); byte ddsSizeCheck = ddsBytes[4]; if (ddsSizeCheck != 124) { throw new System.Exception("Invalid DDS DXTn texture. Unable to read"); //this header byte should be 124 for DDS image files } int height = ddsBytes[13] * 256 + ddsBytes[12]; int width = ddsBytes[17] * 256 + ddsBytes[16]; byte DXTType = ddsBytes[87]; TextureFormat textureFormat = TextureFormat.DXT5; if (DXTType == 49) { textureFormat = TextureFormat.DXT1; // AdvLogger.LogInfo ("DXT1"); } if (DXTType == 53) { textureFormat = TextureFormat.DXT5; // AdvLogger.LogInfo ("DXT5"); } int DDS_HEADER_SIZE = 128; byte[] dxtBytes = new byte[ddsBytes.Length - DDS_HEADER_SIZE]; Buffer.BlockCopy(ddsBytes, DDS_HEADER_SIZE, dxtBytes, 0, ddsBytes.Length - DDS_HEADER_SIZE); System.IO.FileInfo finf = new System.IO.FileInfo(ddsPath); Texture2D texture = new Texture2D(width, height, textureFormat, false); texture.LoadRawTextureData(dxtBytes); texture.Apply(); texture.name = finf.Name; return(texture); } catch (Exception) { AdvLogger.LogError("Error: Could not load DDS", LogOptions.Popup); return(new Texture2D(8, 8)); } }
public static Texture2D LoadTexture(string fn, bool normalMap = false) { if (!File.Exists(fn)) { return(null); } string ext = Path.GetExtension(fn).ToLower(); if (ext == ".png" || ext == ".jpg") { Texture2D t2d = new Texture2D(1, 1); t2d.LoadImage(File.ReadAllBytes(fn)); if (normalMap) { SetNormalMap(ref t2d); } return(t2d); } else if (ext == ".dds") { Texture2D returnTex = LoadDDSManual(fn); if (normalMap) { SetNormalMap(ref returnTex); } return(returnTex); } else if (ext == ".tga") { Texture2D returnTex = LoadTGA(fn); if (normalMap) { SetNormalMap(ref returnTex); } return(returnTex); } else { AdvLogger.LogInfo("texture not supported : " + fn); } return(null); }
public static Material[] LoadMTLFile(string fn, Shader shader) { Material mat = null; List <Material> matlList = new List <Material>(); FileInfo mtlFileInfo = new FileInfo(fn); string baseFileName = Path.GetFileNameWithoutExtension(fn); string mtlFileDirectory = mtlFileInfo.Directory.FullName + Path.DirectorySeparatorChar; foreach (string ln in File.ReadAllLines(fn)) { string l = ln.Trim().Replace(" ", " "); string[] cmps = l.Split(' '); string data = l.Remove(0, l.IndexOf(' ') + 1); bool isTransparent = shader.name.Contains("Transparent"); bool isHologram = shader.name.Contains("Hologram"); if (cmps[0] == "newmtl") { if (mat != null) { matlList.Add(mat); } AdvLogger.LogInfo("[3D Holo] Assigning shader"); mat = new Material(shader) { name = data }; AdvLogger.LogInfo("[3D Holo] Done"); mat.SetFloat("_RimPower", 10); mat.SetColor("_Color", new Color(1, 1, 1, 0.5f)); mat.SetColor("_Emission", Color.white); } else if (cmps[0] == "Kd") { mat.SetColor("_MainColor", ParseColorFromCMPS(cmps)); } else if (cmps[0] == "map_Kd") { //TEXTURE string fpth = OBJGetFilePath(data, mtlFileDirectory, baseFileName); if (fpth != null) { mat.SetTexture("_MainTex", TextureLoader.LoadTexture(fpth)); } } else if (cmps[0] == "map_Bump") { //TEXTURE string fpth = OBJGetFilePath(data, mtlFileDirectory, baseFileName); if (fpth != null) { mat.SetTexture("_BumpMap", TextureLoader.LoadTexture(fpth, true)); mat.EnableKeyword("_NORMALMAP"); } } else if (cmps[0] == "map_Ao") { //TEXTURE string fpth = OBJGetFilePath(data, mtlFileDirectory, baseFileName); if (fpth != null) { mat.SetTexture("_OcclusionMap", TextureLoader.LoadTexture(fpth, true)); mat.EnableKeyword("_OCCLUSION"); } } else if (cmps[0] == "Ks") { mat.SetColor("_RimColor", ParseColorFromCMPS(cmps)); mat.SetColor("_SpecColor", ParseColorFromCMPS(cmps)); } else if (cmps[0] == "Ns") { float Ns = float.Parse(cmps[1]); Ns = (Ns / 1000); mat.SetFloat("_Smooth", Ns); } } if (mat != null) { matlList.Add(mat); } return(matlList.ToArray()); }
/// <summary> /// Das Spiel wird beendet und das Plugin sollte nun Sachen abspeichern. /// </summary> public void OnSave() { AdvLogger.LogInfo(name + " didn´t saved anything."); }
/// <summary> /// Das Plugin wird geladen und sollte notwendige Vorbereitungen treffen. /// </summary> public void OnLoad() { BoardTypes.FtdBreadboard.Add(new BoardTypes.ComponentType(typeof(CustomTagDriveModule))); //BoardTypes.FtdBreadboard.Add(new BoardTypes.ComponentType(typeof(CustomTagInput))); AdvLogger.LogInfo(name + " V" + version + " has been loaded."); }
static void Postfix(cCameraControl __instance, FocusCameraSettings settings) { cCameraControl_IEFocusExternalCameraOnThis_Patch.xRotVel = 0f; cCameraControl_IEFocusExternalCameraOnThis_Patch.yRotVel = 0f; Main.subject = null; Main.rotation = null; IPositionReturn pof = settings.PositionOfFocus; switch (pof) { case PositionAndRotationReturnConstruct parrc: // I can't find where this is created... FieldInfo fic = typeof(PositionAndRotationReturnConstruct).GetField("_c", BindingFlags.NonPublic | BindingFlags.Instance); AllConstruct c = (AllConstruct)fic.GetValue(parrc); Main.rotation = parrc; Main.lastRotation = parrc.Rotation; if (c is MainConstruct mc) { Main.subject = mc; } break; case PositionReturnBlock prb: // FocusCameraSettings were directed to some construct's block. FieldInfo fib = typeof(PositionReturnBlock).GetField("_b", BindingFlags.NonPublic | BindingFlags.Instance); IBlockForReturns b = (IBlockForReturns)fib.GetValue(prb); if (b is Block block) { IAllConstructBlock acb = block.GetConstructableOrSubConstructable(); if (acb is AllConstruct ac) { Main.rotation = new RotationReturnConstruct(ac); } else // Should not be the case. { Main.rotation = new RotationReturnBlock(b); } Main.lastRotation = Main.rotation.Rotation; Main.subject = block.GetConstructable() as MainConstruct; } break; case PositionReturnForce prf: // FocusCameraSettings were created from the strategic view. FieldInfo fif = typeof(PositionReturnForce).GetField("_f", BindingFlags.NonPublic | BindingFlags.Instance); Force f = (Force)fif.GetValue(prf); if (f.C != null) { // Center camera on CoM if coming from strategic map. PositionAndRotationReturnConstruct yeah = new PositionAndRotationReturnConstruct(f.C, PositionReturnConstructReferenceSelection.CenterOfMass); settings.PositionOfFocus = yeah; Main.rotation = yeah; Main.lastRotation = yeah.Rotation; Main.subject = f.C; } else { // This produces results hysterically bad for filming. // This only should happen if the camera focuses on an out-of-play force. Main.rotation = new RotationReturnForce(f); Main.lastRotation = Main.rotation.Rotation; if (f.IsInPlay) { AdvLogger.LogInfo("PositionOfFocus set to a PositionReturnForce in play, but there is no construct object!"); } } break; case PositionReturnTransform prt: // FocusCameraSettings were directed to a projectile. FieldInfo fit = typeof(PositionReturnTransform).GetField("_t", BindingFlags.NonPublic | BindingFlags.Instance); Transform t = (Transform)fit.GetValue(prt); Main.rotation = new RotationReturnTransform(t); Main.lastRotation = Main.rotation.Rotation; break; default: // Other focus subjects won't be tracked rotation-wise. (Don't think there are any others.) AdvLogger.LogInfo(string.Format("Received a unknown IPositionReturn: {0}", pof.GetType().FullName)); break; } }