void Start() { if (!Builder.prefab || CraftData.GetTechType(Builder.prefab) != FloatingCargoCrate.TechType) // don't play animation for ghost model { animFixer = new AnimFixer(gameObject.getChild("3rd_person_model/floating_storage_cube_tp")); } }
public static void AddEnergyTool(EnergyMixin __instance, ref float amount) { // Acid Battery is not chargeable by any method (e.g. Swim Charge Fins) if (!Config.NORMAL.Equals(DeathRun.config.batteryCosts)) { var batt = __instance.GetBattery(); if (batt != null) { TechType t = CraftData.GetTechType(batt); if (t == AcidBatteryCellBase.BatteryID) { amount = 0; return; } } } if (isTransformInRadiation(Player.main.transform)) { if (Config.DEATHRUN.Equals(DeathRun.config.powerCosts) || Config.EXORBITANT.Equals(DeathRun.config.powerCosts)) { amount /= 4; } else if (Config.HARD.Equals(DeathRun.config.powerCosts)) { amount /= 2; } } else if (Config.DEATHRUN.Equals(DeathRun.config.powerCosts) || Config.EXORBITANT.Equals(DeathRun.config.powerCosts)) { amount /= 2; } }
public static bool InterceptTrace(GameObject ignoreObj, float maxDist, ref GameObject closestObj, ref Vector3 position, out Vector3 normal, bool includeUseableTriggers = true) { bool result = UWE.Utils.TraceFPSTargetPosition(ignoreObj, maxDist, ref closestObj, ref position, out normal, includeUseableTriggers); TechType key = (closestObj != null ? CraftData.GetTechType(closestObj) : TechType.None); if (key == TechType.None) { return(result); } if (_MakeHarvestables.TryGetValue(key, out float value)) { Log.LogDebug($"InterceptTrace found closestObj with TechType {key}"); LiveMixin component = closestObj.EnsureComponent <LiveMixin>(); if (component.data == null) { Log.LogDebug($"Adding LiveMixin data to object {closestObj.GetInstanceID()} with TechType {key}", null, true); component.data = new LiveMixinData(); component.data.maxHealth = value; component.health = value; } } return(result); }
private void OnVehiclePrefabLoaded(GameObject prefab, string guid, Vector3 spawnPosition, Quaternion spawnRotation, Optional <List <InteractiveChildObjectIdentifier> > interactiveChildIdentifiers, Optional <string> dockingBayGuid) { // Partially copied from SubConsoleCommand.OnSubPrefabLoaded GameObject gameObject = Utils.SpawnPrefabAt(prefab, null, spawnPosition); gameObject.transform.rotation = spawnRotation; gameObject.SetActive(true); gameObject.SendMessage("StartConstruction", SendMessageOptions.DontRequireReceiver); CrafterLogic.NotifyCraftEnd(gameObject, CraftData.GetTechType(gameObject)); Rigidbody rigidBody = gameObject.GetComponent <Rigidbody>(); rigidBody.isKinematic = false; GuidHelper.SetNewGuid(gameObject, guid); if (interactiveChildIdentifiers.IsPresent()) { VehicleChildObjectIdentifierHelper.SetInteractiveChildrenGuids(gameObject, interactiveChildIdentifiers.Get()); //Copy From ConstructorBeginCraftingProcessor } if (dockingBayGuid.IsPresent()) { GameObject dockingBayBase = GuidHelper.RequireObjectFrom(dockingBayGuid.Get()); VehicleDockingBay dockingBay = dockingBayBase.GetComponentInChildren <VehicleDockingBay>(); Vehicle vehicle = gameObject.GetComponent <Vehicle>(); dockingBay.DockVehicle(vehicle); } }
internal void RaycastMode_Update() { HandReticle.main.SetIcon(HandReticle.IconType.Scan); //Transform aimTransform = Player.main.camRoot.GetAimingTransform(); //if (Physics.Raycast(aimTransform.position, aimTransform.forward, out RaycastHit hitInfo, 15, 3)) if (Targeting.GetTarget(Player.main.gameObject, 10f, out GameObject target, out float distance)) { TechType techType = CraftData.GetTechType(target); //if (Targeting.GetRoot(target, out TechType techType, out GameObject root)) //{ //HandReticle.main.SetText(HandReticle.TextType.Hand, hitInfo.transform.name, false); HandReticle.main.SetText(HandReticle.TextType.Hand, $"Target: {target.name}\nTechType: {techType}\ndistance: {distance:F1} m", false); HandReticle.main.SetText(HandReticle.TextType.HandSubscript, handSubScript, false, GameInput.Button.RightHand); if (Input.GetMouseButton(1)) { //OnBaseObjectChange(hitInfo.transform.gameObject); OnBaseObjectChange(target); isRayEnabled = false; OutputWindow_Log(MESSAGE_TEXT[MESSAGES.RAYCAST_STATE], isRayEnabled); } //} } }
public static void PostAwake(ref PlayerTool __instance) { if (__instance is Knife) { TechType itemTechType = CraftData.GetTechType(__instance.gameObject); if (itemTechType == TechType.None) { return; // We can't do much without this. } Knife knife = __instance as Knife; float damage; float spikeyTrapDamage; if (itemTechType == TechType.HeatBlade) { damage = Main.config.HeatbladeDamage; spikeyTrapDamage = Main.config.HeatbladeTentacleDamage; } else { damage = Main.config.KnifeDamage; spikeyTrapDamage = Main.config.KnifeTentacleDamage; } knife.damage = damage; knife.bleederDamage = damage; knife.spikeyTrapDamage = spikeyTrapDamage; } }
private void OnVehiclePrefabLoaded(GameObject prefab, string guid, Optional <string> modulesEquipmentGuid, Vector3 spawnPosition, Quaternion spawnRotation, List <InteractiveChildObjectIdentifier> interactiveChildIdentifiers) { // Partially copied from SubConsoleCommand.OnSubPrefabLoaded GameObject gameObject = Utils.SpawnPrefabAt(prefab, null, spawnPosition); gameObject.transform.rotation = spawnRotation; gameObject.SetActive(true); gameObject.SendMessage("StartConstruction", SendMessageOptions.DontRequireReceiver); CrafterLogic.NotifyCraftEnd(gameObject, CraftData.GetTechType(gameObject)); Rigidbody rigidBody = gameObject.GetComponent <Rigidbody>(); rigidBody.isKinematic = false; GuidHelper.SetNewGuid(gameObject, guid); SetInteractiveChildrenGuids(gameObject, interactiveChildIdentifiers); //Copy From ConstructorBeginCraftingProcessor SubRoot subRoot = gameObject.GetComponent <SubRoot>(); if (subRoot != null) { if (modulesEquipmentGuid.IsPresent()) { GuidHelper.SetNewGuid(subRoot.upgradeConsole.modules.owner, modulesEquipmentGuid.Get()); Log.Info("Cyclop Modules Guid: " + GuidHelper.GetGuid(subRoot.upgradeConsole.modules.owner)); } else { Log.Info("Error Cyclop Modules Guid Missing Cyclop Guid: " + GuidHelper.GetGuid(subRoot.gameObject)); } } }
public static bool Prefix(ref GameObject go, ref bool __result) { TechType techType = CraftData.GetTechType(go); // make a variable and store the Damage.acidImmune content into a List var acidImmune = DamageSystem.acidImmune == null ? new List <TechType>() : DamageSystem.acidImmune.ToList(); // if the list doesn't have TechType.Seamoth if (!acidImmune.Contains(TechType.Seamoth)) { // Add TechType.Seamoth to the list acidImmune.Add(TechType.Seamoth); } if (techType != TechType.None) { for (int i = 0; i < DamageSystem.acidImmune.Length; i++) { if (techType == DamageSystem.acidImmune[i]) { __result = true; return(false); } DamageSystem.acidImmune = acidImmune.ToArray(); // Adding our list content into the original Array } } __result = false; return(true); }
private void Awake() { if (this.techType == TechType.None) { this.techType = CraftData.GetTechType(base.gameObject); } this.oxygen = base.GetComponent <Oxygen>(); if (this.oxygen == null) { Log.LogDebug($"CustomOxy: Failed to find Oxygen component in parent"); return; } if (this.oxygen.isPlayer) { return; } if (Main.config.GetCapacityOverride(this.techType, out float capacityOverride, out float capacityMultiplier)) { bool bIsManual = Main.config.bManualRefill; Log.LogDebug($"CustomiseOxygen.Main.GetCapacityOverride returned true with values of capacityOverride={capacityOverride}, capacityMultiplier={capacityMultiplier}"); if (capacityOverride > 0) { this.oxygen.oxygenCapacity = capacityOverride; } else { Main.config.SetCapacityOverride(this.techType, this.oxygen.oxygenCapacity, false, true); this.oxygen.oxygenCapacity *= capacityMultiplier; } Log.LogDebug($"CustomOxy.Awake(): Oxygen capacity set to {this.oxygen.oxygenCapacity}"); } }
public static bool Use(GameObject useObj, ref bool __result) { if (useObj != null) { var techType = CraftData.GetTechType(useObj); if (techType == TechType.FirstAidKit) { var heal = GameModeUtilsPatches.currentConfig.Health.FirstAidKitHeal; if (Player.main.GetComponent <LiveMixin>().AddHealth(heal) > 0.1f) { __result = true; } else { ErrorMessage.AddMessage(Language.main.Get("HealthFull")); __result = false; } return(false); } } return(true); }
public static bool BatteryCheck(Pickupable pickupable) { var energyMixin = pickupable.gameObject.GetComponentInChildren <EnergyMixin>(); if (energyMixin != null) { var gameObject = #if !BZ energyMixin.GetBattery(); #else energyMixin.GetBatteryGameObject(); #endif if (gameObject != null && energyMixin.defaultBattery == CraftData.GetTechType(gameObject)) { var battery = gameObject.GetComponent <IBattery>(); return(Math.Abs(battery.capacity - battery.charge) < 0.001f); } else if (gameObject == null && QModManager.API.QModServices.Main.ModPresent("NoBattery")) { return(true); } return(false); } var b2 = pickupable.GetComponent <IBattery>(); return(b2 == null || Math.Abs(b2.capacity - b2.charge) < 0.001f); }
public static void Postfix(Survival __instance, GameObject useObj, bool __result) { if (__result && (useObj != null)) { TechType techType = CraftData.GetTechType(useObj); if ((techType == TechType.Boomerang) || (techType == TechType.LavaBoomerang)) { NitrogenLevel nitrogenLevel = Player.main.gameObject.GetComponent <NitrogenLevel>(); if (DeathRun.saveData.nitroSave.safeDepth > 10f) { DeathRun.saveData.nitroSave.safeDepth /= 2; if (Time.time - ticksNotice > 60) { ticksNotice = Time.time; ErrorMessage.AddMessage("The tasty raw Boomerang helps purge Nitrogen from your bloodstream!"); } if (DeathRun.saveData.nitroSave.safeDepth < 10f) { nitrogenLevel.nitrogenLevel = DeathRun.saveData.nitroSave.safeDepth * 10; } } else { nitrogenLevel.nitrogenLevel = 0; } } } }
static public void ChangeConstructionAmount(Constructable target, bool constructing) { if (Multiplayer.main.blocked) { return; } if (buildConstructActive) { return; } var res = new ClientBuildConstructChange(); res.objectGuid = GuidHelper.Get(target.gameObject); res.baseGuid = GuidHelper.Get(GetNewBase()); res.moduleGuid = GuidHelper.Get(GetNewModule()); res.tech = CraftData.GetTechType(target.gameObject); res.objectPosition = target.gameObject.transform.position; res.amount = target.constructedAmount; res.state = target.constructed; res.constructing = constructing; if (res.amount == 0f && constructing) { return; } if (res.state || (res.amount == 0f && !constructing) || (res.amount == 1f && constructing) || rateLimiter.Update(0.500f)) { Multiplayer.main.Send(res); } }
public static void Postfix(Constructable __instance) { if (__instance.constructed) { CoroutineHost.StartCoroutine(InitializeBuilder(CraftData.GetTechType(__instance.gameObject))); } }
void UpdateActiveTarget() { if (GetLastDockedOnMapRoom().storageContainer.container.GetCount(Main.pickupModule.TechType) > 0) { Targeting.GetTarget(gameObject, 7f, out GameObject target, out float distance, null); var root = UWE.Utils.GetEntityRoot(target); root = root != null ? root : target; if (root.GetComponentProfiled <Pickupable>() is not null && CraftData.GetTechType(root) != TechType.MapRoomCamera) { target = root; } else { target = null; } _activeTarget = target; var guiHand = Player.main.GetComponent <GUIHand>(); if (_activeTarget is not null) { GUIHand.Send(_activeTarget, HandTargetEventType.Hover, guiHand); } }
private void GiveResourceOnDamage(GameObject target, bool isAlive, bool wasAlive) { TechType techType = CraftData.GetTechType(target); HarvestType harvestTypeFromTech = CraftData.GetHarvestTypeFromTech(techType); if (techType == TechType.Creepvine) { GoalManager.main.OnCustomGoalEvent("Cut_Creepvine"); } if ((harvestTypeFromTech == HarvestType.DamageAlive && wasAlive) || (harvestTypeFromTech == HarvestType.DamageDead && !isAlive)) { int num = 1; if (harvestTypeFromTech == HarvestType.DamageAlive && !isAlive) { num += CraftData.GetHarvestFinalCutBonus(techType); } TechType harvestOutputData = CraftData.GetHarvestOutputData(techType); if (harvestOutputData != TechType.None) { CraftData.AddToInventory(harvestOutputData, num, false, false); } } }
private static void Postfix(Creature __instance) { TechType techType = CraftData.GetTechType(__instance.gameObject); if (techType == TechType.Rockgrub) { // Add Pickupable component to the original fish Pickupable pickupable = __instance.gameObject.EnsureComponent <Pickupable>(); pickupable.isPickupable = true; pickupable.randomizeRotationWhenDropped = true; // Add WaterParkCreature component to the original fish __instance.gameObject.EnsureComponent <WaterParkCreature>().pickupable = pickupable; // Add Eatable component to the original fish Eatable eatable = __instance.gameObject.EnsureComponent <Eatable>(); eatable.foodValue = 10f; eatable.waterValue = 4f; // Clone the original fish and remove the extra Components from it GameObject obj = Object.Instantiate(__instance.gameObject); foreach (var component in obj.GetComponents <Component>()) { Object.Destroy(component); } // Add AquariumFish component to the original fish AquariumFish aquariumFish = __instance.gameObject.EnsureComponent <AquariumFish>(); aquariumFish.model = obj; // Set the Object inactive cause yes obj.SetActive(false); } }
private static void SurvivalPatchings(IDictionary <TechType, List <Action> > dictionary, GameObject obj, ref bool result) { TechType tt = CraftData.GetTechType(obj); if (dictionary.TryGetValue(tt, out List <Action> action)) { action.ForEach((x) => x.Invoke()); result = true; } if (result) { #if SUBNAUTICA #pragma warning disable CS0618 // Type or member is obsolete and yet IS still used by Subnautica itself. string sound = CraftData.GetUseEatSound(tt); if (!string.IsNullOrEmpty(sound)) { FMODUWE.PlayOneShot(sound, Player.main.transform.position); // only play the sound if its useable } #pragma warning restore CS0618 #elif BELOWZERO FMODAsset asset = Player.main.GetUseSound(TechData.GetSoundType(tt)); if (asset != null) { FMODUWE.PlayOneShot(asset, Player.main.transform.position); // only play the sound if its useable } #endif } }
public static bool Prefix(ref Knife __instance, GUIHand hand) { if (!Config.NONVIOLENT.Equals(DeathRun.config.nonViolent)) { return(true); } Vector3 position = default(Vector3); GameObject gameObject = null; UWE.Utils.TraceFPSTargetPosition(Player.main.gameObject, __instance.attackDist, ref gameObject, ref position, true); if (gameObject == null) { InteractionVolumeUser component = Player.main.gameObject.GetComponent <InteractionVolumeUser>(); if (component != null && component.GetMostRecent() != null) { gameObject = component.GetMostRecent().gameObject; } } if (gameObject) { LiveMixin liveMixin = gameObject.FindAncestor <LiveMixin>(); if (Knife.IsValidTarget(liveMixin)) { if (liveMixin) { bool wasAlive = liveMixin.IsAlive(); TechType t = CraftData.GetTechType(gameObject); if ((t == TechType.GenericJeweledDisk) || (t == TechType.BlueJeweledDisk) || (t == TechType.GreenJeweledDisk) || (t == TechType.PurpleJeweledDisk) || (t == TechType.RedJeweledDisk)) { liveMixin.TakeDamage(__instance.damage, position, __instance.damageType, null); } __instance.GiveResourceOnDamage(gameObject, liveMixin.IsAlive(), wasAlive); } global::Utils.PlayFMODAsset(__instance.attackSound, __instance.transform, 20f); //VFXSurface component2 = gameObject.GetComponent<VFXSurface>(); //Vector3 euler = MainCameraControl.main.transform.eulerAngles + new Vector3(300f, 90f, 0f); //VFXSurfaceTypeManager.main.Play(component2, __instance.vfxEventType, position, Quaternion.Euler(euler), Player.main.transform); } else { gameObject = null; } } if (gameObject == null && hand.GetActiveTarget() == null) { if (Player.main.IsUnderwater()) { global::Utils.PlayFMODAsset(__instance.underwaterMissSound, __instance.transform, 20f); return(false); } global::Utils.PlayFMODAsset(__instance.surfaceMissSound, __instance.transform, 20f); } return(false); }
public static void Prefix(VFXConstructing __instance) { if (CraftData.GetTechType(__instance.gameObject) != MainPatch.sharkTech) { return; } __instance.wireColor = col; }
public static void Postfix(ref bool __result) { if (Main.config.Hardcore && __result && Builder.prefab != null) { TechType techType = CraftData.GetTechType(Builder.prefab); __result = CrafterLogic.IsCraftRecipeUnlocked(techType); } }
static bool Prefix(ResourceTracker __instance) { if (Enumerable.Range(70, 15).Contains((int)CraftData.GetTechType(__instance.gameObject))) { __instance.overrideTechType = TechType.None; } return(true); }
public static void Postfix(BaseSpotLight __instance) { TechType techType = CraftData.GetTechType(__instance.gameObject); if (techType == TechType.Spotlight) { __instance.gameObject.EnsureComponent <ColoringController>(); } }
public static bool GiveResourceOnDamage(ref GameObject target) { if (!GetPreventPickup(target.transform)) { return(true); } return(!IsPlant(CraftData.GetTechType(target))); }
static void StartPostfix(Creature __instance) { var techType = CraftData.GetTechType(__instance.gameObject); if (techType == TechType.Spadefish) { __instance.gameObject.GetComponent <Rigidbody>().mass = 2.5f; } }
private void OnRemoveItem(string slot, InventoryItem item) { if (CraftData.GetTechType(item.item.gameObject) == SeatruckBuilderModulePrefab.TechTypeID) { Instance.enabled = false; moduleSlotID = -1; OnDisable(); } }
private static void StartPostfix(WaterParkCreature __instance) { if (CraftData.GetTechType(__instance.gameObject) != TechType.Rockgrub) { return; } __instance.gameObject.EnsureComponent <Pickupable>().isPickupable = true; }
public static bool GiveResourceOnDamage(ref GameObject target) { if (!GetPreventPickup(target.transform)) // If island isn't radiative, return without cancelling { return(true); } return(!IsPlant(CraftData.GetTechType(target))); }
public static void Postfix(VFXConstructing __instance) { if (CraftData.GetTechType(__instance.gameObject) != MainPatch.sharkTech) { return; } __instance.ghostMaterial = new Material(__instance.ghostMaterial); __instance.ghostOverlay.material = __instance.ghostMaterial; __instance.ghostMaterial.color = col; }
public static void Prefix(BreakableResource __instance) { TechType Breakable = CraftData.GetTechType(__instance.gameObject); if (prefabs.TryGetValue(Breakable, out List <BreakableResource.RandomPrefab> randomPrefabs)) { __instance.prefabList = randomPrefabs; return; } }