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;
     }
 }
Example #3
0
 /// <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 + "?");
     }
 }
Example #4
0
 void InnerViewStoreFailed(PGISlotItem item, PGISlot dest, PGISlot src)
 {
     if ((EventsToHandle & EventType.View) != 0)
     {
         ViewStoreFailed(item, dest, src);
     }
 }
Example #5
0
        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;
        }
Example #6
0
 void InnerViewCanRemove(UnityAction onFailed, PGISlotItem item, PGISlot slot)
 {
     if ((EventsToHandle & EventType.View) != 0)
     {
         ViewCanRemove(onFailed, item, slot);
     }
 }
Example #7
0
 protected virtual void InnerModelRemove(PGISlotItem item, CellModel dest)
 {
     if (dest == CachedCell && dest != null)
     {
         ModelRemove(item, dest);
     }
 }
Example #8
0
 protected virtual void InnerModelStoreFailed(PGISlotItem item, CellModel dest)
 {
     if (dest == CachedCell && dest != null)
     {
         ModelStoreFailed(item, dest);
     }
 }
Example #9
0
        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;
        }
Example #10
0
 /// <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);
                }
            }
        }
    }
Example #12
0
 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;
                }
            }
        }
    }
Example #14
0
 /// <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);
     }
 }
Example #15
0
 /// <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);
     }
 }
Example #16
0
 /// <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);
     }
 }
Example #17
0
 void InnerViewRemove(PGISlotItem item, PGISlot current)
 {
     if ((EventsToHandle & EventType.View) != 0)
     {
         ViewRemove(item, current);
     }
 }
Example #18
0
 /// <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 + "?");
     }
 }
Example #19
0
 public void TrashItem(PGISlotItem item, PGISlot dest, PGISlot notUsed)
 {
     if (dest == null || dest == dest.Model)
     {
         return;
     }
     TrashItem(item, dest.Model, dest);
 }
Example #20
0
 /// <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);
 }
Example #21
0
 /// <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);
 }
Example #22
0
 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
 }
Example #23
0
 /// <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);
 }
Example #24
0
 /// <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 + "?");
     }
 }
Example #25
0
 /// <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);
     }
 }
Example #27
0
        /// <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;
            }
        }
Example #28
0
        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();
 }
Example #30
0
    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();
        }