public ObjectInstance Clone(ObjectInstance source, params object[] args) { Validation.IsNotNull(source, "source"); var obj = new ObjectInstance(GetNextId, source.Name, 99, 99) { Parent = source.Parent, Level = source.Level, WearLocation = source.WearLocation, Count = source.Count, ShortDescription = source.ShortDescription, Description = source.Description, Action = source.Action, ItemType = source.ItemType, ExtraFlags = source.ExtraFlags, Weight = source.Weight, Cost = source.Cost, WearFlags = source.WearFlags, Owner = source.Owner, MagicFlags = source.MagicFlags, Timer = source.Timer, Values = source.Values }; source.Value = new List <int>(obj.Value); if (ObjectActionTable.ContainsKey(obj.ItemType)) { ObjectActionTable[obj.ItemType].Invoke(obj); } Add(obj.ID, obj); return(obj); }
public ObjectInstance Create(Template parent, params object[] args) { Validation.IsNotNull(parent, "parent"); Validation.Validate(parent is ObjectTemplate, "Invalid Template Type"); var objParent = parent.CastAs <ObjectTemplate>(); long id; if (args != null && args.Length > 0) { id = Convert.ToInt64(args[0]); } else { id = GetNextId; } var name = parent.Name; if (args != null && args.Length > 1) { name = args[1].ToString(); } var obj = new ObjectInstance(id, name, 99, 99) { Parent = parent, Level = args == null || args.Length == 0 ? 1 : (int)args[0], WearLocation = WearLocations.None, Count = 1, ShortDescription = objParent.ShortDescription, Description = parent.Description, Action = objParent.Action, ItemType = objParent.Type, ExtraFlags = objParent.ExtraFlags, Weight = objParent.Weight, Cost = objParent.Cost, Values = objParent.Values }; foreach (var wearLoc in objParent.GetWearFlags()) { obj.WearFlags += (int)wearLoc; } //Array.Copy(objParent.Value, obj.Value, 5); if (ObjectActionTable.ContainsKey(obj.ItemType)) { ObjectActionTable[obj.ItemType].Invoke(obj); } Add(obj.ID, obj); return(obj); }