protected IEnumerator LaunchProjectile(Equippable equippable, Weapon weapon) { if (!HasProjectile) { //if we don't have a projectile it doesn't matter //MasterAudio.PlaySound (mEquippable.Sounds.SoundType, ToolDoppleganger.transform, mEquippable.Sounds.SoundUseUnuccessfully); mEquippable.UseUnsuccessfully(); ToolState = PlayerToolState.Equipped; yield break; } //convert the projectile object to a world item if it isn't already Projectile projectile = null; if (ProjectileObject.IsWorldItem) { //get the projectile from the existing worlditem projectile = ProjectileObject.worlditem.Get <Projectile>(); } else { WorldItem worlditemProjectile = null; //clone the projectile from the stack item WorldItems.CloneFromStackItem(ProjectileObject.GetStackItem(WIMode.Stacked), WIGroups.Get.Player, out worlditemProjectile); //initialize immediately worlditemProjectile.Initialize(); worlditemProjectile.transform.position = ToolActionPointObject.position; worlditemProjectile.transform.rotation = ToolActionPointObject.rotation; //set the projectile object to null ProjectileObject = null; //give it a second to initialze projectile = worlditemProjectile.Get <Projectile>(); } if (projectile != null) { projectile.Launch(ToolActionPointObject, weapon, LaunchForce); //play the launching sound mEquippable.UseSuccessfully(); //MasterAudio.PlaySound (mEquippable.Sounds.SoundType, ToolDoppleganger.transform, mEquippable.Sounds.SoundUseSuccessfully); yield return(null); } else { Debug.Log("Projectile was null"); } RefreshToolDoppleganger(false); yield return(null); if (UsesTensionMorph) { TensionChannel.Percent = 0f; } yield break; }
public void OnClickSquare() { Debug.Log("Clicking result square"); WIStackError error = WIStackError.None; if (ReadyForRetrieval) { Debug.Log("Is ready for retrieval"); while (NumItemsCrafted > 0) { StackItem craftedItem = CraftedItemTemplate.ToStackItem(); craftedItem.Group = WIGroups.Get.Player; if (craftedItem.CanEnterInventory) { if (Player.Local.Inventory.AddItems(craftedItem, ref error)) { Debug.Log("Added item to inventory"); NumItemsCrafted--; } else { Debug.Log("Couldn't add to inventory, what now?"); break; } } else { Debug.Log("We have to carry the item"); if (Player.Local.ItemPlacement.IsCarryingSomething) { Player.Local.ItemPlacement.PlaceOrDropCarriedItem(); } //turn it into a worlditem and have the player carry it WorldItem craftedWorldItem = null; if (WorldItems.CloneFromStackItem(craftedItem, WIGroups.GetCurrent(), out craftedWorldItem)) { craftedWorldItem.Props.Local.CraftedByPlayer = true; craftedWorldItem.Initialize(); craftedWorldItem.ActiveState = WIActiveState.Active; craftedWorldItem.Props.Local.FreezeOnStartup = false; craftedWorldItem.tr.rotation = Quaternion.identity; craftedWorldItem.SetMode(WIMode.World); craftedWorldItem.tr.position = Player.Local.ItemPlacement.GrabberIdealPosition; craftedWorldItem.LastActiveDistanceToPlayer = 0f; //if we have an interface open, close it now GUIInventoryInterface.Get.Minimize(); //then force the player to carry the item if (Player.Local.ItemPlacement.ItemCarry(craftedWorldItem, true)) { NumItemsCrafted--; } else { GUIManager.PostWarning("You have to drop what you're carrying first"); } //set placement mode to true immediately Player.Local.ItemPlacement.PlacementModeEnabled = true; } break; } } } else { Debug.Log("Not ready for retrieval"); } RefreshRequest(); }