private static float fActiveModeHealthRegenMultiplier = 5f; // Health regeneration is multiplied by this amount in active mode protected void Start() { string RCFilename; if (thermalReactorCharge is null && PrefabDatabase.TryGetPrefabFilename(CraftData.GetClassIdForTechType(TechType.Exosuit), out RCFilename)) { AddressablesUtility.LoadAsync <GameObject>(RCFilename).Completed += (x) => { GameObject gameObject1 = x.Result; Exosuit exosuit = gameObject1?.GetComponent <Exosuit>(); thermalReactorCharge = exosuit?.thermalReactorCharge; }; } if (sonarSound is null && PrefabDatabase.TryGetPrefabFilename(CraftData.GetClassIdForTechType(TechType.Seamoth), out RCFilename)) { AddressablesUtility.LoadAsync <GameObject>(RCFilename).Completed += (x) => { GameObject gameObject1 = x.Result; SeaMoth seamoth = gameObject1?.GetComponent <SeaMoth>(); if (seamoth?.sonarSound != null) { sonarSound = this.gameObject.AddComponent <FMOD_CustomEmitter>(); sonarSound.SetAsset(seamoth.sonarSound.asset); sonarSound.UpdateEventAttributes(); } foreach (var r in gameObject1.GetComponentsInChildren <Renderer>()) { } }; } }
private static IEnumerator AddbrokenRestoPlayerInv(BreakableResource __instance, AssetReferenceGameObject gameObject) { CoroutineTask <GameObject> task = AddressablesUtility.InstantiateAsync(gameObject.RuntimeKey as string); yield return(task); GameObject prefab = task.GetResult(); var pickupable = prefab.GetComponent <Pickupable>(); pickupable.Initialize(); CraftData.AddToInventory(pickupable.GetTechType()); yield break; }
static IEnumerator _startGame() { Physics.autoSyncTransforms = Physics2D.autoSimulation = false; #if BRANCH_STABLE && GAME_SN yield return(SceneManager.LoadSceneAsync("Essentials", LoadSceneMode.Additive)); #else yield return(AddressablesUtility.LoadSceneAsync("Essentials", LoadSceneMode.Additive)); #endif Application.backgroundLoadingPriority = ThreadPriority.Normal; foreach (var cmd in Main.config.dbg.fastStart.commandsAfterLoad) { DevConsole.SendConsoleCommand(cmd); } }
protected void Start() { #pragma warning disable CS0612 // Type or member is obsolete if (repulsionCannonFireSound is null && PrefabDatabase.TryGetPrefabFilename(CraftData.GetClassIdForTechType(TechType.RepulsionCannon), out var RCFilename)) { AddressablesUtility.LoadAsync <GameObject>(RCFilename).Completed += (x) => { var gameObject1 = x.Result; var component = gameObject1?.GetComponent <RepulsionCannon>(); repulsionCannonFireSound = component?.shootSound; }; } if ((stasisRifleFireSound is null || stasisRifleEvent is null) && PrefabDatabase.TryGetPrefabFilename(CraftData.GetClassIdForTechType(TechType.StasisRifle), out var SRFilename)) { AddressablesUtility.LoadAsync <GameObject>(SRFilename).Completed += (x) => { var gameObject2 = x.Result; var component2 = gameObject2?.GetComponent <StasisRifle>(); stasisRifleFireSound = component2?.fireSound; stasisRifleEvent = component2?.chargeBegin; }; } if (modeChangeSound is null && PrefabDatabase.TryGetPrefabFilename(CraftData.GetClassIdForTechType(TechType.PropulsionCannon), out var PCFilename)) { AddressablesUtility.LoadAsync <GameObject>(PCFilename).Completed += (x) => { var gameObject3 = x.Result; var component3 = gameObject3?.GetComponent <PropulsionCannon>(); modeChangeSound = component3?.shootSound; }; } if (laserShootSound is null && PrefabDatabase.TryGetPrefabFilename(CraftData.GetClassIdForTechType(TechType.Welder), out var WFilename)) { AddressablesUtility.LoadAsync <GameObject>(WFilename).Completed += (x) => { var gameObject4 = x.Result; var component4 = gameObject4?.GetComponent <Welder>(); laserShootSound = component4?.weldSound; }; } #pragma warning restore CS0612 // Type or member is obsolete laserEndParticleSystem = LaserParticles.transform.Find("Laserend").gameObject.GetComponent <ParticleSystem>(); scaleParticleSystem = LaserParticles.transform.Find("scale").GetComponent <ParticleSystem>(); }
public IEnumerator Samples_GetAddressFromAssetReference_ReturnsCorrectAddress() { var savedImpl = UnityEngine.AddressableAssets.Addressables.m_AddressablesInstance; UnityEngine.AddressableAssets.Addressables.m_AddressablesInstance = m_Addressables; AsyncOperationHandle assetReferenceHandle = m_Addressables.InstantiateAsync(m_AssetReferenceObjectKey); yield return(assetReferenceHandle); Assert.IsNotNull(assetReferenceHandle.Result as GameObject); AssetReferenceTestBehavior behavior = (assetReferenceHandle.Result as GameObject).GetComponent <AssetReferenceTestBehavior>(); string returnedAddress = AddressablesUtility.GetAddressFromAssetReference(behavior.Reference); Assert.AreEqual(behavior.AssetReferenceAddress, returnedAddress); m_Addressables.Release(assetReferenceHandle); UnityEngine.AddressableAssets.Addressables.m_AddressablesInstance = savedImpl; }
private static IEnumerator AddtoPrawn(BreakableResource __instance, Exosuit exosuit, AssetReferenceGameObject gameObject) { CoroutineTask <GameObject> task = AddressablesUtility.InstantiateAsync(gameObject.RuntimeKey as string); yield return(task); GameObject prefab = task.GetResult(); var pickupable = prefab.GetComponent <Pickupable>(); pickupable.Initialize(); var item = new InventoryItem(pickupable); exosuit.storageContainer.container.UnsafeAdd(item); string name = Language.main.GetOrFallback(pickupable.GetTechType().AsString(), pickupable.GetTechType().AsString()); ErrorMessage.AddMessage(Language.main.GetFormat("VehicleAddedToStorage", name)); uGUI_IconNotifier.main.Play(pickupable.GetTechType(), uGUI_IconNotifier.AnimationType.From, null); pickupable.PlayPickupSound(); yield break; }
/* * public override IEnumerator GetGameObjectAsync(IOut<GameObject> gameObject) * { * AsyncOperationHandle<GameObject> seatruckFabricatorModuleRequest = AddressablesUtility.LoadAsync<GameObject>("WorldEntities/Tools/SeaTruckFabricatorModule.prefab"); * yield return seatruckFabricatorModuleRequest; * GameObject seatruckFabricatorModulePrefab = seatruckFabricatorModuleRequest.Result; * * _GameObject = UWE.Utils.InstantiateDeactivated(seatruckFabricatorModulePrefab); * * _GameObject.SetActive(true); * * gameObject.Set(_GameObject); * } */ public override IEnumerator GetGameObjectAsync(IOut <GameObject> gameObject) { AsyncOperationHandle <GameObject> loadRequest_01 = AddressablesUtility.LoadAsync <GameObject>("WorldEntities/Tools/SeaTruckFabricatorModule.prefab"); yield return(loadRequest_01); if (loadRequest_01.Status == AsyncOperationStatus.Failed) { BZLogger.Error("Cannot find GameObject in Resources folder at path 'WorldEntities/Tools/SeaTruckFabricatorModule.prefab'"); yield break; } GameObject seatruckFabricatorModulePrefab = loadRequest_01.Result; GameObjectClone = UWE.Utils.InstantiateDeactivated(seatruckFabricatorModulePrefab, null, Vector3.zero, Quaternion.identity); SetupScannerModule(); /* * IAssetBundleWrapperCreateRequest bundleRequest = AssetBundleManager.LoadBundleAsync("basegeneratorpieces"); * yield return bundleRequest; * IAssetBundleWrapper bundle = bundleRequest.assetBundle; * IAssetBundleWrapperRequest loadRequest_02 = bundle.LoadAssetAsync<GameObject>("Assets/Prefabs/Base/GeneratorPieces/BaseMapRoom.prefab"); * yield return loadRequest_02; * GameObject maproom = loadRequest_02.asset as GameObject; */ AsyncOperationHandle <GameObject> loadRequest_02 = AddressablesUtility.LoadAsync <GameObject>("Assets/Prefabs/Base/GeneratorPieces/BaseMapRoom.prefab"); yield return(loadRequest_02); if (loadRequest_02.Status == AsyncOperationStatus.Failed) { BZLogger.Error("Cannot find Prefab at path 'Assets/Prefabs/Base/GeneratorPieces/BaseMapRoom.prefab'"); yield break; } GameObject maproom = loadRequest_02.Result; if (!maproom) { BZLogger.Debug("Failed to load MapRoom prefab!"); yield break; } antenna = UWE.Utils.InstantiateDeactivated(maproom.transform.Find("Map_room_antenna").gameObject, GameObjectClone.transform, Vector3.zero, Quaternion.identity); AsyncOperationHandle <GameObject> loadRequest_03 = AddressablesUtility.LoadAsync <GameObject>("Submarine/Build/BatteryCharger.prefab"); yield return(loadRequest_03); GameObject batteryChargerPrefab = loadRequest_03.Result; GameObject powerSystemRoot = new GameObject("powerSystemRoot"); powerSystemRoot.transform.SetParent(GameObjectClone.transform); powerSystemRoot.transform.localPosition = new Vector3(-1.06f, -0.20f, 1.66f); powerSystemRoot.transform.localRotation = Quaternion.Euler(0, 270, 180); powerSystemRoot.transform.localScale = new Vector3(1.78f, 1.78f, 1.0f); powerSystem = UWE.Utils.InstantiateDeactivated(batteryChargerPrefab, powerSystemRoot.transform, Vector3.zero, Quaternion.identity); AsyncOperationHandle <GameObject> loadRequest_04 = AddressablesUtility.LoadAsync <GameObject>("Submarine/Build/MapRoomFunctionality.prefab"); yield return(loadRequest_04); GameObject mapRoomFunctionalityPrefab = loadRequest_04.Result; scannerUIRoot = new GameObject("scannerRoot"); scannerUIRoot.transform.SetParent(GameObjectClone.transform, false); scannerUIRoot.transform.localScale = new Vector3(1.14f, 1.14f, 1.14f); scannerUIRoot.transform.localPosition = new Vector3(1.37f, 0.07f, 1.60f); scannerUIRoot.transform.localRotation = Quaternion.Euler(0, 90, 0); scannerUI = UWE.Utils.InstantiateDeactivated(mapRoomFunctionalityPrefab.transform.Find("screen/scannerUI").gameObject, scannerUIRoot.transform, Vector3.zero, Quaternion.identity); SetupAntenna(); SetupScannerUI(); SetupPowerSystem(); GameObjectClone.AddComponent <SeaTruckSegmentListener>(); gameObject.Set(GameObjectClone); yield break; }