public void OnPickup() { SeamothArmManager control = ThisSeamoth.GetComponent <SeamothArmManager>(); GameObject activeTarget = control.GetActiveTarget(); if (activeTarget) { Pickupable pickupable = activeTarget.GetComponent <Pickupable>(); PickPrefab component = activeTarget.GetComponent <PickPrefab>(); ItemsContainer container = control.GetRoomForItem(pickupable); if (pickupable != null && pickupable.isPickupable && container != null) { pickupable = pickupable.Initialize(); InventoryItem item = new InventoryItem(pickupable); container.UnsafeAdd(item); Utils.PlayFMODAsset(pickupSound, front, 5f); } else if (component != null && component.AddToContainer(container)) { component.SetPickedUp(); } } }
public static bool HandleItemPickup(ref PickPrefab __instance) { if (!GetPreventPickup(__instance.transform)) // If not radiative { return(true); } return(!IsPlant(__instance.pickTech)); }
public void OnPickup() { GameObject activeTarget = ArmServices.main.GetActiveTarget(TruckHelper.MainCab); if (activeTarget) { Pickupable pickupable = activeTarget.GetComponent <Pickupable>(); PickPrefab pickPrefab = activeTarget.GetComponent <PickPrefab>(); StartCoroutine(OnPickupAsync(pickupable, pickPrefab)); } }
private bool TryUse(out float cooldownDuration) { if (Time.time - timeUsed >= cooldownTime) { Pickupable pickupable = null; PickPrefab x = null; GameObject activeTarget = ArmServices.main.GetActiveTarget(TruckHelper.MainCab); if (activeTarget) { pickupable = activeTarget.GetComponent <Pickupable>(); x = activeTarget.GetComponent <PickPrefab>(); } if (pickupable != null && pickupable.isPickupable) { if (TruckHelper.HasRoomForItem(pickupable)) { animator.SetTrigger("use_tool"); cooldownTime = (cooldownDuration = cooldownPickup); shownNoRoomNotification = false; return(true); } if (!shownNoRoomNotification) { ErrorMessage.AddDebug(Language.main.Get("ContainerCantFit")); shownNoRoomNotification = true; } } else { if (x != null) { animator.SetTrigger("use_tool"); cooldownTime = (cooldownDuration = cooldownPickup); return(true); } animator.SetTrigger("bash"); cooldownTime = (cooldownDuration = cooldownPunch); fxControl.Play(0); return(true); } } cooldownDuration = 0f; return(false); }
public static bool ShootObject(ref Rigidbody rb) { if (!GetPreventPickup(rb.transform)) // If not radiative { return(true); } PickPrefab prefab = rb.GetComponent <PickPrefab>(); if (prefab == null) { return(true); } return(!IsPlant(prefab.pickTech)); }
void OnPickup(Pickupable pickupable, PickPrefab component) { if (pickupable != null && pickupable.isPickupable && GetStorageContainer(pickupable).HasRoomFor(pickupable)) { pickupable = pickupable.Initialize(); InventoryItem item = new InventoryItem(pickupable); GetStorageContainer(pickupable).UnsafeAdd(item); global::Utils.PlayFMODAsset(pickupSound, this.front, 5f); } else if (component != null && component.AddToContainer(GetStorageContainer(pickupable))) { component.SetPickedUp(); } this.cooldownTime = Time.time + cooldownPickup; }
public static bool ValidateObject(ref GameObject go, ref bool __result) { if (!GetPreventPickup(go.transform)) // If not radiative { return(true); } PickPrefab prefab = go.GetComponent <PickPrefab>(); if (prefab == null) { return(true); } // If it returns false, then it will cancel the method and prevent them from using it return(__result = !IsPlant(prefab.pickTech)); }
public static bool Prefix(ExosuitClawArm __instance) { Exosuit componentInParent = __instance.GetComponentInParent <Exosuit>(); if (componentInParent.GetActiveTarget()) { Pickupable pickupable = componentInParent.GetActiveTarget().GetComponent <Pickupable>(); PickPrefab component = componentInParent.GetActiveTarget().GetComponent <PickPrefab>(); if (pickupable != null && pickupable.isPickupable && componentInParent.storageContainer.container.HasRoomFor(pickupable)) { NitroxServiceLocator.LocateService <Item>().PickedUp(pickupable.gameObject, pickupable.GetTechType()); } else if (component != null) { Log.Debug("Delete Pickprefab for exosuit claw arm"); NitroxServiceLocator.LocateService <Item>().PickedUp(component.gameObject, component.pickTech); } } return(true); }
void TryUse() { Pickupable pickupable = null; PickPrefab component = null; var pos = Vector3.zero; var hitObject = default(GameObject); UWE.Utils.TraceFPSTargetPosition(seamoth.gameObject, 6f, ref hitObject, ref pos, true); if (hitObject) { pickupable = hitObject.FindAncestor <Pickupable>(); component = hitObject.FindAncestor <PickPrefab>(); } if (pickupable != null && pickupable.isPickupable) { if (GetStorageContainer(pickupable) != null) { this.animator.SetTrigger("use_tool"); OnPickup(pickupable, component); } else { ErrorMessage.AddMessage(Language.main.Get("ContainerCantFit")); } } else { if (component != null) { this.animator.SetTrigger("use_tool"); OnPickup(pickupable, component); } this.animator.SetTrigger("bash"); this.fxControl.Play(0); OnHit(); } }
private IEnumerator OnPickupAsync(Pickupable pickupable, PickPrefab pickPrefab) { ItemsContainer container = TruckHelper.GetRoomForItem(pickupable); if (pickupable != null && pickupable.isPickupable && container != null) { pickupable.Initialize(); InventoryItem item = new InventoryItem(pickupable); container.UnsafeAdd(item); Utils.PlayFMODAsset(pickupSound, front, 5f); } else if (pickPrefab != null) { TaskResult <bool> result = new TaskResult <bool>(); yield return(pickPrefab.AddToContainerAsync(container, result)); if (result.Get()) { pickPrefab.SetPickedUp(); } result = null; } yield break; }
public void OnPickup() { GameObject activeTarget = Exosuit.GetActiveTarget(); if (activeTarget) { Pickupable pickupable = activeTarget.GetComponent <Pickupable>(); PickPrefab component = activeTarget.GetComponent <PickPrefab>(); bool hasRoomForItem = Exosuit.storageContainer.container.HasRoomFor(pickupable); if (pickupable != null && pickupable.isPickupable && hasRoomForItem) { pickupable = pickupable.Initialize(); InventoryItem item = new InventoryItem(pickupable); Exosuit.storageContainer.container.UnsafeAdd(item); Utils.PlayFMODAsset(pickupSound, front, 5f); } else if (component != null && component.AddToContainer(Exosuit.storageContainer.container)) { component.SetPickedUp(); } } }