public void CloneItemNoLocalStateIsNotCopied(string itemResRef) { Location startLocation = NwModule.Instance.StartingLocation; NwItem? item = NwItem.Create(itemResRef, startLocation); Assert.That(item, Is.Not.Null, $"Item {itemResRef} was null after creation."); Assert.That(item !.IsValid, Is.True, $"Item {itemResRef} was invalid after creation."); createdTestObjects.Add(item); LocalVariableInt testVar = item.GetObjectVariable <LocalVariableInt>("test"); testVar.Value = 9999; NwItem clone = item.Clone(startLocation, null, false); Assert.That(clone, Is.Not.Null, $"Item {itemResRef} was null after clone."); Assert.That(clone.IsValid, Is.True, $"Item {itemResRef} was invalid after clone."); createdTestObjects.Add(clone); LocalVariableInt cloneTestVar = clone.GetObjectVariable <LocalVariableInt>("test"); Assert.That(cloneTestVar.HasValue, Is.False, "Local variable exists on the clone with copyLocalState = false."); Assert.That(cloneTestVar.Value, Is.Not.EqualTo(testVar.Value), "Local variable on the cloned item matches the value of the original item."); }
public void CloneDoorNoLocalStateIsNotCopied(string doorResRef) { Location startLocation = NwModule.Instance.StartingLocation; NwDoor? door = NwDoor.Create(doorResRef, startLocation); Assert.That(door, Is.Not.Null, $"Door {doorResRef} was null after creation."); Assert.That(door !.IsValid, Is.True, $"Door {doorResRef} was invalid after creation."); createdTestObjects.Add(door); LocalVariableInt testVar = door.GetObjectVariable <LocalVariableInt>("test"); testVar.Value = 9999; NwDoor clone = door.Clone(startLocation, null, false); Assert.That(clone, Is.Not.Null, $"Door {doorResRef} was null after clone."); Assert.That(clone.IsValid, Is.True, $"Door {doorResRef} was invalid after clone."); createdTestObjects.Add(clone); LocalVariableInt cloneTestVar = clone.GetObjectVariable <LocalVariableInt>("test"); Assert.That(cloneTestVar.HasValue, Is.False, "Local variable exists on the clone with copyLocalState = false."); Assert.That(cloneTestVar.Value, Is.Not.EqualTo(testVar.Value), "Local variable on the cloned door matches the value of the original door."); }
public void CloneCreatureWithLocalStateIsCopied(string creatureResRef) { Location startLocation = NwModule.Instance.StartingLocation; NwCreature?creature = NwCreature.Create(creatureResRef, startLocation); Assert.That(creature, Is.Not.Null, $"Creature {creatureResRef} was null after creation."); Assert.That(creature !.IsValid, Is.True, $"Creature {creatureResRef} was invalid after creation."); createdTestObjects.Add(creature); LocalVariableInt testVar = creature.GetObjectVariable <LocalVariableInt>("test"); testVar.Value = 9999; NwCreature clone = creature.Clone(startLocation); Assert.That(clone, Is.Not.Null, $"Creature {creatureResRef} was null after clone."); Assert.That(clone.IsValid, Is.True, $"Creature {creatureResRef} 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 creature did not match the value of the original creature."); }
public void CloneStoreNoLocalStateIsNotCopied(string storeResRef) { Location startLocation = NwModule.Instance.StartingLocation; NwStore? store = NwStore.Create(storeResRef, startLocation); Assert.That(store, Is.Not.Null, $"Store {storeResRef} was null after creation."); Assert.That(store !.IsValid, Is.True, $"Store {storeResRef} was invalid after creation."); createdTestObjects.Add(store); LocalVariableInt testVar = store.GetObjectVariable <LocalVariableInt>("test"); testVar.Value = 9999; NwStore clone = store.Clone(startLocation, null, false); Assert.That(clone, Is.Not.Null, $"Store {storeResRef} was null after clone."); Assert.That(clone.IsValid, Is.True, $"Store {storeResRef} was invalid after clone."); createdTestObjects.Add(clone); LocalVariableInt cloneTestVar = clone.GetObjectVariable <LocalVariableInt>("test"); Assert.That(cloneTestVar.HasValue, Is.False, "Local variable exists on the clone with copyLocalState = false."); Assert.That(cloneTestVar.Value, Is.Not.EqualTo(testVar.Value), "Local variable on the cloned store matches the value of the original store."); }
public void CloneWaypointWithLocalStateIsCopied(string waypointResRef) { Location startLocation = NwModule.Instance.StartingLocation; NwWaypoint?waypoint = NwWaypoint.Create(waypointResRef, startLocation); Assert.That(waypoint, Is.Not.Null, $"Waypoint {waypointResRef} was null after creation."); Assert.That(waypoint !.IsValid, Is.True, $"Waypoint {waypointResRef} was invalid after creation."); createdTestObjects.Add(waypoint); LocalVariableInt testVar = waypoint.GetObjectVariable <LocalVariableInt>("test"); testVar.Value = 9999; NwWaypoint clone = waypoint.Clone(startLocation); Assert.That(clone, Is.Not.Null, $"Waypoint {waypointResRef} was null after clone."); Assert.That(clone.IsValid, Is.True, $"Waypoint {waypointResRef} 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 waypoint did not match the value of the original waypoint."); }
public void CloneTriggerWithLocalStateIsCopied(string triggerResRef) { Location startLocation = NwModule.Instance.StartingLocation; NwTrigger?trigger = NwTrigger.Create(triggerResRef, startLocation); Assert.That(trigger, Is.Not.Null, $"Trigger {triggerResRef} was null after creation."); Assert.That(trigger !.IsValid, Is.True, $"Trigger {triggerResRef} was invalid after creation."); createdTestObjects.Add(trigger); LocalVariableInt testVar = trigger.GetObjectVariable <LocalVariableInt>("test"); testVar.Value = 9999; NwTrigger clone = trigger.Clone(startLocation); Assert.That(clone, Is.Not.Null, $"Trigger {triggerResRef} was null after clone."); Assert.That(clone.IsValid, Is.True, $"Trigger {triggerResRef} 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 trigger did not match the value of the original trigger."); }