public void TrashItem(PGISlotItem item, PGIModel inv, PGISlot slot) { //This helper method will handle all of the magic for us. //It makes sure the item is unequipped and removed from the inventory //and triggers all of the necessary events. inv.Drop(item); }
public void OnUnequip(PGISlotItem item, PGIModel inv, PGISlot slot) { foreach (var dis in disableSlots) { dis.Blocked = true; } }
/// <summary> /// Triggered just before this item is equipped. /// </summary> /// <param name="item">Item.</param> /// <param name="inv">Inv.</param> public void CanUnequip(PGISlotItem item, PGIModel inv, PGISlot slot) { if (ShowDebugCanMessages) { Debug.Log("<color=yellow>Can unequip</color> " + this.gameObject.name + " from " + slot.gameObject.name + " in " + inv.gameObject.name + "?"); } }
void InnerViewStoreFailed(PGISlotItem item, PGISlot dest, PGISlot src) { if ((EventsToHandle & EventType.View) != 0) { ViewStoreFailed(item, dest, src); } }
public void CanStore(UnityAction onFailed, PGISlotItem item, PGISlot slot) { var inv = slot.Model; //If we are equipping on of the filter's types, then we need to see if //any of the linked slots are full or blocked. if (LinkedSlots != null) { ItemType type = item.GetComponent <ItemType>(); if (type != null && HashedTypes != null) { if (HashedTypes.Contains(type.TypeName.Hash)) { foreach (PGISlot linked in LinkedSlots) { if (linked.Item != null || linked.Blocked) { //disallow equipping onFailed(); return; } } } } } //Either the item is not using multiple slots or, if it is, //the linked slots are all empty and unblocked. Good to go! return; }
void InnerViewCanRemove(UnityAction onFailed, PGISlotItem item, PGISlot slot) { if ((EventsToHandle & EventType.View) != 0) { ViewCanRemove(onFailed, item, slot); } }
protected virtual void InnerModelRemove(PGISlotItem item, CellModel dest) { if (dest == CachedCell && dest != null) { ModelRemove(item, dest); } }
protected virtual void InnerModelStoreFailed(PGISlotItem item, CellModel dest) { if (dest == CachedCell && dest != null) { ModelStoreFailed(item, dest); } }
public void CanEquip(PGISlotItem item, PGIModel inv, PGISlot slot) { //If we are equipping on of the filter's types, then we need to see if //any of the linked slots are full or blocked. if (LinkedSlots != null) { ItemType type = item.GetComponent <ItemType>(); if (type != null && TypesThatUseMultiSlots != null) { if (TypesThatUseMultiSlots.Contains(type.TypeName)) { foreach (PGISlot linked in LinkedSlots) { if (linked.Item != null || linked.Blocked) { //disallow equipping inv.CanPerformAction = false; return; } } } } } //Either the item is not using multiple slots or, if it is, //the linked slots are all empty and unblocked. Good to go! return; }
/// <summary> /// Triggered when this item fails to equip. /// </summary> /// <param name="item">Item.</param> /// <param name="inv">Inv.</param> public void StoreInInventoryFailed(PGISlotItem item, PGIModel inv) { if (ShowDebugMessages) { Debug.Log("<color=red>Failed to store</color> " + this.gameObject.name + " in " + inv.gameObject.name); } }
public void OnEquip(PGISlotItem item, PGIModel inv, PGISlot slot) { if (!this.enabled) { return; } //Check to see if the equipped item has an ItemType component ItemType type = item.GetComponent <ItemType>(); if (type != null)//type.TypeName.Equals("Two-handed Weapon")) { //It does. So we need to block if (LowerLinkedSlots != null) { foreach (PGISlot linked in LowerLinkedSlots) { linked.Blocked = true; //HACK ALERT: //This is a work-around for a bug introduced with the advent of 3D mesh icons. //This simply ensures the linked slot's default icon is restored as it should be. linked.gameObject.SetActive(false); linked.gameObject.SetActive(true); } } } }
protected virtual void InnerModelCanRemove(UnityAction onFailed, PGISlotItem item, CellModel dest) { if (dest == CachedCell && dest != null) { ModelCanRemove(onFailed, item, dest); } }
public void OnUnequip(PGISlotItem item, PGIModel inv, PGISlot slot) { if (!this.enabled) { return; } if (LowerLinkedSlots != null) { foreach (PGISlot linked in LowerLinkedSlots) { //Warning, we are making the assumption that nothing else //had previously blocked this slot. //HACK ALERT: We need to check for Blocked stat before changing it here //due to the changes made for the 3D icon system and the highlight colors //used by items when equipped to slots. if (linked.Blocked) { linked.Blocked = false; } if (linked.Item != null && !toggleAll) { break; } } } }
/// <summary> /// Triggered when this item is unequipped. /// </summary> /// <param name="item">Item.</param> /// <param name="inv">Inv.</param> public void Unequip(PGISlotItem item, PGIModel inv, PGISlot dest) { if (ShowDebugMessages) { Debug.Log("<color=cyan>Unequipped</color> " + this.gameObject.name + " from " + dest.gameObject.name + " in " + inv.gameObject.name); } }
/// <summary> /// Triggered when this item fails to equip. /// </summary> /// <param name="item">Item.</param> /// <param name="inv">Inv.</param> public void EquipFailed(PGISlotItem item, PGIModel inv, PGISlot failedDest) { if (ShowDebugMessages) { Debug.Log("<color=red>Failed to equip</color> " + this.gameObject.name + " to " + failedDest.gameObject.name + " in " + inv.gameObject.name); } }
/// <summary> /// Triggered when this item is equipped. /// </summary> /// <param name="item">Item.</param> /// <param name="inv">Inv.</param> public void Equip(PGISlotItem item, PGIModel inv, PGISlot from) { if (ShowDebugMessages) { Debug.Log("<color=blue>Equipped</color> " + this.gameObject.name + " to " + from.gameObject.name + " in " + inv.gameObject.name); } }
void InnerViewRemove(PGISlotItem item, PGISlot current) { if ((EventsToHandle & EventType.View) != 0) { ViewRemove(item, current); } }
/// <summary> /// Triggered just before this item is unequipped. /// If you wish to stop the action set the passed PGIModel's /// 'CanPerformAction' flag to false. /// </summary> /// <param name="item">Item.</param> /// <param name="inv">Inv.</param> public void CanEquip(PGISlotItem item, PGIModel inv, PGISlot slot) { inv.CanPerformAction = true; if (ShowDebugCanMessages) { Debug.Log("<color=yellow>Can equip</color> " + this.gameObject.name + " to " + slot.gameObject.name + " in " + inv.gameObject.name + "?"); } }
public void TrashItem(PGISlotItem item, PGISlot dest, PGISlot notUsed) { if (dest == null || dest == dest.Model) { return; } TrashItem(item, dest.Model, dest); }
/// <summary> /// Triggered after this item is removed from the given inventory. /// </summary> /// <param name="item">Item.</param> /// <param name="inv">Inv.</param> public void DropFromInventory(PGISlotItem item, PGIModel inv) { if (ShowDebugMessages) { Debug.Log("<color=grey>Dropping</color> " + this.gameObject.name + " from " + inv.gameObject.name); } SetPhysicalManifestation(true); }
/// <summary> /// Makes sure we close the container if we remove it from our inventory. /// </summary> /// <param name="item">The item being equipped.</param> /// <param name="model">The model the item is being equipped within.</param> public void OnDrop(PGISlotItem item, PGIModel model) { //POINT OF INTERNEST: The view being closed would normally return the DraggedItem (i.e. this item) //to it's model when it is disabled. However, a slight delay in the view's //internal OnDisable() method allows us the time we need to actually drop //this item and finish up processing. ContainerPanel.SetActive(false); }
public void TrashItem(PGISlotItem item, PGIModel inv, PGISlot slot) { //This helper method will handle all of the magic for us. //It makes sure the item is unequipped and removed from the inventory //and triggers all of the necessary events. inv.Drop(item); PGIModel.PostMovementEvents(item, null, slot.CorrespondingCell.Model); //this is a workaround for the fact that the item doesn't have a model currently due to the way drag n drop works }
/// <summary> /// Triggered after this item is being stored in the given inventory. /// </summary> /// <param name="item">Item.</param> /// <param name="inv">Inv.</param> public void StoreInInventory(PGISlotItem item, PGIModel inv) { if (ShowDebugMessages) { Debug.Log("<b>Storing</b> " + this.gameObject.name + " in " + inv.gameObject.name); } SetPhysicalManifestation(false); }
/// <summary> /// Triggered just before this item is leaves the inventory. /// If you wish to stop the action set the passed PGIModel's /// 'CanPerformAction' flag to false. /// </summary> /// <param name="item">Item.</param> /// <param name="inv">Inv.</param> public void CanRemove(PGISlotItem item, PGIModel inv) { //we must set this flag or the item will not be able to be moved. if (ShowDebugCanMessages) { Debug.Log("<color=yellow>Can remove</color> " + this.gameObject.name + " from " + inv.gameObject.name + "?"); } }
/// <summary> /// Triggered just before this item is enters the inventory. /// If you wish to stop the action set the passed PGIModel's /// 'CanPerformAction' flag to false. /// </summary> /// <param name="item">Item.</param> /// <param name="inv">Inv.</param> public void CanStore(PGISlotItem item, PGIModel inv) { inv.CanPerformAction = true; //we must set this flag or the item will not be able to be moved. if (ShowDebugCanMessages) { Debug.Log("<color=yellow>Can store</color> " + this.gameObject.name + " in " + inv.gameObject.name + "?"); } }
public void OnStore(PGISlotItem item, PGIModel model) { gameObject.SetActive(false); gameObject.transform.position = model.transform.position; if (PickupSound != null) { AudioSource.PlayClipAtPoint(PickupSound, transform.position); } }
/// <summary> /// Used by OnCanEquip event of this gameobject's PGISlotItem component. /// Ensures that we don't equip this item to it's own inventory. /// </summary> /// <returns><c>true</c> if this instance can store the specified item model; otherwise, <c>false</c>.</returns> /// <param name="item">The item being equipped.</param> /// <param name="model">The model the item is being equipped within.</param> /// <param name="slot">The equipment slot the item is being equipped to.</param> public void CanEquip(PGISlotItem item, PGIModel model, PGISlot slot) { //make sure we aren't trying to store this container in itself PGIModel storage = GetComponent <PGIModel>(); if (storage == model) { model.CanPerformAction = false; } }
protected override void OnEnable() { TargetItem = this.target as PGISlotItem; //we need to do this because CustomEditor is kinda dumb //and won't expose the type we passed to it. Plus relfection //can't seem to get at the data either. EditorTargetType = typeof(PGISlotItem); base.OnEnable(); }
public void OnRemove(PGISlotItem item, PGIModel model) { gameObject.SetActive(true); gameObject.transform.position = model.transform.position; if (DropSound != null) { AudioSource.PlayClipAtPoint(DropSound, transform.position); } OnDrop(); }
void Start() { slotItem = gameObject.GetComponent <PGISlotItem>(); if (slotItem != null) { slotItem.OnEquip.AddListener(OnEquip); slotItem.OnUnequip.AddListener(OnUnequip); slotItem.OnCanEquip.AddListener(OnCanEquip); } }
/// <summary> /// Updates the <see cref="PlayerSaveData" /> to matcha a change in the <see cref="PGIModel" />. /// </summary> /// <param name="arg0">The item removed.</param> /// <param name="pgiModel">The model ???</param> private void OnRemoveItem( PGISlotItem arg0, PGIModel pgiModel ) { if( !m_keepSyncedWithInventory ) { return; } PlayerData_Unsub(); UnitItem unitItem = arg0.GetComponent<UnitItem>(); if( unitItem != null ) { m_saveData.UnitDefinitions.Remove( unitItem.Unit ); m_saveData.NotifyChanges(); } PlayerData_Sub(); }
public void OnStoreItem( PGISlotItem item, PGIModel model ) { if( !enabled ) { return; } // Don't bother if we are disabled if( item.GetComponent<ModuleItem>() != null ) { UpdatePreview(); } }
/// <summary> /// Updates the <see cref="PlayerSaveData" /> to matcha a change in the <see cref="PGIModel" />. /// </summary> /// <param name="arg0">The item removed.</param> /// <param name="pgiModel">The model ???</param> private void OnRemoveItem( PGISlotItem arg0, PGIModel pgiModel ) { if( !m_keepSyncedWithInventory ) { return; } PlayerData_Unsub(); ModuleItem moduleItem = arg0.GetComponent<ModuleItem>(); if( moduleItem != null ) { m_saveData.Modules.Remove( moduleItem.Module ); m_saveData.NotifyChanges(); } PlayerData_Sub(); }