示例#1
0
        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.");
        }
示例#2
0
        public void CreateDoorIsCreated(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);
        }
示例#3
0
        public void CloneDoorWithoutTagOriginalTagIsCopied(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);
            door.Tag = "expectedNewTag";

            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);

            Assert.That(clone.Tag, Is.EqualTo(door.Tag), "Cloned door's tag did not match the original door's.");
        }
示例#4
0
        public void CloneDoorCustomTagIsApplied(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);

            string expectedNewTag = "expectedNewTag";
            NwDoor clone          = door.Clone(startLocation, expectedNewTag, 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);

            Assert.That(clone.Tag, Is.EqualTo(expectedNewTag), "Tag defined in clone method was not applied to the cloned door.");
        }
示例#5
0
        public void SerializeDoorCreatesValidData(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);

            byte[]? doorData = door.Serialize();

            Assert.That(doorData, Is.Not.Null);
            Assert.That(doorData, Has.Length.GreaterThan(0));

            NwDoor?door2 = NwDoor.Deserialize(doorData !);

            Assert.That(door2, Is.Not.Null);
            Assert.That(door2 !.IsValid, Is.True);

            createdTestObjects.Add(door2);

            Assert.That(door2.Area, Is.Null);
        }
示例#6
0
 protected override void PrepareEvent(NwCreature objSelf)
 {
     Creature     = objSelf;
     BlockingDoor = NWScript.GetBlockingDoor().ToNwObject <NwDoor>();
 }
示例#7
0
            public static void Signal(NwDoor door, int eventId)
            {
                Event nwEvent = NWScript.EventUserDefined(eventId) !;

                NWScript.SignalEvent(door, nwEvent);
            }
            public static void Signal(NwObject caster, NwDoor target, NwSpell spell, bool harmful = true)
            {
                Event nwEvent = NWScript.EventSpellCastAt(caster, spell.Id, harmful.ToInt()) !;

                NWScript.SignalEvent(target, nwEvent);
            }