static void AddItem(string codeName, DDLItem instance) { DDLString str; if (!instance.TryGetValue("visual", out str)) { return; } string modelName = Path.GetFileNameWithoutExtension(str.Value); ModelDef model; if (!ModelDef.TryGetModel(modelName, out model)) { model = new ModelDef(modelName, str.Value); model.Create(); } ItemDef item = ItemDef.Get(codeName); if (item == null) { item = new ItemDef(codeName); } else { item.Delete(); } item.Model = model; if (instance.TryGetValue("name", out str)) { item.Name = str.Value; } if (string.IsNullOrWhiteSpace(item.Name)) { item.Name = "no name (" + codeName + ")"; } if (instance.TryGetValue("effect", out str)) { item.Effect = str.Value; } item.Create(); }
static void AddNPC(string codeName, DDLNpc instance) { DDLString str; if (!instance.TryGetValue("visual", out str)) { return; } string modelName = Path.GetFileNameWithoutExtension(str.Value); ModelDef model; if (!ModelDef.TryGetModel(modelName, out model)) { model = new ModelDef(modelName, str.Value); model.Create(); } NPCDef npc = NPCDef.Get(codeName); if (npc == null) { npc = new NPCDef(codeName); } else { npc.Delete(); } npc.Model = model; if (instance.TryGetValue("name", out str)) { npc.Name = str.Value; } if (string.IsNullOrWhiteSpace(npc.Name)) { npc.Name = "no name (" + codeName + ")"; } if (instance.TryGetValue("bodymesh", out str)) { npc.BodyMesh = str.Value; } if (instance.TryGetValue("headmesh", out str)) { npc.HeadMesh = str.Value; } DDLInt dint; if (instance.TryGetValue("bodytex", out dint)) { npc.BodyTex = dint.Value; } if (instance.TryGetValue("headtex", out dint)) { npc.HeadTex = dint.Value; } npc.Create(); }