public static bool Speedloader_DuplicateFromSpawnLock(Speedloader __instance, ref GameObject __result, FVRViveHand hand) { //unlike MonoMod the base class can technically be retrived, but it's a PitA so again this is copied from FVRPhysicalObject.DuplicateFromSpawnLock GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(__instance.ObjectWrapper.GetGameObject(), __instance.Transform.position, __instance.Transform.rotation); FVRPhysicalObject fvrObj = gameObject.GetComponent <FVRPhysicalObject>(); if (fvrObj is FVREntityProxy) { (fvrObj as FVREntityProxy).Data.PrimeDataLists((fvrObj as FVREntityProxy).Flags); } hand.ForceSetInteractable(fvrObj); fvrObj.SetQuickBeltSlot(null); fvrObj.BeginInteraction(hand); Speedloader component = gameObject.GetComponent <Speedloader>(); for (int i = 0; i < __instance.Chambers.Count; i++) { component.Chambers[i].Type = __instance.Chambers[i].Type; if (__instance.Chambers[i].IsLoaded) { component.Chambers[i].Load(__instance.Chambers[i].LoadedClass, false); } else { component.Chambers[i].Unload(); } } __result = gameObject; return(false); }
public GameObject DuplicateFromSpawnLock(FVRViveHand hand) { //the base keyword does not work for some strange reason, so this is copied from FVRPhysicalObject.DuplicateFromSpawnLock GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.ObjectWrapper.GetGameObject(), this.Transform.position, this.Transform.rotation); FVRPhysicalObject fvrObj = gameObject.GetComponent <FVRPhysicalObject>(); (fvrObj as FVREntityProxy)?.Data.PrimeDataLists((fvrObj as FVREntityProxy).Flags); hand?.ForceSetInteractable(fvrObj); fvrObj.SetQuickBeltSlot(null); fvrObj.BeginInteraction(hand); patch_FVRFireArmClip component = gameObject.GetComponent <patch_FVRFireArmClip>(); for (int i = 0; i < Mathf.Min(this.LoadedRounds.Length, component.LoadedRounds.Length); i++) { if (this.LoadedRounds[i] != null && this.LoadedRounds[i].LR_Mesh != null) { component.LoadedRounds[i].LR_Class = this.LoadedRounds[i].LR_Class; component.LoadedRounds[i].LR_Type = this.LoadedRounds[i].LR_Type; component.LoadedRounds[i].LR_Mesh = this.LoadedRounds[i].LR_Mesh; component.LoadedRounds[i].LR_Material = this.LoadedRounds[i].LR_Material; component.LoadedRounds[i].LR_ObjectWrapper = this.LoadedRounds[i].LR_ObjectWrapper; } } component.m_numRounds = this.m_numRounds; component.UpdateBulletDisplay(); return(gameObject); }
public void movemagtohand(FVRViveHand hand, FVRFireArmMagazine magazine) { //puts mag in hand if (hand != null) { hand.ForceSetInteractable(magazine); } magazine.BeginInteraction(hand); }
public override void UpdateInteraction(FVRViveHand hand) { base.UpdateInteraction(hand); // If we're already completely eaten return if (_currentStage == EatStages.Length) { return; } // Check if we're close enough to be eaten if (Vector3.Distance(transform.position, GM.CurrentPlayerBody.Head.transform.position + GM.CurrentPlayerBody.Head.transform.up * -0.2f) >= 0.150000005960464) { return; } // Check if it's been long enough since the last time we were eaten if (_lastEatTime + EatDelay > Time.time) { return; } // Play the eat sound _lastEatTime = Time.time; SM.PlayGenericSound(EatSound, transform.position); EatEvent.Invoke(); GM.CurrentPlayerBody.HealPercent(HealPercent); if (_currentStage != EatStages.Length - 1 || DestroyOnEat) { EatStages[_currentStage].SetActive(false); } _currentStage++; // If we've eaten all the stages if (_currentStage == EatStages.Length && DestroyOnEat) { EndInteraction(hand); hand.ForceSetInteractable(null); Destroy(gameObject); } else { EatStages[_currentStage].SetActive(true); } }