public virtual void Save(LwoObject lwo) { var componentAttribute = GetType().GetCustomAttribute <GameComponentAttribute>(); if (componentAttribute == null) { return; } var lwoComponent = lwo.Add(componentAttribute.ComponentId, componentAttribute.Table); if (lwoComponent.Row == null) { return; } foreach (var field in GetType().GetFields()) { var attribute = field.GetCustomAttribute <LoadFieldAttribute>(); if (attribute == null) { continue; } lwoComponent.Row[attribute.Name].Value = field.GetValue(this); } }
public override void Save(LwoObject lwo) { base.Save(lwo); var skillsTable = WorkspaceControl.Database["ObjectSkills"]; var skills = skillsTable.Where(s => s.Key == Lot); foreach (var skill in skills.ToArray()) { skillsTable.Remove(skill); } foreach (var skill in _skills) { var entry = skillsTable.Create(Lot); entry["skillID"].Value = skill._skillId; entry["castOnType"].Value = skill._castOnType; entry["AICombatWeight"].Value = skill._aiCombatWeight; } }
public static T GetComponent <T>(this LwoObject @this) where T : class { var name = typeof(T).Name; foreach (var component in @this) { if (component.Row?.Table?.Name == default) { continue; } if ($"{component.Row.Table.Name}Table" != name) { continue; } var instance = Activator.CreateInstance(typeof(T), component.Row) as T; return(instance); } return(default);