Esempio n. 1
0
        public void TestReservation()
        {
            EventTargetReservation reservation = EventTarget.ReserveTargets(3);
            EventTarget            target1     = reservation.GetEntityTarget(0);
            EventTarget            target2     = reservation.GetEntityTarget(1);
            EventTarget            target3     = reservation.GetEntityTarget(2);

            Assert.IsFalse(target1.Equals(target2));
            Assert.IsFalse(target2.Equals(target3));
            Assert.IsFalse(target1.Equals(target3));

            Assert.Throws <IndexOutOfReservedTargetsException>(() => reservation.GetEntityTarget(-1));
            Assert.Throws <IndexOutOfReservedTargetsException>(() => reservation.GetEntityTarget(3));
        }
Esempio n. 2
0
        public void ReserveEntityTargets()
        {
            // See ExampleCustomEventSystem for a description of what EventTarget are and how they could be
            // used. Also see EventTarget.cs

            // Reservations allow us to reserve a block of event targets for us to use however way we see fit. Will
            // prevent EventTarget from giving out targets within that reservation on EventTarget creation or other'
            // reservations.
            EventTargetReservation reservation = EventTarget.ReserveTargets(100);

            // Grabs an EventTarget by index
            EventTarget target0  = reservation.GetEntityTarget(0);
            EventTarget target50 = reservation.GetEntityTarget(50);

            // Throws an error if outside the reservation (if checks are enabled)
            EventTarget target200 = reservation.GetEntityTarget(200);
        }