public static GameSettingString AddNewShort(this IGroupCommon <GameSetting> gameSettings, string editorId) { var ret = new GameSettingString( gameSettings.SourceMod.GetNextFormKey(editorId)); gameSettings.Add(ret); return(ret); }
public static GlobalShort AddNewShort(this IGroupCommon <Global> globals, string editorId) { var ret = new GlobalShort( globals.SourceMod.GetNextFormKey(editorId)); globals.Add(ret); return(ret); }
public static GameSettingFloat AddNewFloat(this IGroupCommon <GameSetting> gameSettings) { var ret = new GameSettingFloat( gameSettings.SourceMod.GetNextFormKey()); gameSettings.Add(ret); return(ret); }
public static GlobalFloat AddNewFloat(this IGroupCommon <Global> globals) { var ret = new GlobalFloat( globals.SourceMod.GetNextFormKey()); globals.Add(ret); return(ret); }
public static GameSettingString AddNewShort(this IGroupCommon <GameSetting> gameSettings) { var ret = new GameSettingString( gameSettings.SourceMod.GetNextFormKey(), gameSettings.SourceMod.GameRelease.ToSkyrimRelease()); gameSettings.Add(ret); return(ret); }
public static GameSettingInt AddNewInt(this IGroupCommon <GameSetting> gameSettings, string editorId) { var ret = new GameSettingInt( gameSettings.SourceMod.GetNextFormKey(editorId), gameSettings.SourceMod.GameRelease.ToSkyrimRelease()); gameSettings.Add(ret); return(ret); }
public static GlobalInt AddNewInt(this IGroupCommon <Global> globals, string editorId) { var ret = new GlobalInt( globals.SourceMod.GetNextFormKey(editorId), globals.SourceMod.GameRelease.ToSkyrimRelease()); globals.Add(ret); return(ret); }
/// <summary> /// Duplicates a given record (giving it a new FormID) adding it to the group and returning it. /// </summary> /// <param name="group">Group to add to</param> /// <param name="edid">EditorID to drive the FormID assignment off any persistance systems</param> /// <param name="source">Source record to duplicate</param> /// <returns>Duplicated and added record</returns> public static TMajor DuplicateIn <TMajor, TMajorGetter>(this IGroupCommon <TMajor> group, string edid, TMajorGetter source) where TMajor : IMajorRecordCommon, TMajorGetter where TMajorGetter : IMajorRecordCommonGetter, IBinaryItem, IDuplicatable { var ret = (TMajor)source.Duplicate(() => group.SourceMod.GetNextFormKey(edid)); group.Add(ret); return(ret); }
public static GlobalShort AddNewShort(this IGroupCommon <Global> globals) { var ret = new GlobalShort( globals.SourceMod.GetNextFormKey(), globals.SourceMod.GameRelease.ToSkyrimRelease()); globals.Add(ret); return(ret); }
/// <summary> /// Takes in a FormLink, and either returns the existing override definition /// from the Group, or attempts to link and copy the given record, inserting it, and then returning it as an override. /// </summary> /// <param name="group">Group to retrieve and/or insert from</param> /// <param name="link">Link to query and add</param> /// <param name="cache">Cache to query link against</param> /// <param name="rec">Retrieved record if successful</param> /// <returns>True if a record was retrieved</returns> public static TMajor GetOrAddAsOverride <TMajor, TMajorGetter>(this IGroupCommon <TMajor> group, IFormLinkGetter <TMajorGetter> link, ILinkCache cache) where TMajor : class, IMajorRecordInternal, TMajorGetter where TMajorGetter : class, IMajorRecordGetter { if (TryGetOrAddAsOverride(group, link, cache, out var rec)) { return(rec); } throw new MissingRecordException(link.FormKey, link.Type); }
/// <summary> /// Convenience function to instantiate a new Major Record and add it to the Group<br /> /// </summary> /// <param name="group">Group to add a record to</param> /// <param name="formKey">FormKey assign the new record.</param> /// <returns>New record already added to the Group</returns> public static TMajor AddNew <TMajor>(this IGroupCommon <TMajor> group, FormKey formKey) where TMajor : IMajorRecordInternal, IBinaryItem { var ret = MajorRecordInstantiator <TMajor> .Activator( formKey, group.SourceMod.GameRelease); group.Set(ret); return(ret); }
/// <summary> /// Convenience function to instantiate a new Major Record and add it to the Group.<br /> /// FormKey will be automatically assigned. /// </summary> /// <param name="group">Group to add a record to</param> /// <returns>New record already added to the Group</returns> public static TMajor AddNew <TMajor>(this IGroupCommon <TMajor> group) where TMajor : IMajorRecordInternal { var ret = MajorRecordInstantiator <TMajor> .Activator( group.SourceMod.GetNextFormKey(), group.SourceMod.GameRelease); group.Set(ret); return(ret); }
/// <summary> /// Convenience function to instantiate a new Major Record and add it to the Group.<br /> /// FormKey will be automatically assigned based on the editorID given /// </summary> /// <param name="group">Group to add a record to</param> /// <param name="editorID">Editor ID to assign the new record, and use in any FormKey persistence logic.</param> /// <returns>New record already added to the Group</returns> public static TMajor AddNew <TMajor>(this IGroupCommon <TMajor> group, string?editorID) where TMajor : IMajorRecordInternal, IBinaryItem { var ret = MajorRecordInstantiator <TMajor> .Activator( group.SourceMod.GetNextFormKey(editorID), group.SourceMod.GameRelease); ret.EditorID = editorID; group.Set(ret); return(ret); }
/// <summary> /// Duplicates a given record (giving it a new FormID) adding it to the group and returning it. /// </summary> /// <param name="group">Group to add to</param> /// <param name="source">Source record to duplicate</param> /// <param name="edid">EditorID to drive the FormID assignment off any persistance systems</param> /// <returns>Duplicated and added record</returns> public static TMajor DuplicateInAsNewRecord <TMajor, TMajorGetter>(this IGroupCommon <TMajor> group, TMajorGetter source, string?edid) where TMajor : IMajorRecordInternal, TMajorGetter where TMajorGetter : IMajorRecordGetter, IBinaryItem { try { var newRec = group.AddNew(edid); var mask = OverrideMixIns.AddAsOverrideMasks.GetValueOrDefault(typeof(TMajor)); newRec.DeepCopyIn(source, mask as MajorRecord.TranslationMask); group.RecordCache.Set(newRec); return(newRec); } catch (Exception ex) { throw RecordException.Factory(ex, source.FormKey, source.EditorID); } }
/// <summary> /// Takes in an existing record definition, and either returns the existing override definition /// from the Group, or copies the given record, inserts it, and then returns it as an override. /// </summary> /// <param name="group">Group to retrieve and/or insert from</param> /// <param name="major">Major record to query and potentially copy</param> /// <returns>Existing override record, or a copy of the given record that has already been inserted into the group</returns> public static TMajor GetOrAddAsOverride <TMajor, TMajorGetter>(this IGroupCommon <TMajor> group, TMajorGetter major) where TMajor : class, IMajorRecordInternal, TMajorGetter where TMajorGetter : class, IMajorRecordGetter { try { if (group.RecordCache.TryGetValue(major.FormKey, out var existingMajor)) { return(existingMajor); } var mask = AddAsOverrideMasks.GetValueOrDefault(typeof(TMajor)); existingMajor = (major.DeepCopy(mask as MajorRecord.TranslationMask) as TMajor) !; group.RecordCache.Set(existingMajor); return(existingMajor); } catch (Exception ex) { throw RecordException.Enrich <TMajor>(ex, major.FormKey, major.EditorID); } }
/// <summary> /// Takes in a FormLink, and either returns the existing override definition /// from the Group, or attempts to link and copy the given record, inserting it, and then returning it as an override. /// </summary> /// <param name="group">Group to retrieve and/or insert from</param> /// <param name="link">Link to query and add</param> /// <param name="cache">Cache to query link against</param> /// <param name="rec">Retrieved record if successful</param> /// <returns>True if a record was retrieved</returns> public static bool TryGetOrAddAsOverride <TMajor, TMajorGetter>(this IGroupCommon <TMajor> group, IFormLinkGetter <TMajorGetter> link, ILinkCache cache, [MaybeNullWhen(false)] out TMajor rec) where TMajor : class, IMajorRecordInternal, TMajorGetter where TMajorGetter : class, IMajorRecordGetter { try { if (group.RecordCache.TryGetValue(link.FormKey, out rec)) { return(true); } if (!link.TryResolve <TMajorGetter>(cache, out var getter)) { rec = default; return(false); } rec = GetOrAddAsOverride(group, getter); return(true); } catch (Exception ex) { throw RecordException.Enrich <TMajor>(ex, link.FormKey, edid: null); } }
/// <summary> /// Duplicates a given record (giving it a new FormID) adding it to the group and returning it. /// </summary> /// <param name="group">Group to add to</param> /// <param name="source">Source record to duplicate</param> /// <param name="edid">EditorID to drive the FormID assignment off any persistence systems</param> /// <returns>Duplicated and added record</returns> public static TMajor DuplicateInAsNewRecord <TMajor, TMajorGetter>(this IGroupCommon <TMajor> group, TMajorGetter source, string?edid) where TMajor : class, IMajorRecordInternal, TMajorGetter where TMajorGetter : IMajorRecordGetter, IBinaryItem { return(DuplicateInAsNewRecord <TMajor, TMajorGetter, TMajorGetter>(group, source, edid)); }
/// <summary> /// Duplicates a given record (giving it a new FormID) adding it to the group and returning it. /// </summary> /// <param name="group">Group to add to</param> /// <param name="source">Source record to duplicate</param> /// <returns>Duplicated and added record</returns> public static TMajor DuplicateInAsNewRecord <TMajor, TMajorGetter>(this IGroupCommon <TMajor> group, TMajorGetter source) where TMajor : class, IMajorRecordInternal, TMajorGetter where TMajorGetter : IMajorRecordGetter { return(DuplicateInAsNewRecord <TMajor, TMajorGetter, TMajorGetter>(group, source)); }
/// <summary> /// Duplicates a given record (giving it a new FormID) adding it to the group and returning it. /// </summary> /// <param name="group">Group to add to</param> /// <param name="source">Source record to duplicate</param> /// <returns>Duplicated and added record</returns> public static TMajor DuplicateInAsNewRecord <TMajor, TMajorGetter, TSharedParent>(this IGroupCommon <TMajor> group, TMajorGetter source) where TMajor : class, IMajorRecordInternal, TSharedParent where TMajorGetter : TSharedParent where TSharedParent : IMajorRecordGetter { try { var newRec = (source.Duplicate(group.SourceMod.GetNextFormKey()) as TMajor) !; group.Add(newRec); return(newRec); } catch (Exception ex) { throw RecordException.Enrich <TMajor>(ex, source.FormKey, source.EditorID); } }