public bool PushWearable(Wearable wearable) { if (!mStack.HasTopItem && Wearable.CanWear(Type, BodyPart, Orientation, wearable.worlditem)) { WIStackError error = WIStackError.None; return(Stacks.Push.Item(mStack, wearable.worlditem, ref error)); } return(false); }
public bool IsWearing(WearableType typeOfWearable, BodyPartType onBodyPart, BodyOrientation orientation, string articlePrefabName) { bool upperBody = true; int index = Wearables.GetWearableIndex(onBodyPart, orientation, ref upperBody); WIStackContainer container = null; if (upperBody) { container = State.UpperBodyContainer; } else { container = State.LowerBodyContainer; } WIStack stack = container.StackList[index]; IWIBase wearableItem; if (stack.HasTopItem) { wearableItem = stack.TopItem; if (Wearable.CanWear(typeOfWearable, onBodyPart, orientation, wearableItem)) { //has top item and we can wear that item, so yes we are wearing it if (!string.IsNullOrEmpty(articlePrefabName)) { if (string.Equals(wearableItem.PrefabName, articlePrefabName)) { return(true); } } else { // no need to check for article return(true); } } } return(false); }
public override void OnClickSquare() { if (!IsEnabled) { return; } bool result = false; bool pickUp = false; bool playSound = false; bool playErrorSound = false; WIStackError error = WIStackError.None; if (Player.Local.Inventory.SelectedStack.HasTopItem) { Wearable wearable = null; IWIBase topItem = Player.Local.Inventory.SelectedStack.TopItem; if (Wearable.CanWear(Type, BodyPart, Orientation, topItem)) { if (mStack.HasTopItem) { if (Stacks.Swap.Stacks(mStack, Player.Local.Inventory.SelectedStack, ref error)) { pickUp = true; playSound = true; result = true; } else { result = false; playSound = true; } } else { Stacks.Add.Items(Player.Local.Inventory.SelectedStack, mStack, ref error); playSound = true; result = true; } } else { result = false; playErrorSound = true; } } else { Stacks.Add.Items(mStack, Player.Local.Inventory.SelectedStack, ref error); pickUp = true; playSound = true; result = true; } if (playSound) { if (pickUp) { MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "InventoryPickUpStack"); } else { MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "InventoryPlaceStack"); } } else if (playErrorSound) { MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "ButtonClickDisabled"); } RefreshRequest(); }