public static bool CanWear(WearableType type, BodyPartType bodyPart, BodyOrientation orientation, IWIBase itemBase) { WorldItem item = null; if (itemBase.IsWorldItem) { item = itemBase.worlditem; } else { //use the item to get the template WorldItem prefab = null; WorldItems.Get.PackPrefab(itemBase.PackName, itemBase.PrefabName, out item); } if (item == null) { //whoops, not sure what went wrong here return(false); } bool result = false; Wearable wearable = null; if (item.worlditem.Is <Wearable>(out wearable)) { bool matchesType = Flags.Check((uint)wearable.Type, (uint)type, Flags.CheckType.MatchAny); bool matchesOrientation = (wearable.Orientation == BodyOrientation.None && orientation == BodyOrientation.None) || Flags.Check((uint)wearable.Orientation, (uint)orientation, Flags.CheckType.MatchAny); bool matchesBodyPart = wearable.BodyPart == bodyPart; //Debug.Log("Matches type? " + matchesType.ToString() + " matches orientation? " + matchesOrientation.ToString() + " matchesBodyPart? " + matchesBodyPart.ToString()); result = matchesType & matchesOrientation & matchesBodyPart; } else { Debug.Log("World item " + itemBase.FileName + " is not wearable"); } return(result); }
public static string StateName(Wearable wearable) { return(wearable.State.CurrentOrientation.ToString() + "_" + wearable.State.CurrentStyle.ToString()); }