コード例 #1
0
        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.");
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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.");
        }
コード例 #4
0
        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.");
        }
コード例 #5
0
        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);
        }
コード例 #6
0
            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);
            }
コード例 #7
0
 public static void SetPlaceableNameOverride(this NwPlayer player, NwPlaceable placeable, string name)
 {
     PlayerPlugin.SetPlaceableNameOverride(player, placeable, name);
 }
コード例 #8
0
 public static void ForceOpenInventory(this NwPlayer player, NwPlaceable target)
 {
     PlayerPlugin.ForcePlaceableInventoryWindow(player, target);
 }
コード例 #9
0
 public static void SetIsStatic(this NwPlaceable placeable, bool value)
 {
     ObjectPlugin.SetPlaceableIsStatic(placeable, value.ToInt());
 }
コード例 #10
0
 public static bool GetIsStatic(this NwPlaceable placeable)
 {
     return(ObjectPlugin.GetPlaceableIsStatic(placeable).ToBool());
 }
コード例 #11
0
            public static void Signal(NwPlaceable placeable, int eventId)
            {
                Event nwEvent = NWScript.EventUserDefined(eventId) !;

                NWScript.SignalEvent(placeable, nwEvent);
            }