public static void Prefix() { if (!File.Exists(Path.Combine(Main.modPath, "DefaultValues.json"))) { CoroutineHost.StartCoroutine(Main.GenerateDefaults()); } }
// 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(); }
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 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); }
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 }
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 }
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); }
public void PreviousTrack() { Stop(); musicSource.clip = null; CurrentTrackIndex -= 2; CoroutineHost.StartCoroutine(Play()); }
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>(); }
// 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); }
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)); }
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)); } }
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); }
public static void Load() { #if SN1 CreateTabsAndLoadFiles(); #elif BZ CoroutineHost.StartCoroutine(WaitForSpriteManager()); #endif }
internal void AddBattery(Battery b) { if (!pendingBatteryList.Contains(b)) { pendingBatteryList.Add(b); CoroutineHost.StartCoroutine(ProcessPendingBatteries()); } }
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()); }; }
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)); }
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)); } }
private static void Init() { _config = new JSONObject(); #if !UNITY_EDITOR CoroutineHost.Instance.StartCoroutine(InitAsync()); #else CoroutineHost.StartTrackedCoroutine(InitAsync(), _config, "LanguageManager"); #endif }
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()); }; }
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()); }; }
static private void CreateHost() { if (s_RoutineHost == null) { s_RoutineHost = new GameObject("CoroutineHost").AddComponent <CoroutineHost>(); s_RoutineHost.hideFlags = s_RoutineHost.gameObject.hideFlags = HideFlags.HideAndDontSave; CoroutineHost.DontDestroyOnLoad(s_RoutineHost); } }
/// <summary> /// Fills an Image and sets it type to fill if it is not yet fill /// </summary> /// <param name="img">The Image to fill</param> /// <param name="fillIn">Fill In or Out?</param> /// <param name="duration">The Amount of time in seconds the filling will take</param> /// <param name="manageActive">If true the gameobject is activated or deactivated automatically</param> /// <param name="finished">Callback for when the Fading is finished</param> /// <param name="progressMapping">Function for mapping the progress, takes one float argument between 0 and 1 and should return a float between 0 and 1</param> /// <returns></returns> public static Coroutine Fill(this Image img, bool fillIn, float duration, bool manageActive, Func <float, float> progressMapping, Action finished = null) { if (manageActive && fillIn) { img.gameObject.SetActive(true); } CoroutineHost.StopTrackedCoroutine(img, COROUTINE_TAG); return(CoroutineHost.StartTrackedCoroutine(FillImage(img, fillIn, duration, img.fillMethod, img.fillClockwise, manageActive && !fillIn, finished, progressMapping), img, COROUTINE_TAG)); }
public static void Start(IEnumerator routine) { if (host == null) { host = new GameObject("Coroutine Host").AddComponent <CoroutineHost>(); Object.DontDestroyOnLoad(host); } host.StartCoroutine(routine); }
/// <summary> /// Fills an Image and sets it type to fill if it is not yet fill /// </summary> /// <param name="img">The Image to fill</param> /// <param name="fillIn">Fill In or Out?</param> /// <param name="duration">The Amount of time in seconds the filling will take</param> /// <param name="manageActive">If true the gameobject is activated or deactivated automatically</param> /// <param name="method">The Fill Method</param> /// <param name="clockwise">Fill clockwise?</param> /// <param name="finished">Callback for when the Fading is finished</param> /// <returns></returns> public static Coroutine Fill(this Image img, bool fillIn, float duration, bool manageActive, Image.FillMethod method, bool clockwise, Action finished = null) { if (manageActive && fillIn) { img.gameObject.SetActive(true); } CoroutineHost.StopTrackedCoroutine(img, COROUTINE_TAG); return(CoroutineHost.StartTrackedCoroutine(FillImage(img, fillIn, duration, method, clockwise, manageActive && !fillIn, finished, null), img, COROUTINE_TAG)); }
/// <summary> /// Fades a Canvas Group in or out /// </summary> /// <param name="group">The Group to fade</param> /// <param name="fadeIn">Fade In?</param> /// <param name="duration">Amount of seconds the fading should take</param> /// <param name="manageActive">If true the gameobject is activated or deactivated automatically</param> /// <param name="progressMapping">Function for mapping the progress, takes one float argument between 0 and 1 and should return a float between 0 and 1</param> /// <param name="finished">Callback for when the Fading is finished</param> /// <returns></returns> public static Coroutine Fade(this CanvasGroup group, bool fadeIn, float duration, bool manageActive, Func <float, float> progressMapping, Action finished = null) { if (manageActive && fadeIn) { group.gameObject.SetActive(true); } CoroutineHost.StopTrackedCoroutine(group, COROUTINE_TAG); return(CoroutineHost.StartTrackedCoroutine(FadeCanvasGroup(group, fadeIn, duration, manageActive && !fadeIn, finished, progressMapping), group, COROUTINE_TAG)); }