Browse Source

[ShipDecorations] [2.0.3.8] Camera test

Zariteis 4 years ago
parent
commit
fbd855f6a2

BIN
ShipDecorations/Assets/generator.png


+ 1 - 7
ShipDecorations/CoroutineManager.cs

@@ -1,10 +1,4 @@
-using GadgetCore.API;
-using GadgetCore.Util;
-using HarmonyLib;
-using System;
-using System.Collections;
-using System.Threading;
-using System.Windows.Threading;
+using System;
 using UnityEngine;
 using UnityEngine;
 
 
 namespace ShipDecorations
 namespace ShipDecorations

+ 69 - 0
ShipDecorations/Patches/Patch_CameraScript_Update.cs

@@ -0,0 +1,69 @@
+using GadgetCore.API;
+using HarmonyLib;
+using UnityEngine;
+
+namespace ShipDecorations.Patches
+{
+
+  [HarmonyPatch(typeof(CameraScript))]
+  [HarmonyPatch("Update")]
+  [HarmonyGadget("ShipDecorations")]
+  public static class Patch_CameraScript_Update
+  {
+    [HarmonyPrefix]
+    public static bool Prefix(CameraScript __instance, Transform ___t, Transform ___player, bool ___deathCamera, int ___dLimit)
+    {
+      var offset = -50f;
+      var smoothing = 100;
+
+      if (!___player)
+        ___t.rotation = Quaternion.EulerAngles(0, 0, 0);
+      else
+        ___t.rotation = Quaternion.EulerAngles(0.2f, 0.2f, 0);
+
+      if (!___player)
+      {
+        ___t.position = new Vector3(0f, 0f, -8f);
+      }
+      else if (___deathCamera)
+      {
+        ___t.position = Vector3.Lerp(___t.position, new Vector3(___player.position.x, ___player.position.y + 2f, offset), 5f * Time.smoothDeltaTime * smoothing);
+      }
+      else if (GameScript.dead)
+      {
+        Vector3 b = new Vector3(___player.position.x, ___player.position.y, offset);
+        ___dLimit = -24;
+        ___t.position = Vector3.Lerp(___t.position, b, 5f * Time.smoothDeltaTime * smoothing);
+      }
+      else if (!GameScript.inventoryOpen && !GameScript.pausing)
+      {
+        if (!GameScript.combatMode)
+        {
+          if (GameScript.buildMode)
+          {
+            ___dLimit = 20;
+          }
+          else
+          {
+            ___dLimit = 1;
+          }
+        }
+        else if (GameScript.dead)
+        {
+          ___dLimit = 15;
+        }
+        else
+        {
+          ___dLimit = 7;
+        }
+        Vector3 b2 = new Vector3(___player.position.x - 10f, ___player.position.y + 10f, offset);
+        ___t.position = Vector3.Lerp(___t.position, b2, 5f * Time.smoothDeltaTime * smoothing);
+      }
+      else
+      {
+        ___t.position = Vector3.Lerp(___t.position, new Vector3(___player.position.x - 10f, ___player.position.y + 10f, offset), 5f * Time.smoothDeltaTime * smoothing);
+      }
+      return false;
+    }
+  }
+}

+ 18 - 0
ShipDecorations/Patches/Patch_ShipScript_Update.cs

@@ -0,0 +1,18 @@
+using GadgetCore.API;
+using HarmonyLib;
+
+namespace ShipDecorations.Patches
+{
+
+  [HarmonyPatch(typeof(ShipScript))]
+  [HarmonyPatch("Update")]
+  [HarmonyGadget("ShipDecorations")]
+  public static class Patch_ShipScript_Update
+	{
+    [HarmonyPrefix]
+    public static bool Prefix(ShipScript __instance)
+		{
+			return false;
+    }
+  }
+}

+ 40 - 2
ShipDecorations/ShipDecorations.cs

@@ -27,6 +27,8 @@ namespace ShipDecorations
       Logger.Log("Ship Decorations v" + Info.Mod.Version);
       Logger.Log("Ship Decorations v" + Info.Mod.Version);
       Core.logger = Logger;
       Core.logger = Logger;
 
 
+      QualitySettings.antiAliasing = 0;
+
       var lightsPlatform = new ShopPlatform("Decorations").Register();
       var lightsPlatform = new ShopPlatform("Decorations").Register();
 
 
       lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableDecoItem("cBed.png", "iBed.png", "Bed"), 1000));
       lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableDecoItem("cBed.png", "iBed.png", "Bed"), 1000));
@@ -77,7 +79,7 @@ namespace ShipDecorations
         GadgetCoreAPI.AddCustomResource("prop/ScrapYard/component/engineGreen", engine);
         GadgetCoreAPI.AddCustomResource("prop/ScrapYard/component/engineGreen", engine);
       }
       }
 
 
-      foreach (var e in ShopPlatform.DefaultObjects.GetShopPlatformEntries())
+      foreach (var e in ShopPlatform.DefaultBlocks.GetShopPlatformEntries())
       {
       {
         if (e.ItemID == 2400)
         if (e.ItemID == 2400)
         {
         {
@@ -87,9 +89,45 @@ namespace ShipDecorations
 
 
       ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateEngineItem("cBlueEngineBlock.png", "iBlueEngineBlock.png", "engineBlue", "Plasma Engine", "An engine for a ship.", "BlueEngineBlock"), 10));
       ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateEngineItem("cBlueEngineBlock.png", "iBlueEngineBlock.png", "engineBlue", "Plasma Engine", "An engine for a ship.", "BlueEngineBlock"), 10));
       ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateEngineItem("cYellowEngineBlock.png", "iYellowEngineBlock.png", "engineYellow", "Differential Engine", "An engine for a ship.", "YellowEngineBlock"), 10));
       ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateEngineItem("cYellowEngineBlock.png", "iYellowEngineBlock.png", "engineYellow", "Differential Engine", "An engine for a ship.", "YellowEngineBlock"), 10));
-      ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateOverrideEngineItem("cRedEngineBlock.png", "iRedEngineBlock.png", "engineRed", "Combustion Engine", "An engine for a ship.", "RedEngineBlock"), 10));
+      //ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateOverrideEngineItem("cRedEngineBlock.png", "iRedEngineBlock.png", "engineRed", "Combustion Engine", "An engine for a ship.", "RedEngineBlock"), 10));
       ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateEngineItem("cGreenEngineBlock.png", "iGreenEngineBlock.png", "engineGreen", "Burst Engine", "An engine for a ship.", "GreenEngineBlock"), 10));
       ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateEngineItem("cGreenEngineBlock.png", "iGreenEngineBlock.png", "engineGreen", "Burst Engine", "An engine for a ship.", "GreenEngineBlock"), 10));
 
 
+
+      SceneManager.sceneLoaded += OnSceneLoaded;
+    }
+
+    internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
+    {
+      if (scene.buildIndex == 1)
+      {
+        try
+        {
+          var aa = GameObject.Find("Main Camera").GetComponent<AntialiasingAsPostEffect>();
+
+          //aa.enabled = true;
+          Component.DestroyImmediate(aa);
+          //var bloom = GameObject.Find("Main Camera").GetComponent<Bloom>();
+          //Component.DestroyImmediate(bloom);
+          var vig = GameObject.Find("Main Camera").GetComponent<Vignetting>();
+          Component.DestroyImmediate(vig);
+          var noise = GameObject.Find("Main Camera").GetComponent<NoiseEffect>();
+          Component.DestroyImmediate(noise);
+          var flare = GameObject.Find("Main Camera").GetComponent<Flare>();
+          Component.DestroyImmediate(flare);
+          //var camera = GameObject.Find("Main Camera").GetComponent<Camera>();
+          //camera.transform.rotation = Quaternion.EulerAngles(0.2f,0.2f,0);
+          //camera.useOcclusionCulling = false;
+          //camera.orthographic = false;
+          //camera.rect = new Rect(0, 0, 1, 1);
+          //camera.fieldOfView = 33;
+          //GameObject.Find("Main Camera").transform.localPosition = new Vector3(0, 0, -50);
+          //for(int i  = 0; i < GameObject.Find("Main Camera").transform.GetChildCount(); i++)
+          //{
+          //  GameObject.Find("Main Camera").transform.GetChild(i).transform.localPosition = new Vector3(0, 0, -60);
+          //}
+        }
+        catch (Exception e) { Core.logger.LogConsole(e.Message); }
+      }
     }
     }
   }
   }
 }
 }

+ 4 - 3
ShipDecorations/ShipDecorations.csproj

@@ -42,6 +42,10 @@
       <HintPath>$(GamePath)$(ManagedFolder)Assembly-CSharp.dll</HintPath>
       <HintPath>$(GamePath)$(ManagedFolder)Assembly-CSharp.dll</HintPath>
       <Private>false</Private>
       <Private>false</Private>
     </Reference>
     </Reference>
+    <Reference Include="Assembly-UnityScript">
+      <HintPath>$(GamePath)$(ManagedFolder)Assembly-UnityScript.dll</HintPath>
+      <Private>false</Private>
+    </Reference>
     <Reference Include="GadgetCore">
     <Reference Include="GadgetCore">
       <HintPath>$(GamePath)$(ManagedFolder)GadgetCore.dll</HintPath>
       <HintPath>$(GamePath)$(ManagedFolder)GadgetCore.dll</HintPath>
       <Private>false</Private>
       <Private>false</Private>
@@ -409,7 +413,4 @@
       <EmbedInteropTypes>false</EmbedInteropTypes>
       <EmbedInteropTypes>false</EmbedInteropTypes>
     </Reference>
     </Reference>
   </ItemGroup>
   </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Patches\" />
-  </ItemGroup>
 </Project>
 </Project>

+ 22 - 0
ShipDecorations/ShipDecorations.sln

@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31005.135
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShipDecorations", "ShipDecorations.csproj", "{91AB81DE-EAEE-47D1-93DD-541179208219}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{91AB81DE-EAEE-47D1-93DD-541179208219}.Release|x86.ActiveCfg = Release|x86
+		{91AB81DE-EAEE-47D1-93DD-541179208219}.Release|x86.Build.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {1B9B37B1-5D3B-4232-AB22-774CA7998725}
+	EndGlobalSection
+EndGlobal