Exemple #1
0
 public override void Init()
 {
     if (ObjectPrivate.TryGetFirstComponent(out RigidBody))
     {
         RigidBody.Subscribe(CollisionEventType.RigidBodyContact, OnCollision);
         RigidBody.SetMotionType(RigidBodyMotionType.MotionTypeDynamic);
     }
     else
     {
         Log.Write(LogLevel.Error, "Choppable couldn't find a RigidBody component.  That component is needed in order to detect when an avatar walks into them");
         return;
     }
     Pieces = ScenePrivate.FindReflective <INamedRigidThing>("Kitchen.Chopped").ToList <INamedRigidThing>();
     Log.Write(LogLevel.Info, $"Found {Pieces.Count()} chopped bits");
     Axe = ScenePrivate.FindReflective <IChopper>("Kitchen.Chopper").FirstOrDefault();
     Log.Write(LogLevel.Info, $"Found Axe: {Axe.GetName()}");
 }
Exemple #2
0
 private void testChopper(IChopper chopper)
 {
     Assert.AreEqual(-1, chopper.Chop(3, new int[] {}));
     Assert.AreEqual(-1, chopper.Chop(3, new int[] { 1 }));
     Assert.AreEqual(0, chopper.Chop(1, new int[] { 1 }));
     Assert.AreEqual(0, chopper.Chop(1, new int[] { 1, 3, 5 }));
     Assert.AreEqual(1, chopper.Chop(3, new int[] { 1, 3, 5 }));
     Assert.AreEqual(2, chopper.Chop(5, new int[] { 1, 3, 5 }));
     Assert.AreEqual(-1, chopper.Chop(0, new int[] { 1, 3, 5 }));
     Assert.AreEqual(-1, chopper.Chop(2, new int[] { 1, 3, 5 }));
     Assert.AreEqual(-1, chopper.Chop(4, new int[] { 1, 3, 5 }));
     Assert.AreEqual(-1, chopper.Chop(6, new int[] { 1, 3, 5 }));
     Assert.AreEqual(0, chopper.Chop(1, new int[] { 1, 3, 5, 7 }));
     Assert.AreEqual(1, chopper.Chop(3, new int[] { 1, 3, 5, 7 }));
     Assert.AreEqual(2, chopper.Chop(5, new int[] { 1, 3, 5, 7 }));
     Assert.AreEqual(3, chopper.Chop(7, new int[] { 1, 3, 5, 7 }));
     Assert.AreEqual(-1, chopper.Chop(0, new int[] { 1, 3, 5, 7 }));
     Assert.AreEqual(-1, chopper.Chop(2, new int[] { 1, 3, 5, 7 }));
     Assert.AreEqual(-1, chopper.Chop(4, new int[] { 1, 3, 5, 7 }));
     Assert.AreEqual(-1, chopper.Chop(6, new int[] { 1, 3, 5, 7 }));
     Assert.AreEqual(-1, chopper.Chop(8, new int[] { 1, 3, 5, 7 }));
 }