Пример #1
0
		public static int Build(Mobile from, Point3D start, Point3D end, ConstructorInfo ctor, object[] values, string[,] props, PropertyInfo[] realProps, ArrayList packs)
		{
			try
			{
				Map map = from.Map;

				int objectCount = (packs == null ? (((end.X - start.X) + 1) * ((end.Y - start.Y) + 1)) : packs.Count);

				if (objectCount >= 20)
					from.SendMessage("Constructing {0} objects, please wait.", objectCount);

				bool sendError = true;

				if (packs != null)
				{
					for (int i = 0; i < packs.Count; ++i)
					{
						object built = Build(from, ctor, values, props, realProps, ref sendError);

						if (built is Item)
						{
							Container pack = (Container)packs[i];

							pack.DropItem((Item)built);
						}
						else if (built is Mobile)
						{
							Mobile m = (Mobile)built;

							m.MoveToWorld(new Point3D(start.X, start.Y, start.Z), map);
						}
					}
				}
				else
				{
					for (int x = start.X; x <= end.X; ++x)
					{
						for (int y = start.Y; y <= end.Y; ++y)
						{
							object built = Build(from, ctor, values, props, realProps, ref sendError);

							if (built is Item)
							{
								Item item = (Item)built;
								item.MoveToWorld(new Point3D(x, y, start.Z), map);
								AddItemEventArgs e = new AddItemEventArgs(built as Item, from);
								EventSink.InvokeAddItem(e);

								// erl: stores person adding it if Spawner
								// or ChestItemSpawner type + calls change log

								if (built is Spawner)
								{
									Spawner sp = (Spawner)built;
									sp.LastProps = from;
									sp.LogChange("Spawner added");
								}
								else if (built is ChestItemSpawner)
								{
									ChestItemSpawner sp = (ChestItemSpawner)built;
									sp.LastProps = from;
									sp.LogChange("ChestItemSpawner added");
								}

							}
							else if (built is Mobile)
							{
								Mobile m = (Mobile)built;

								m.MoveToWorld(new Point3D(x, y, start.Z), map);
							}
						}
					}
				}

				return objectCount;
			}
			catch (Exception ex)
			{
				LogHelper.LogException(ex);
				Console.WriteLine(ex);
				return 0;
			}
		}
Пример #2
0
		private static void EventSink_AddItem(AddItemEventArgs e)
		{
			LogHelper lh = new LogHelper("AddItem.log", false, true);
			lh.Log(LogType.Mobile, e.from, String.Format("Used [Add Item to create ItemID:{0}, Serial:{1}", e.item.ItemID.ToString(), e.item.Serial.ToString()));
			lh.Finish();
		}
Пример #3
0
		public static void InvokeAddItem(AddItemEventArgs e)
		{
			if (AddItem != null)
			{
				foreach (AddItemEventHandler currentDelegate in AddItem.GetInvocationList())
				{
					try
					{
						currentDelegate.Invoke(e);
					}
					catch (Exception ex)
					{
						// Log an exception
						EventSink.InvokeLogException(new LogExceptionEventArgs(ex));
					}
				}
			}
		}