public void DisableAPI() { // Some calls assuring the Disable() API is accessible and working. SkyrimMod sourceMod = new SkyrimMod(Utility.PluginModKey, SkyrimRelease.SkyrimSE); FormKey key = sourceMod.GetNextFormKey(); PlacedObject placedObject = new PlacedObject(key, SkyrimRelease.SkyrimSE); // Simplistic Disable access and verification. PlacedObject disabledObj = placedObject; disabledObj.Disable(); //_testOutputHelper.WriteLine($"{disabledPlacedObject.MajorRecordFlagsRaw}"); Assert.True(EnumExt.HasFlag(disabledObj.MajorRecordFlagsRaw, Constants.InitiallyDisabled)); MajorRecord majorRecord = placedObject; majorRecord.Disable(); Assert.True(EnumExt.HasFlag(majorRecord.MajorRecordFlagsRaw, Constants.InitiallyDisabled)); IMajorRecordCommon interfaceRecord = placedObject; interfaceRecord.Disable(); Assert.True(EnumExt.HasFlag(interfaceRecord.MajorRecordFlagsRaw, Constants.InitiallyDisabled)); IPlaced interfacePlaced = placedObject; interfacePlaced.Disable(); Assert.True(EnumExt.HasFlag(interfacePlaced.MajorRecordFlagsRaw, Constants.InitiallyDisabled)); // Sanity test both API are invokable under Placed context. PlacedTrap placedTrap = new PlacedTrap(key, SkyrimRelease.SkyrimSE); placedTrap.Disable(IPlaced.DisableType.DisableWithoutZOffset); interfacePlaced = placedTrap; interfacePlaced.Disable(IPlaced.DisableType.JustInitiallyDisabled); IPlaced abstractPlaced = placedTrap; abstractPlaced.Disable(); abstractPlaced.Disable(IPlaced.DisableType.SafeDisable); //Try any other object other than Placed (invoke MajorRecord.Disable() and see if it works) var armor = new Armor(key, SkyrimRelease.SkyrimSE); armor.Disable(); Assert.True(EnumExt.HasFlag(armor.MajorRecordFlagsRaw, Constants.InitiallyDisabled)); }
/// <summary> /// Disables the placed object using standard undelete and disable procedure. This will flag the record <br/> /// as Initially Disabled, set the Enable Parent to be opposite of the Player and set the Z-Offset to /// -30000. /// </summary> /// <returns>True if the disable was successful.</returns> public static bool Disable(this IPlaced placed) { return(placed.Disable(DisableType.SafeDisable)); }