public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 1: { m_Amount = reader.ReadInt(); if (m_Amount > 0) { string sType = reader.ReadString(); m_Type = ScriptCompiler.FindTypeByName(sType); m_LabelNumber = reader.ReadInt(); m_Description = reader.ReadString(); } break; } case 0: { //m_Commodity = reader.ReadItem(); m_oldversionCommodity = reader.ReadItem(); Timer.DelayCall(TimeSpan.FromSeconds(3.0), new TimerCallback(SetOldVersionCommodityInfo)); break; } } }
public override void Deserialize(GenericReader reader) { //handle base StoreEntry deserialization first base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 0: default: { _ItemListEntryType = ScriptCompiler.FindTypeByName(reader.ReadString()); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { string typestring = reader.ReadString(); Type type = ScriptCompiler.FindTypeByName(typestring); ItemListEntry entry = (ItemListEntry)Activator.CreateInstance(type, new object[] { reader }); ItemListEntries.Add(entry); } break; } } } //deserialize
public static bool IsEqualOrChildOf(this Type a, string bName, bool ignoreCase, bool fullName) { var b = Type.GetType(bName) ?? (fullName ? ScriptCompiler.FindTypeByFullName(bName) : ScriptCompiler.FindTypeByName(bName)); return(IsEqualOrChildOf(a, b)); }
/* Trouve l'objet à placer, et prend le args <amount> si il existe. * Retourne true si l'objet a été trouvé.*/ public bool ValidateArgs() { if (v.cmdArgs.Length >= 1) { v.typeObject = ScriptCompiler.FindTypeByName(v.cmdArgs.GetString(0)); if (v.typeObject != null) { if (v.cmdArgs.GetInt32(1) <= MAXIMUM_AMOUNT && v.cmdArgs.GetInt32(1) > 0) { v.amount = v.cmdArgs.GetInt32(1); } // else m_amount = 1; Setté par défaut dans le constructeur. return(true); } else { v.cmdArgs.Mobile.SendMessage("L'objet n'a pas été trouvé."); } } else { v.cmdArgs.Mobile.SendMessage("Le nom de l'objet doit être spécifié."); } return(false); }
public static bool HasInterface(this Type t, string i) { var iType = Type.GetType(i, false) ?? (i.IndexOf('.') < 0 ? ScriptCompiler.FindTypeByName(i) : ScriptCompiler.FindTypeByFullName(i)); return(iType != null && iType.IsInterface && HasInterface(t, iType)); }
public List <string> CreateArray(RelayInfo info, Mobile from) { List <string> creaturesName = new List <string>(); for (int i = 0; i < 13; i++) { TextRelay te = info.GetTextEntry(i); if (te != null) { string str = te.Text; if (str.Length > 0) { str = str.Trim(); string t = Spawner.ParseType(str); Type type = ScriptCompiler.FindTypeByName(t); if (type != null) { creaturesName.Add(str); } else { from.SendMessage("{0} is not a valid type name.", t); } } } } return(creaturesName); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { Mobile m = reader.ReadMobile(); TradeOrderCrate crate = reader.ReadItem() as TradeOrderCrate; if (m != null && crate != null) { ActiveTrades[m] = crate; } } _NameBuffer = new Dictionary <Type, string>(); count = reader.ReadInt(); for (int i = 0; i < count; i++) { Type t = ScriptCompiler.FindTypeByName(reader.ReadString()); string name = reader.ReadString(); if (t != null) { _NameBuffer[t] = name; } } }
protected override bool OnBeforeListAdd() { if (InputType != null) { return(true); } Send( new InputDialogGump( User, Refresh(), title: "Add Type by Name", html: "Write the name of a Type to add it to this list.\nExample: System.String", callback: (b1, text) => { InputType = VitaNexCore.TryCatchGet( () => Type.GetType(text, false, true) ?? ScriptCompiler.FindTypeByFullName(text, true) ?? ScriptCompiler.FindTypeByName(text, true)); HandleAdd(); InputType = null; })); return(false); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); Int32 version = reader.ReadInt(); switch (version) { case 0: Int32 count = reader.ReadInt(); for (Int32 i = 0; i < count; i++) { Type t = ScriptCompiler.FindTypeByName(reader.ReadString()); Int32 regenHits = reader.ReadInt(); Int32 regenStam = reader.ReadInt(); Int32 regenMana = reader.ReadInt(); Int32 strBonus = reader.ReadInt(); Int32 dexBonus = reader.ReadInt(); Int32 intBonus = reader.ReadInt(); Int32 duration = reader.ReadInt(); if (t != null) { m_FoodEffects.Add(t, new FoodEffect(regenHits, regenStam, regenMana, strBonus, dexBonus, intBonus, duration)); } } break; } }
public static void GumpInvoke(Mobile from, Mobile targ, string[] args) { string name = args[0]; FixArgs(ref args); Type type = ScriptCompiler.FindTypeByName(name); if (type == null) { from.SendMessage("No gump with that name was found."); } else if (type.IsSubclassOf(typeof(Gump))) { bool sent = SendThatGump(from, targ, type, args); if (sent) { from.SendMessage("Gump sent to the player."); } else { SendGumpUsage(type, from); } } else { from.SendMessage("No gump with that name was found"); } }
public static void SpawnEditor_OnCommand(Mobile from) { ArrayList worldList = new ArrayList(); ArrayList facetList = new ArrayList(); Type type = ScriptCompiler.FindTypeByName("PremiumSpawner", true); if (type == typeof(Item) || type.IsSubclassOf(typeof(Item))) { bool isAbstract = type.IsAbstract; foreach (Item item in World.Items.Values) { if (isAbstract ? item.GetType().IsSubclassOf(type) : item.GetType() == type) { worldList.Add(item); } } } foreach (PremiumSpawner worldSpnr in worldList) { if (worldSpnr.Map == from.Map) { facetList.Add(worldSpnr); } } //TODO: Sort spawner list SpawnEditor_OnCommand(from, 0, facetList); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); Bosses = new List <Type>(); CurrentBoss = reader.ReadMobile() as ShadowguardBoss; Minax = reader.ReadMobile() as LadyMinax; int count = reader.ReadInt(); for (int i = 0; i < count; i++) { Type boss = ScriptCompiler.FindTypeByName(reader.ReadString()); if (boss != null) { Bosses.Add(boss); } } if (CurrentBoss == null) { Reset(); } }
public static void RemoveVoidSpawners() { List <XmlSpawner> list = new List <XmlSpawner>(); foreach (XmlSpawner spawner in World.Items.Values.OfType <XmlSpawner>()) { if (list.Contains(spawner)) { break; } foreach (XmlSpawner.SpawnObject obj in spawner.SpawnObjects) { if (obj == null || obj.TypeName == null) { continue; } Type t = ScriptCompiler.FindTypeByName(obj.TypeName, true); if (t != null && t.IsSubclassOf(typeof(BaseVoidCreature)) || obj.TypeName.ToLower().StartsWith("korpre")) { list.Add(spawner); break; } } } list.ForEach(spawner => spawner.DoReset = true); Console.WriteLine("Reset {0} Void Spawn Spawners.", list.Count); }
public override bool ValidateArgs(BaseCommandImplementor impl, CommandEventArgs e) { if (e.Length >= 1) { Type t = ScriptCompiler.FindTypeByName(e.GetString(0)); if (t == null) { e.Mobile.SendMessage("No type with that name was found."); string match = e.GetString(0).Trim(); if (match.Length < 3) { e.Mobile.SendMessage("Invalid search string."); e.Mobile.SendGump(new AddGump(e.Mobile, match, 0, Type.EmptyTypes, false)); } else { e.Mobile.SendGump(new AddGump(e.Mobile, match, 0, AddGump.Match(match).ToArray(), true)); } } else { return(true); } } else { e.Mobile.SendGump(new CategorizedAddGump(e.Mobile)); } return(false); }
public virtual void Deserialize(GenericReader reader) { int version = reader.ReadInt(); switch (version) { case 2: { _LootType = (LootType)reader.ReadInt(); _Insured = reader.ReadBool(); goto case 1; } case 1: { _Hue = reader.ReadInt(); goto case 0; } case 0: default: { _Type = ScriptCompiler.FindTypeByName(reader.ReadString()); _Name = reader.ReadString(); break; } } if (version == 0) { //default hue from previous version; _Hue = 1153; } }
public static void SaveQuest_OnCommand(CommandEventArgs e) { Mobile m = e.Mobile; if (e.Length == 0 || e.Length > 2) { m.SendMessage("Syntax: SaveQuest <id> [saveEnabled=true]"); return; } Type index = ScriptCompiler.FindTypeByName(e.GetString(0)); MLQuest quest; if (index == null || !m_Quests.TryGetValue(index, out quest)) { m.SendMessage("Invalid quest type name."); return; } bool enable = (e.Length == 2) ? e.GetBoolean(1) : true; quest.SaveEnabled = enable; m.SendMessage("Serialization for quest {0} is now {1}.", quest.GetType().Name, enable ? "enabled" : "disabled"); if (AutoGenerateNew && !enable) { m.SendMessage("Please note that automatic generation of new quests is ON. This quest will be regenerated on the next server start."); } }
public void ApplyButtonPressed(IGumpComponent sender, object param) { String titleName = GetTextEntry("Definition Name"); Boolean enabled = GetCheck("Definition Enabled"); if (DataIsValid) { List <Type> creatureRegistry = new List <Type>(); List <TitleEntry> titleRegistry = new List <TitleEntry>(); for (int i = 0; i < 20; i++) { string name = GetTextEntry(String.Format("Creature_{0}", i)); Type type = ScriptCompiler.FindTypeByName(name); if (type != null) { creatureRegistry.Add(type); } } for (int i = 0; i < 10; i++) { string title = GetTextEntry(String.Format("Title_{0}", i)); string count = GetTextEntry(String.Format("Count_{0}", i)); Int32 cnt = 0; Int32.TryParse(count, out cnt); if (title != "" && cnt > 0) { titleRegistry.Add(new TitleEntry(title, cnt)); } } if (_TitleIndex < _TitleDefinitions.Count) { _TitleDefinitions[_TitleIndex] = new TitleDefinition(titleName, enabled, creatureRegistry, titleRegistry); } else { _TitleDefinitions.Add(new TitleDefinition(titleName, enabled, creatureRegistry, titleRegistry)); } if (Address != null) { Address.SendGump(new SlayerTitleSetupGump(_CoreEnabled, _TitleDefinitions, (_TitleIndex / 10) * 10)); } } else { if (Address != null) { Address.SendGump(new TitleDefinitionGump(_CoreEnabled, _TitleDefinitions, _TitleIndex, titleName, enabled, _CreatureNames, _Titles, _Counts, true)); } } }
public CategoryEntry(CategoryEntry parent, CategoryLine[] lines, ref int index) { m_Parent = parent; string text = lines[index].Text; int start = text.IndexOf('('); if (start < 0) { throw new FormatException(String.Format("Input string not correctly formatted ('{0}')", text)); } m_Title = text.Substring(0, start).Trim(); int end = text.IndexOf(')', ++start); if (end < start) { throw new FormatException(String.Format("Input string not correctly formatted ('{0}')", text)); } text = text.Substring(start, end - start); string[] split = text.Split(';'); ArrayList list = new ArrayList(); for (int i = 0; i < split.Length; ++i) { Type type = ScriptCompiler.FindTypeByName(split[i].Trim()); if (type == null) { Console.WriteLine("Match type not found ('{0}')", split[i].Trim()); } else { list.Add(type); } } m_Matches = (Type[])list.ToArray(typeof(Type)); list.Clear(); int ourIndentation = lines[index].Indentation; ++index; while (index < lines.Length && lines[index].Indentation > ourIndentation) { list.Add(new CategoryEntry(this, lines, ref index)); } m_SubCategories = (CategoryEntry[])list.ToArray(typeof(CategoryEntry)); list.Clear(); m_Matched = list; }
/// <summary> /// Verifies if the types for the player backpack and /// </summary> public void ValidateTypes() { Type t = null; // Item in backpack if (m_ReactToItemInBackpack && m_TypeBackpack != null) { t = ScriptCompiler.FindTypeByName(m_TypeBackpack, true); if (t == null) { t = ScriptCompiler.FindTypeByFullName(m_TypeBackpack, true); } m_ItemType = t; if (t == null) // If the item doesn't exist, don't bother checking { m_ReactToItemInBackpack = false; } } // Item given if (m_ReactToItemGiven && m_TypeGiven != null) { t = ScriptCompiler.FindTypeByName(m_TypeGiven, true); if (t == null) { t = ScriptCompiler.FindTypeByFullName(m_TypeGiven, true); } m_ItemGivenType = t; if (t == null) { m_ReactToItemGiven = false; } } // Function if (m_TriggerFunction) { t = DialogNPC.FindType(m_FunctionType); if (t == null) { m_TriggerFunction = false; return; } m_Method = t.GetMethod(m_FunctionName, new Type[] { typeof(DialogNPC), typeof(Mobile) }); if (m_Method == null) { m_TriggerFunction = false; } } }
public void ApplyButtonPressed(IGumpComponent sender, object param) { String[] values = new String[] { GetTextEntry("Food Type"), GetTextEntry("Hit Point Regen"), GetTextEntry("Stamina Regen"), GetTextEntry("Mana Regen"), GetTextEntry("STR Bonus"), GetTextEntry("DEX Bonus"), GetTextEntry("INT Bonus"), GetTextEntry("Duration") }; Boolean valid = true; valid &= IsFoodType(values[0]); for (Int32 i = 1; i < 8; i++) { valid &= IsValidNumber(values[i], (i < 7)); } if (valid) { Int32[] parsedValues = new Int32[] { 0, 0, 0, 0, 0, 0, 0 }; for (Int32 i = 1; i < 8; i++) { Int32.TryParse(values[i], out parsedValues[i - 1]); } FoodEffect effect = new FoodEffect(parsedValues[0], parsedValues[1], parsedValues[2], parsedValues[3], parsedValues[4], parsedValues[5], parsedValues[6]); Type type = ScriptCompiler.FindTypeByName(values[0]); if (_EffectIndex < _FoodTypes.Count) { _FoodTypes[_EffectIndex] = type; _FoodEffects[_EffectIndex] = effect; } else { _FoodTypes.Add(type); _FoodEffects.Add(effect); } if (Address != null) { Address.SendGump(new FoodEffectsSetupGump(_CoreEnabled, _FoodTypes, _FoodEffects, (_EffectIndex / 10) * 10)); } } else if (Address != null) { Address.SendGump(new FoodEffectGump(_CoreEnabled, _FoodTypes, _FoodEffects, _EffectIndex, values, true)); } }
public virtual bool HandleDrop(Mobile from, Item dropped) { if (m_Collected >= m_Needed) { from.SendAsciiMessage("We have received all that we need of that already! Thanks anyways!"); return(false); } if (m_Type == null) { if (CollectionType == null) { from.SendAsciiMessage("That does not belong in this collection barrel!"); return(false); } try { m_Type = ScriptCompiler.FindTypeByName(CollectionType, true); } catch { } if (m_Type == null) { from.SendAsciiMessage("That does not belong in this collection barrel!"); return(false); } } if (CheckItem(dropped)) { from.SendAsciiMessage("Thank you for your donation to our cause!"); from.SendSound(GetDroppedSound(dropped), GetWorldLocation()); m_Collected += dropped.Amount; if (m_Record.ContainsKey(from)) { m_Record[from] += dropped.Amount; } else { m_Record.Add(from, dropped.Amount); } dropped.Delete(); return(true); } else { from.SendAsciiMessage("That does not belong in this collection barrel!"); return(false); } }
public TradeDetails(GenericReader reader) { int version = reader.ReadInt(); ItemType = ScriptCompiler.FindTypeByName(reader.ReadString()); Worth = reader.ReadInt(); Amount = reader.ReadInt(); Name = reader.ReadString(); }
public virtual void Deserialize(GenericReader reader) { int version = reader.ReadEncodedInt(); if (version > 0) { string questerType = reader.ReadString(); if (questerType != null) { m_QuesterType = ScriptCompiler.FindTypeByName(questerType); } } switch (reader.ReadInt()) { case 0x0: m_Quester = null; break; case 0x1: m_Quester = reader.ReadMobile() as NewQuester; break; case 0x2: m_Quester = reader.ReadItem() as BaseQuestItem; break; } /* * if (m_Quester is BaseEscort) * { * BaseEscort escort = (BaseEscort)m_Quester; * * escort.Quest = this; * } */ if (m_Quester is BaseQuestItem) { BaseQuestItem item = (BaseQuestItem)m_Quester; item.Quest = this; } if (version == 0 && m_Quester != null) { m_QuesterType = m_Quester.GetType(); } for (int i = 0; i < m_Objectives.Count; i++) { BaseObjective objective = m_Objectives[i]; objective.Deserialize(reader); } }
public static object ParseValue(Type type, string value) { try { if (IsEnum(type)) { return(Enum.Parse(type, value, true)); } else if (IsType(type)) { return(ScriptCompiler.FindTypeByName(value)); } else if (IsParsable(type)) { return(ParseParsable(type, value)); } else { object obj = value; if (value != null && value.StartsWith("0x")) { if (IsSignedNumeric(type)) { obj = Convert.ToInt64(value.Substring(2), 16); } else if (IsUnsignedNumeric(type)) { obj = Convert.ToUInt64(value.Substring(2), 16); } obj = Convert.ToInt32(value.Substring(2), 16); } if (obj == null && !type.IsValueType) { return(null); } else { return(Convert.ChangeType(obj, type)); } } } catch { return(null); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); reader.ReadInt(); GuardImmune = reader.ReadBool(); m_SpawnRange = reader.ReadInt(); m_WalkingRange = reader.ReadInt(); WayPoint = reader.ReadItem() as WayPoint; m_Group = reader.ReadBool(); m_MinDelay = reader.ReadTimeSpan(); m_MaxDelay = reader.ReadTimeSpan(); m_MaxCount = reader.ReadInt(); m_Team = reader.ReadInt(); m_HomeRange = reader.ReadInt(); m_Running = reader.ReadBool(); TimeSpan ts = TimeSpan.Zero; if (m_Running) { ts = reader.ReadDeltaTime() - DateTime.UtcNow; } int size = reader.ReadInt(); m_SpawnObjects = new List <SpawnObject>(size); for (int i = 0; i < size; ++i) { SpawnObject so = new SpawnObject(reader); if (AddSpawnObject(so)) { string typeName = ParseType(so.SpawnName); if (ScriptCompiler.FindTypeByName(typeName) == null) { if (m_WarnTimer == null) { m_WarnTimer = new WarnTimer(); } m_WarnTimer.Add(Location, Map, typeName); } } } if (m_Running) { DoTimer(ts); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); string name = reader.ReadString(); m_TypeName = ScriptCompiler.FindTypeByName(name); m_FishWeight = reader.ReadInt(); m_Fisher = reader.ReadMobile(); m_DateCaught = reader.ReadDateTime(); }
private static void GetItems(string name, Mobile from) { if (ScriptCompiler.FindTypeByName(name) == null) { from.SendMessage("No type with that name was found."); return; } Type type = ScriptCompiler.FindTypeByName(name); BuildMobileList(type); }
private Type ValidateType(String typeName) { Type type = ScriptCompiler.FindTypeByName(typeName); if (type != null && typeof(ISpawnable).IsAssignableFrom(type)) { return(type); } else { return(null); } }
/// <summary> /// Finds a type through its name /// </summary> /// <param name="name">The type name</param> /// <returns>A Type is a match is found, null if none</returns> public static Type FindType(string name) { Type t = ScriptCompiler.FindTypeByName(name, true); if (t != null) { return(t); } t = ScriptCompiler.FindTypeByFullName(name, true); return(t); }
public static void FindMobileByType_OnCommand(CommandEventArgs e) { try { if (e.Length == 1) { if (e == null || e.Mobile == null || e.Mobile is PlayerMobile == false) { return; } // if you are a GM the world needs to be in 'Build' mode to access this comand if (e.Mobile.AccessLevel < AccessLevel.Administrator && Core.Building == false) { e.Mobile.SendMessage("The server must be in build mode for you to access this command."); return; } PlayerMobile pm = e.Mobile as PlayerMobile; LogHelper Logger = new LogHelper("FindMobileByType.log", e.Mobile, false); string name = e.GetString(0); // reset jump table pm.JumpIndex = 0; pm.JumpList = new ArrayList(); Type tx = ScriptCompiler.FindTypeByName(name); if (tx != null) { foreach (Mobile mob in World.Mobiles.Values) { if (mob != null && !mob.Deleted && tx.IsAssignableFrom(mob.GetType())) { pm.JumpList.Add(mob); Logger.Log(LogType.Mobile, mob); } } } else { e.Mobile.SendMessage("{0} is not a recognized type.", name); } Logger.Finish(); } else { e.Mobile.SendMessage("Format: FindMobileByType <type>"); } } catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); } }