public void ClonePlaceableWithLocalStateIsCopied(string placeableResRef) { Location startLocation = NwModule.Instance.StartingLocation; NwPlaceable?placeable = NwPlaceable.Create(placeableResRef, startLocation); Assert.That(placeable, Is.Not.Null, $"Placeable {placeableResRef} was null after creation."); Assert.That(placeable !.IsValid, Is.True, $"Placeable {placeableResRef} was invalid after creation."); createdTestObjects.Add(placeable); LocalVariableInt testVar = placeable.GetObjectVariable <LocalVariableInt>("test"); testVar.Value = 9999; NwPlaceable clone = placeable.Clone(startLocation); Assert.That(clone, Is.Not.Null, $"Placeable {placeableResRef} was null after clone."); Assert.That(clone.IsValid, Is.True, $"Placeable {placeableResRef} was invalid after clone."); createdTestObjects.Add(clone); LocalVariableInt cloneTestVar = clone.GetObjectVariable <LocalVariableInt>("test"); Assert.That(cloneTestVar.HasValue, Is.True, "Local variable did not exist on the clone with copyLocalState = true."); Assert.That(cloneTestVar.Value, Is.EqualTo(testVar.Value), "Local variable on the cloned placeable did not match the value of the original placeable."); }
public void CreatePlaceableIsCreated(string placeableResRef) { Location startLocation = NwModule.Instance.StartingLocation; NwPlaceable?placeable = NwPlaceable.Create(placeableResRef, startLocation); Assert.That(placeable, Is.Not.Null, $"Placeable {placeableResRef} was null after creation."); Assert.That(placeable !.IsValid, Is.True, $"Placeable {placeableResRef} was invalid after creation."); createdTestObjects.Add(placeable); }
public void ClonePlaceableCustomTagIsApplied(string placeableResRef) { Location startLocation = NwModule.Instance.StartingLocation; NwPlaceable?placeable = NwPlaceable.Create(placeableResRef, startLocation); Assert.That(placeable, Is.Not.Null, $"Placeable {placeableResRef} was null after creation."); Assert.That(placeable !.IsValid, Is.True, $"Placeable {placeableResRef} was invalid after creation."); createdTestObjects.Add(placeable); string expectedNewTag = "expectedNewTag"; NwPlaceable clone = placeable.Clone(startLocation, expectedNewTag, false); Assert.That(clone, Is.Not.Null, $"Placeable {placeableResRef} was null after clone."); Assert.That(clone.IsValid, Is.True, $"Placeable {placeableResRef} was invalid after clone."); createdTestObjects.Add(clone); Assert.That(clone.Tag, Is.EqualTo(expectedNewTag), "Tag defined in clone method was not applied to the cloned placeable."); }
public void ClonePlaceableWithoutTagOriginalTagIsCopied(string placeableResRef) { Location startLocation = NwModule.Instance.StartingLocation; NwPlaceable?placeable = NwPlaceable.Create(placeableResRef, startLocation); Assert.That(placeable, Is.Not.Null, $"Placeable {placeableResRef} was null after creation."); Assert.That(placeable !.IsValid, Is.True, $"Placeable {placeableResRef} was invalid after creation."); createdTestObjects.Add(placeable); placeable.Tag = "expectedNewTag"; NwPlaceable clone = placeable.Clone(startLocation, null, false); Assert.That(clone, Is.Not.Null, $"Placeable {placeableResRef} was null after clone."); Assert.That(clone.IsValid, Is.True, $"Placeable {placeableResRef} was invalid after clone."); createdTestObjects.Add(clone); Assert.That(clone.Tag, Is.EqualTo(placeable.Tag), "Cloned placeable's tag did not match the original placeable's."); }
public void SerializePlaceableCreatesValidData(string placeableResRef) { Location startLocation = NwModule.Instance.StartingLocation; NwPlaceable?placeable = NwPlaceable.Create(placeableResRef, startLocation); Assert.That(placeable, Is.Not.Null, $"Placeable {placeableResRef} was null after creation."); Assert.That(placeable !.IsValid, Is.True, $"Placeable {placeableResRef} was invalid after creation."); createdTestObjects.Add(placeable); byte[]? placeableData = placeable.Serialize(); Assert.That(placeableData, Is.Not.Null); Assert.That(placeableData, Has.Length.GreaterThan(0)); NwPlaceable?placeable2 = NwPlaceable.Deserialize(placeableData !); Assert.That(placeable2, Is.Not.Null); Assert.That(placeable2 !.IsValid, Is.True); createdTestObjects.Add(placeable2); Assert.That(placeable2.Area, Is.Null); }
public static void Signal(NwObject caster, NwPlaceable target, NwSpell spell, bool harmful = true) { Event nwEvent = NWScript.EventSpellCastAt(caster, spell.Id, harmful.ToInt()) !; NWScript.SignalEvent(target, nwEvent); }
public static void SetPlaceableNameOverride(this NwPlayer player, NwPlaceable placeable, string name) { PlayerPlugin.SetPlaceableNameOverride(player, placeable, name); }
public static void ForceOpenInventory(this NwPlayer player, NwPlaceable target) { PlayerPlugin.ForcePlaceableInventoryWindow(player, target); }
public static void SetIsStatic(this NwPlaceable placeable, bool value) { ObjectPlugin.SetPlaceableIsStatic(placeable, value.ToInt()); }
public static bool GetIsStatic(this NwPlaceable placeable) { return(ObjectPlugin.GetPlaceableIsStatic(placeable).ToBool()); }
public static void Signal(NwPlaceable placeable, int eventId) { Event nwEvent = NWScript.EventUserDefined(eventId) !; NWScript.SignalEvent(placeable, nwEvent); }