public static void Postfix()
        {
            if (uGUI_BuilderMenu.IsOpen() || !Input.GetMouseButton(2) || Builder.isPlacing)
            {
                return;
            }
            if (!Targeting.GetTarget(Player.main.gameObject, 200f, out var result, out _))
            {
                return;
            }
            if (!Targeting.GetRoot(result, out var techType, out var gameObject)
#if SN1
                || !CraftData.IsBuildableTech(techType)
#elif BZ
                || !TechData.GetBuildable(techType)
#endif
                )
            {
                return;
            }
#if SN1
            if (Builder.Begin(gameObject))
            {
                ErrorMessage.AddMessage($"Placing new {techType}");
            }
            else
            {
                Builder.End();
            }
#elif BZ
            CoroutineHost.StartCoroutine(Builder.BeginAsync(techType));
            ErrorMessage.AddMessage($"Placing new {techType}");
#endif
        }
        // Stol<cough>Borrowed from Senna's Seamoth Arms
        private void Awake()
        {
            animator     = GetComponent <Animator>();
            fxControl    = GetComponent <VFXController>();
            vfxEventType = VFXEventTypes.impact;

            foreach (FMODAsset asset in GetComponents <FMODAsset>())
            {
                if (asset.name == "claw_hit_terrain")
                {
                    this.hitTerrainSound = asset;
                }

                if (asset.name == "claw_hit_fish")
                {
                    this.hitFishSound = asset;
                }
            }

            this.pickupSounds = GetComponent <TechSoundData>();

            // Getting the wrist doesn't seem to work properly this early; I make it a coroutine here so that it can be set when available.
            CoroutineHost.StartCoroutine(GetDeepChildCoroutine());
            //base.Awake();
        }
예제 #3
0
        public static bool TryOverflowIntoCyclopsBioreactors(SubRoot subRoot, TechType fishType, ref int breedCount)
        {
            CyBioReactorMono[] cyBioReactors = subRoot.GetComponentsInChildren <CyBioReactorMono>() ?? new CyBioReactorMono[0];

            if (cyBioReactors.Length == 0)
            {
                return(breedCount > 0);
            }

            Vector2int sizePerFish = CraftData.GetItemSize(fishType);
            int        failCount   = 0;

            while (failCount < cyBioReactors.Length && breedCount > 0)
            {
                foreach (CyBioReactorMono reactor in cyBioReactors)
                {
                    if (breedCount > 0 && reactor.container.HasRoomFor(sizePerFish.x, sizePerFish.y))
                    {
                        CoroutineHost.StartCoroutine(AddToReactor(subRoot, fishType, sizePerFish, reactor));
                        breedCount--;
                    }
                    else
                    {
                        failCount++;
                    }
                }
                if (failCount < cyBioReactors.Length)
                {
                    failCount = 0;
                }
            }
            return(breedCount > 0);
        }
 public static void Postfix(Constructable __instance)
 {
     if (__instance.constructed)
     {
         CoroutineHost.StartCoroutine(InitializeBuilder(CraftData.GetTechType(__instance.gameObject)));
     }
 }
 public void PreviousTrack()
 {
     Stop();
     musicSource.clip   = null;
     CurrentTrackIndex -= 2;
     CoroutineHost.StartCoroutine(Play());
 }
예제 #6
0
        public static bool TryBreedIntoAlterraGen(WaterPark waterPark, TechType parkCreatureTechType, WaterParkCreature parkCreature)
        {
            var componentInParent = waterPark != null?waterPark.gameObject.GetComponentInParent <SubRoot>() : null;

            var AlterraGens = componentInParent != null
                ? componentInParent.gameObject.GetComponentsInChildren <IFCSStorage>()
                : null;

            if (AlterraGens is null)
            {
                return(false);
            }

            foreach (var storage in AlterraGens)
            {
                if (!storage.GetType().Name.Contains("AlterraGen") ||
                    !storage.IsAllowedToAdd(parkCreature.pickupable, false))
                {
                    continue;
                }

                CoroutineHost.StartCoroutine(AddItemToAlterraGen(parkCreatureTechType, storage));
                return(true);
            }

            return(false);
        }
        public void Awake()
        {
            //helper = new SeaTruckHelper(gameObject, false, false, false);
            helper = SeatruckServices.Main.GetSeaTruckHelper(gameObject);

            mainCab     = helper.MainCab;
            motor       = helper.TruckMotor;
            engineSound = motor.engineSound;
            rigidbody   = helper.TruckWorldForces.useRigidbody;

            CoroutineHost.StartCoroutine(LoadBiodomeRobotArmResourcesAsync());

            CoroutineHost.StartCoroutine(Init_Graphics());

            engineDefault      = ScriptableObject.CreateInstance <FMODAsset>();
            engineDefault.name = "engine";
            engineDefault.path = "event:/bz/vehicles/seatruck/engine";

            engine      = ScriptableObject.CreateInstance <FMODAsset>();
            engine.name = "engine";
            engine.path = "event:/sub/drone/motor_loop";

            isFlying.changedEvent.AddHandler(this, new Event <Utils.MonitoredValue <bool> > .HandleFunction(OnFlyModeChanged));

            mainCabExitPoint = helper.TruckSegment.exitPosition.localPosition;

            //helper.onPilotingBegin += OnPilotingBegin;

#if DEBUG
            CoroutineHost.StartCoroutine(InitDebugHUD());
#endif
        }
        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>();
        }
예제 #9
0
        public static bool TryOverflowIntoBioreactors(SubRoot subRoot, TechType fishType, ref int breedCount)
        {
            BaseBioReactor[] bioReactors = subRoot?.gameObject?.GetComponentsInChildren <BaseBioReactor>() ?? new BaseBioReactor[0];

            if (bioReactors.Length == 0)
            {
                return(breedCount > 0);
            }

            Vector2int sizePerFish = CraftData.GetItemSize(fishType);
            int        failCount   = 0;

            while (failCount < bioReactors.Length && breedCount > 0)
            {
                foreach (BaseBioReactor reactor in bioReactors)
                {
                    if (breedCount > 0 && reactor.container.HasRoomFor(sizePerFish.x, sizePerFish.y))
                    {
                        CoroutineHost.StartCoroutine(AddToReactor(subRoot, fishType, sizePerFish, reactor));
                        breedCount--;
                    }
                    else
                    {
                        failCount++;
                    }
                }
                if (failCount < bioReactors.Length)
                {
                    failCount = 0;
                }
            }
            return(breedCount > 0);
        }
예제 #10
0
        public static void ConsoleCommand_batch(string BatchName)
        {
            if (BatchName.SplitByChar('.').Length < 2)
            {
                // The above should return at least two entries if the name already contains an extension. If it doesn't, append a .txt to the end.
                BatchName += ".txt";
            }
            // This command takes the name of a file in the mod directory and attempts to parse it as separate lines, which are passed to the DevConsole separately.
            string filePath = Path.Combine(ModPath, BatchName);

            if (!File.Exists(filePath))
            {
                ErrorMessage.AddMessage($"Could not find file {filePath}");
                return;
            }

            string[] lines = File.ReadAllLines(filePath);

            /*foreach (string s in lines)
             * {
             *  //Logger.Log(Logger.Level.Debug, $"Read line '{s}' from file", null, true);
             *  //DevConsole.InternalSendConsoleCommand(s);
             *  DevConsole.SendConsoleCommand(s);
             * }*/
            CoroutineHost.StartCoroutine(ExecuteScript(BatchName, lines));
            //Logger.Log(Logger.Level.Debug, $"Done reading and executing {lines.Length} lines from file {filePath}", null, true);
        }
예제 #11
0
        // Returns true if discharge occurred, false otherwise
        internal bool Discharge(GameObject attacker)
        {
            if (this.charge < 1)
            {
                Log.LogDebug($"DiverPerimeterDefenceBehaviour.Discharge(): chip TechType {techType.AsString()} battery is dead");
                return(false);
            }

            LiveMixin mixin = attacker.GetComponent <LiveMixin>();

            if (mixin == null)
            {
                Log.LogDebug($"DiverPerimeterDefenceBehaviour.Discharge(): chip TechType {techType.AsString()} could not find LiveMixin component on attacker");
                return(false);
            }

            Log.LogDebug($"DiverPerimeterDefenceBehaviour.Discharge(): chip TechType {techType.AsString()} discharging");
            mixin.TakeDamage(DischargeDamage, gameObject.transform.position, DamageType.Electrical, gameObject);
            this.charge = Mathf.Max(this.charge - JuicePerDischarge, 0f);
            Log.LogDebug($"DiverPerimeterDefenceBehaviour.Discharge(): Discharged, available charge now {this.charge}");
            if (this.charge < 1f)
            {
                if (bDestroyWhenEmpty)
                {
                    Log.LogDebug($"DiverPerimeterDefenceBehaviour.Discharge(): bDestroyWhenEmpty = true, destroying chip");
                    CoroutineHost.StartCoroutine(AddBrokenChipAndDestroy());
                }
            }
            return(true);
        }
예제 #12
0
        public static bool TryOverflowIntoAlterraGens(SubRoot subRoot, TechType fishType, ref int breedCount)
        {
            IFCSStorage[] AlterraGens = subRoot?.gameObject?.GetComponentsInChildren <IFCSStorage>() ?? new IFCSStorage[0];

            if (AlterraGens.Length == 0)
            {
                return(breedCount > 0);
            }

            int failCount = 0;

            while (failCount < AlterraGens.Length && breedCount > 0)
            {
                foreach (IFCSStorage storage in AlterraGens)
                {
                    if (breedCount > 0 && storage.GetType().Name.Contains("AlterraGen") && storage.CanBeStored(1, fishType))
                    {
                        CoroutineHost.StartCoroutine(AddItemToAlterraGen(subRoot, fishType, storage));
                        breedCount--;
                    }
                    else
                    {
                        failCount++;
                    }
                }
                if (failCount < AlterraGens.Length)
                {
                    failCount = 0;
                }
            }

            return(breedCount > 0);
        }
        private static void Prefix(QuickSlots __instance)
        {
            if (!Input.GetKeyDown(KeyCode.I) || uGUI_PDA.main.tabOpen != PDATab.None || DevConsole.instance.state || timeCheck != 0)
            {
                return;
            }
            var item     = __instance.heldItem;
            var techType = item?.item?.GetTechType() ?? TechType.None;
            var tool     = item?.item?.gameObject.GetComponent <PlayerTool>();

            if (GameOptions.GetVrAnimationMode() || tool == null || !tool.hasFirstUseAnimation)
            {
                return;
            }
            if (Player.main.usedTools.Contains(techType))
            {
                Player.main.usedTools.Remove(techType);
            }

            var slot = __instance.GetSlotByItem(item);

            if (slot == -1)
            {
                return;
            }
            __instance.SelectImmediate(slot);
            timeCheck = Time.time + tool.holsterTime;
            CoroutineHost.StartCoroutine(SelectDelay(__instance, slot));
        }
예제 #14
0
        public static void PostPatch()
        {
#if BELOWZERO
            Sprite hoverbike = SpriteManager.Get(SpriteManager.Group.Pings, "Hoverbike");
            CraftTreeHandler.AddTabNode(CraftTree.Type.Fabricator, "HoverbikeUpgrades", "Snowfox Upgrades", hoverbike, new string[] { "Upgrades" });
            foreach (Spawnable s in new List <Spawnable>()
            {
                new HoverbikeWaterTravelModule(),
                new HoverbikeSolarChargerModule(),
                new HoverbikeStructuralIntegrityModule(),
                new HoverbikeEngineEfficiencyModule(),
                new HoverbikeSelfRepairModule(),
                new HoverbikeDurabilitySystem(),
                new HoverbikeSpeedModule(),
            })
            {
                s.Patch();
            }


            //Batteries.PostPatch();
            LanguageHandler.SetLanguageLine("SeamothWelcomeAboard", "Welcome aboard captain.");
#endif
            CoroutineHost.StartCoroutine(PostPatchCoroutine());
        }
 private void FixedUpdate()
 {
     if (Config.ReloadOnFileChange)
     {
         CoroutineHost.StartCoroutine(LoadMusic(true));
     }
 }
예제 #16
0
 public static void Prefix()
 {
     if (!File.Exists(Path.Combine(Main.modPath, "DefaultValues.json")))
     {
         CoroutineHost.StartCoroutine(Main.GenerateDefaults());
     }
 }
예제 #17
0
        public static void Load()
        {
#if SN1
            CreateTabsAndLoadFiles();
#elif BZ
            CoroutineHost.StartCoroutine(WaitForSpriteManager());
#endif
        }
예제 #18
0
 internal void AddBattery(Battery b)
 {
     if (!pendingBatteryList.Contains(b))
     {
         pendingBatteryList.Add(b);
         CoroutineHost.StartCoroutine(ProcessPendingBatteries());
     }
 }
예제 #19
0
 public DiverPerimeterDefenceChip_Broken() : base("DiverPerimeterDefenceChip_Broken", "Diver Perimeter System (damaged)", $"Protects a diver from hostile fauna using electrical discouragement.\n\nChip has been discharged and is non-functional.")
 {
     OnFinishedPatching += () =>
     {
         Main.AddModTechType(this.TechType);
         CoroutineHost.StartCoroutine(PostPatchSetup());
     };
 }
예제 #20
0
        internal static void PostSeaTruckUpgradesModuleChange(ref SeaTruckUpgrades __instance, TechType techType)
        {
            QuickLogger.Debug($"{nameof(PostSeaTruckUpgradesModuleChange)} {techType.AsString()}", true);
            SeaTruckMotor cab = __instance.motor;

            //cab.gameObject.EnsureComponent<VehicleUpgrader>().UpgradeVehicle(techType, ref cab);
            CoroutineHost.StartCoroutine(DeferUpgrade(cab, techType));
        }
예제 #21
0
        public void Patch()
        {
            TechType = TechTypeHandler.Main.AddTechType(TechTypeName, FriendlyName, Description, null, false);

            PrePatch();

            CoroutineHost.StartCoroutine(PatchAsync());
        }
        public static void Postfix(Player __instance)
        {
            SubRoot lastValidSub = __instance.lastValidSub;

            if (lastValidSub != null && __instance.CheckSubValid(lastValidSub))
            {
                CoroutineHost.StartCoroutine(WaitThenMovePlayer(__instance, lastValidSub));
            }
        }
예제 #23
0
 public DiverDefenceSystemMk2(string classId      = "DiverDefenceSystemMk2",
                              string friendlyName = "Diver Defence System Mk2",
                              string description  = "Protects a diver from hostile fauna using electrical discouragement. Can be recharged multiple times.") : base(classId, friendlyName, description)
 {
     OnFinishedPatching += () =>
     {
         CoroutineHost.StartCoroutine(PostPatchSetup());
     };
 }
예제 #24
0
 public DiverPerimeterDefenceChipItem(string classId      = "DiverPerimeterDefenceChipItem",
                                      string friendlyName = "Diver Perimeter Defence System",
                                      string description  = "Protects a diver from hostile fauna using electrical discouragement. Discharge damages the chip beyond repair.") : base(classId, friendlyName, description)
 {
     OnFinishedPatching += () =>
     {
         CoroutineHost.StartCoroutine(PostPatchSetup());
     };
 }
예제 #25
0
        public static void Start(IEnumerator routine)
        {
            if (host == null)
            {
                host = new GameObject("Coroutine Host").AddComponent <CoroutineHost>();
                Object.DontDestroyOnLoad(host);
            }

            host.StartCoroutine(routine);
        }
 private void Awake()
 {
     if (instance != null)
     {
         DestroyImmediate(this);
     }
     else
     {
         CoroutineHost.StartCoroutine(LoadMusic());
     }
 }
예제 #27
0
        internal static void PostFix(Respawn __instance)
        {
            if (DayNightCycle.main.timePassed >= (double)__instance.spawnTime) // if this is true respawn would have already happened in method
            {
                return;
            }

            if (Settings.instance.leviathansRespawn && !__instance.techType.IsLeviathan())
            {
                CoroutineHost.StartCoroutine(RespawnCoroutine(__instance));
            }
        }
 static bool Prefix(FMOD_CustomEmitter __instance)
 {
     if (__instance?.asset?.path != null && __instance.asset.path.Contains(@"event:/env/music/"))
     {
         CoroutineHost.StartCoroutine(CustomTunes.Main.Stop(__instance.asset.path));
         return(false);
     }
     else
     {
         return(true);
     }
 }
예제 #29
0
        private static void RebuildLayersTask(object owner, object state)
        {
            var clipmapCell = (ClipmapCell)owner;
            var meshBuilder = (MeshBuilder)state;

#if BelowZero
            CoroutineHost.StartCoroutine(clipmapCell.RebuildLayersAsync(meshBuilder));
#else
            clipmapCell.RebuildLayers(meshBuilder, out var clipmapChunk);
            clipmapCell.level.OnEndBuildLayers(clipmapCell, clipmapChunk);
#endif
        }
예제 #30
0
        internal static void Patch(Harmony harmony)
        {
#if SUBNAUTICA
            PatchSprites();
            MethodInfo methodInfo = AccessTools.Method(typeof(SpriteManager), nameof(SpriteManager.Get), new Type[] { typeof(SpriteManager.Group), typeof(string) });
#elif BELOWZERO
            CoroutineHost.StartCoroutine(PatchSpritesAsync());
            MethodInfo methodInfo = AccessTools.Method(typeof(SpriteManager), nameof(SpriteManager.Get), new Type[] { typeof(SpriteManager.Group), typeof(string), typeof(Sprite) });
#endif
            HarmonyMethod patchCheck = new HarmonyMethod(AccessTools.Method(typeof(SpritePatcher), nameof(SpritePatcher.PatchCheck)));
            harmony.Patch(methodInfo, prefix: patchCheck);
        }