public void PlaceItemOnMe(PickableItem item) { itemOnSurface = item; // Stop an autoStart item using charge when it's placed if (itemOnSurface is UsableItem) { UsableItem usableTempItem = itemOnSurface as UsableItem; if (usableTempItem.autoStart) { usableTempItem.StopUse(); } } }
private void Update() { if (Input.GetButtonDown("Fire1")) { if (!placebaleSurfaceAvailable && itemAvailable && !itemAvailable.itemInUse)// pick up item { itemInHand = itemAvailable; itemAvailable = null; itemInHand.PlaceItemAtLocation(itemLocation); onPickUpDelegate?.Invoke(); } else if (placebaleSurfaceAvailable) { if (itemInHand && !placebaleSurfaceAvailable.itemOnSurface)// place item on surface { placebaleSurfaceAvailable.PlaceItemOnMe(ItemInHand); itemInHand.DropItem(placebaleSurfaceAvailable); ItemInHand = null; } else if (placebaleSurfaceAvailable.itemOnSurface && !itemInHand)// take item from surface { ItemInHand = placebaleSurfaceAvailable.TakeItemFromMe(); itemAvailable = null; itemInHand.PlaceItemAtLocation(itemLocation); } } else if (spawnableSurfaceAvailable && ItemInHand == null)// spawn and get item from surface { ItemInHand = spawnableSurfaceAvailable.GetObjectFromSurface(); if (itemInHand)// check to see if we got an item { itemInHand.PlaceItemAtLocation(itemLocation); } } else if (itemInHand)// drop item { itemInHand.DropItem(null); ItemInHand = null; onDropDelegate?.Invoke(); } } else if (Input.GetButtonDown("Fire2")) { if (itemInHand && itemInHand is UsableItem) { UsableItem item = itemInHand as UsableItem; if (item.percentageFull > 0 && !item.autoStart) { item.StartUse(); } } } else if (Input.GetButtonUp("Fire2")) { if (itemInHand && itemInHand is UsableItem) { UsableItem item = itemInHand as UsableItem; if (!item.autoStart) { item.StopUse(); } } } }