Esempio n. 1
0
        public int Generate(Map[] maps)
        {
            int count = 0;

            Item item = null;

            for (int i = 0; i < this.m_Entries.Count; ++i)
            {
                DecorationEntryMag entry = (DecorationEntryMag)this.m_Entries[i];
                Point3D            loc   = entry.Location;
                string             extra = entry.Extra;

                for (int j = 0; j < maps.Length; ++j)
                {
                    if (item == null)
                    {
                        item = this.Construct();
                    }

                    if (item == null)
                    {
                        continue;
                    }

                    if (FindItem(loc.X, loc.Y, loc.Z, maps[j], item))
                    {
                    }
                    else
                    {
                        item.MoveToWorld(loc, maps[j]);
                        ++count;

                        if (item is BaseDoor)
                        {
                            IPooledEnumerable eable = maps[j].GetItemsInRange(loc, 1);

                            Type itemType = item.GetType();

                            foreach (Item link in eable)
                            {
                                if (link != item && link.Z == item.Z && link.GetType() == itemType)
                                {
                                    ((BaseDoor)item).Link = (BaseDoor)link;
                                    ((BaseDoor)link).Link = (BaseDoor)item;
                                    break;
                                }
                            }

                            eable.Free();
                        }
                        else if (item is MarkContainer)
                        {
                            try
                            {
                                ((MarkContainer)item).Target = Point3D.Parse(extra);
                            }
                            catch
                            {
                            }
                        }

                        item = null;
                    }
                }
            }

            if (item != null)
            {
                item.Delete();
            }

            return(count);
        }
Esempio n. 2
0
        public int Generate(Map[] maps)
        {
            int count = 0;

            Item item = null;

            for (int i = 0; i < m_Entries.Count; ++i)
            {
                DecorationEntryMag entry = m_Entries[i];
                Point3D            loc   = entry.Location;
                string             extra = entry.Extra;

                for (int j = 0; j < maps.Length; ++j)
                {
                    item ??= Construct();

                    if (item == null)
                    {
                        continue;
                    }

                    if (FindItem(loc.X, loc.Y, loc.Z, maps[j], item))
                    {
                    }
                    else
                    {
                        item.MoveToWorld(loc, maps[j]);
                        ++count;

                        if (item is BaseDoor door)
                        {
                            IPooledEnumerable <BaseDoor> eable = maps[j].GetItemsInRange <BaseDoor>(loc, 1);

                            Type itemType = door.GetType();

                            foreach (BaseDoor link in eable)
                            {
                                if (link != item && link.Z == door.Z && link.GetType() == itemType)
                                {
                                    door.Link = link;
                                    link.Link = door;
                                    break;
                                }
                            }

                            eable.Free();
                        }
                        else if (item is MarkContainer markCont)
                        {
                            try
                            {
                                markCont.Target = Point3D.Parse(extra);
                            }
                            catch
                            {
                                // ignored
                            }
                        }

                        item = null;
                    }
                }
            }

            item?.Delete();

            return(count);
        }