public Tapestry_ItemListIndex(Tapestry_Item item, int min, int max, int weight) { this.item = item; this.rangeMin = min; this.rangeMax = max; this.weight = weight; }
protected virtual void DrawSubTabKeywords(Tapestry_Item i) { if (ReferenceEquals(i.keywords, null)) { i.keywords = (Tapestry_KeywordRegistry)ScriptableObject.CreateInstance("Tapestry_KeywordRegistry"); } i.keywords.DrawInspector(); }
public bool ContainsItem(Tapestry_Item item) { bool check = false; foreach (Tapestry_ItemStack stack in items) { if (stack.item.IsEqual(item.data)) { check = true; break; } } return(check); }
protected override void DrawSubTabEffect(Tapestry_Item i) { string effectOnHoldTooltip = "Does this object apply an Effect to the holder while held?"; if (ReferenceEquals(i.data.effect, null)) { i.data.effect = (Tapestry_Effect)ScriptableObject.CreateInstance("Tapestry_Effect"); } GUILayout.BeginVertical("box"); GUILayout.BeginHorizontal(); i.data.useEffect = EditorGUILayout.Toggle(i.data.useEffect, GUILayout.Width(12)); GUILayout.Label(new GUIContent("Apply Effect While Held?", effectOnHoldTooltip)); GUILayout.EndHorizontal(); if (i.data.useEffect) { pSel = i.data.effect.DrawInspector(pSel); } GUILayout.EndVertical(); }
protected virtual void DrawSubTabEffect(Tapestry_Item i) { string isConsumableTooltip = "Is this object consumable?"; if (ReferenceEquals(i.data.effect, null)) { i.data.effect = (Tapestry_Effect)ScriptableObject.CreateInstance("Tapestry_Effect"); } GUILayout.BeginVertical("box"); GUILayout.BeginHorizontal(); i.data.useEffect = EditorGUILayout.Toggle(i.data.useEffect, GUILayout.Width(12)); GUILayout.Label(new GUIContent("Consumable?", isConsumableTooltip)); GUILayout.EndHorizontal(); if (i.data.useEffect) { pSel = i.data.effect.DrawInspector(pSel); } GUILayout.EndVertical(); }
public override void OnInspectorGUI() { Tapestry_Item i = target as Tapestry_Item; if (startup) { if (!ReferenceEquals(i.data.effect, null)) { if (!ReferenceEquals(i.data.effect.payload, null)) { pSel = ArrayUtility.IndexOf(Tapestry_Config.GetPayloadTypes().Values.ToArray(), i.data.effect.payload.GetType()); } } else { pSel = 0; } startup = false; } string displayTooltip = "What string will display on the player's HUD when looking at this object.", prefabTooltip = "What is the name of the prefab (placed in the Resources/Items folder) that should be instantiated when this object is dropped in world?\n\nGenerally this should be the object's in-world name, rather than its display name.", interactableTooltip = "Can the player take this object to their inventory?", displayNameTooltip = "Should the object still show its display name when the player's cursor is hovering over the object?", valueTooltip = "How valuable is this object?"; GUILayout.BeginVertical("box"); GUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Display Name", displayTooltip)); GUILayout.FlexibleSpace(); i.displayName = EditorGUILayout.DelayedTextField(i.displayName, GUILayout.Width(270)); i.data.displayName = i.displayName; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Prefab Name", prefabTooltip)); GUILayout.FlexibleSpace(); i.data.prefabName = EditorGUILayout.DelayedTextField(i.data.prefabName, GUILayout.Width(270)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); i.isInteractable = EditorGUILayout.Toggle(i.isInteractable, GUILayout.Width(12)); GUILayout.Label(new GUIContent("Takeable?", interactableTooltip)); GUILayout.Space(20); if (!i.isInteractable) { i.displayNameWhenUnactivatable = EditorGUILayout.Toggle(i.displayNameWhenUnactivatable, GUILayout.Width(12)); GUILayout.Label(new GUIContent("Display Name Anyway?", displayNameTooltip)); GUILayout.FlexibleSpace(); } GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent("Value", valueTooltip)); i.data.value = EditorGUILayout.DelayedIntField(i.data.value, GUILayout.Width(50)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); DrawSubTabItemData(i); DrawSubTabEffect(i); DrawSubTabKeywords(i); }
private void HandleActivation() { bool activate = Input.GetKey(Tapestry_Config.KeyboardInput_Activate); bool push = Input.GetKey(Tapestry_Config.KeyboardInput_Push); bool lift = Input.GetKey(Tapestry_Config.KeyboardInput_Lift); objectInSights = null; RaycastHit hit; bool rayHit = Physics.Raycast( Camera.main.transform.position, Camera.main.transform.forward, out hit, reach.Value, ~(LayerMask.GetMask("Ignore Raycast") | LayerMask.GetMask("Tapestry Held Items")) ); if (rayHit) { objectInSights = hit.transform.gameObject.GetComponentInParent <Tapestry_Activatable>(); if (objectInSights != null) { objectInSights.Hover(); if (activateLastFrame && !activate && objectInSights.GetComponent <Tapestry_Activatable>().isInteractable) { if ((typeof(Tapestry_Item).IsAssignableFrom(objectInSights.GetType()))) { Tapestry_Item i = (Tapestry_Item)objectInSights; if (ReferenceEquals(inventory, null)) { inventory = (Tapestry_Inventory)ScriptableObject.CreateInstance("Tapestry_Inventory"); } inventory.AddItem(i, 1); objectInSights.Activate(this); } else if (objectInSights.GetType() == typeof(Tapestry_Door)) { Tapestry_Door d = (Tapestry_Door)objectInSights; if (d.security.isLocked) { if (ReferenceEquals(inventory, null)) { inventory = (Tapestry_Inventory)ScriptableObject.CreateInstance("Tapestry_Inventory"); } if (!d.GetIsOpen()) { if (inventory.ContainsKeyID(d.security.keyID)) { d.security.isLocked = false; if (d.consumeKeyOnUnlock) { inventory.RemoveKeyWithID(d.security.keyID); } } objectInSights.Activate(this); } } else { objectInSights.Activate(this); } } else if (objectInSights.GetType() == typeof(Tapestry_Container)) { Tapestry_Container c = (Tapestry_Container)objectInSights; if (inventoryUI == null) { inventoryUI = FindObjectOfType <Tapestry_UI_Inventory>(); } Debug.Log(c.inventory.items.Count + " in target container."); inventoryUI.Open(inventory, null, c.inventory, "Inventory", c.displayName); } else { objectInSights.Activate(this); } } if (pushLastFrame && !push && objectInSights.GetComponent <Tapestry_Activatable>().isPushable) { objectInSights.Push(this); } if (liftLastFrame && !lift && objectInSights.GetComponent <Tapestry_Activatable>().isLiftable) { objectInSights.Lift(this); } } } //End of frame activateLastFrame = activate; pushLastFrame = push; liftLastFrame = lift; }
public void AddItem(Tapestry_Item item, int quantity) { AddItem(item.data, quantity); }
public void DrawInspector() { GUIStyle title = new GUIStyle(); title.fontStyle = FontStyle.Bold; title.fontSize = 14; int indexToRemove = -1; GUILayout.BeginVertical("box"); GUILayout.Label("Inventory", title); GUILayout.BeginVertical("box"); if (items.Count == 0) { GUILayout.Label("No items in inventory."); } else { for (int i = 0; i < items.Count; i++) { Tapestry_ItemStack stack = items[i]; GUILayout.BeginHorizontal(); if (GUILayout.Button("-", GUILayout.Width(20))) { indexToRemove = i; } GUILayout.FlexibleSpace(); stack.quantity = EditorGUILayout.DelayedIntField(stack.quantity, GUILayout.Width(36)); GUILayout.FlexibleSpace(); GUILayout.Label("x", GUILayout.Width(12)); GUILayout.FlexibleSpace(); EditorGUILayout.TextField(stack.item.displayName, GUILayout.Width(270)); GUILayout.EndHorizontal(); } } if (indexToRemove != -1) { if (items.Count == 1) { items.Clear(); } else { items.RemoveAt(indexToRemove); } } GUILayout.EndVertical(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("+", GUILayout.Width(20))) { if (itemToAdd != null) { AddItem(itemToAdd, 1); itemToAdd = null; } } itemToAdd = (Tapestry_Item)EditorGUILayout.ObjectField(itemToAdd, typeof(Tapestry_Item), true, GUILayout.Width(300)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); }