Beispiel #1
0
 /**
  * Releases the BaseInteractiveObject and all resources.
  * @param io the BaseInteractiveObject
  */
 public void ReleaseIO(BaseInteractiveObject io)
 {
     if (io != null)
     {
         if (io.Inventory != null)
         {
             InventoryData inventory = io.Inventory;
             if (inventory != null)
             {
                 for (int j = 0; j < inventory.GetNumInventorySlots(); j++)
                 {
                     if (io.Equals(inventory.Slots[j].Io))
                     {
                         inventory.Slots[j].Io   = null;
                         inventory.Slots[j].Show = true;
                     }
                 }
             }
         }
         // release script timers and spells
         // release from groups
         //
         Script.Instance.TimerClearByIO(io);
         // MagicRealmSpells.Instance.removeAllSpellsOn(io);
         Script.Instance.ReleaseScript(io.Script);
         Script.Instance.ReleaseScript(io.Overscript);
         Script.Instance.ReleaseAllGroups(io);
         int id    = io.RefId;
         int index = -1;
         BaseInteractiveObject[] objs = GetIOs();
         for (int i = 0; i < objs.Length; i++)
         {
             if (objs[i] != null &&
                 id == objs[i].RefId)
             {
                 index = i;
                 break;
             }
         }
         if (index > -1)
         {
             objs[index] = null;
         }
         objs = null;
         objs = GetIOs();
     }
 }
Beispiel #2
0
        /**
         * Determines if the {@link Interactive} has a specific interactive object.
         * @param io the BaseInteractiveObject
         * @return true if that interactive object has been stored already; false
         *         otherwise
         */
        public bool HasIO(BaseInteractiveObject io)
        {
            bool has = false;

            if (io != null)
            {
                BaseInteractiveObject[] objs = GetIOs();
                for (int i = objs.Length - 1; i >= 0; i--)
                {
                    if (objs[i] != null &&
                        io.RefId == objs[i].RefId &&
                        io.Equals(objs[i]))
                    {
                        has = true;
                        break;
                    }
                }
                objs = null;
            }
            return(has);
        }