Exemplo n.º 1
0
 public void EmptyForIdenticals()
 {
     var world2 = World.Empty.SetWob(_planet);
     Assert.True(new WorldDiff(World.Empty, World.Empty).IsEmpty);
     Assert.True(new WorldDiff(world2, world2).IsEmpty);
     var diff = new WorldDiff(World.Empty, world2);
     Assert.False(diff.IsEmpty);
     Assertions.WorldsEqual(world2, World.Empty.Patch(diff));
 }
Exemplo n.º 2
0
 public bool SendWorldPatch(Guid clientID, WorldDiff diff)
 {
     SetShadow(clientID, w => w.Patch(diff));
     _world.Set(w => w.Patch(diff));
     return true;
 }
Exemplo n.º 3
0
 public WorldDiff ReceiveWorldPatch(Guid clientID)
 {
     WorldDiff diff = null;
     SetShadow(clientID, shadow => shadow.Patch(diff = new WorldDiff(shadow, _world)));
     return diff;
 }
Exemplo n.º 4
0
 private void SyncWithServer()
 {
     Thread.Sleep(TimeSpan.FromSeconds(ServerSyncInterval));
     var diffOut = new WorldDiff(_worldShadow, Globals.World);
     _worldShadow = _worldShadow.Patch(diffOut);
     if (!diffOut.IsEmpty) _visualizationUpdates.Enqueue(diffOut);
     _service.SendWorldPatch(_clientID, diffOut);
     var diffIn = _service.ReceiveWorldPatch(_clientID);
     if (!diffIn.IsEmpty) _visualizationUpdates.Enqueue(diffIn);
     _worldShadow = _worldShadow.Patch(diffIn);
     Globals.World.Set(w => w.Patch(diffIn));
     if (_mission == null)
         _mission = new Mission
         {
             AssignMessage = "Go and find The Planet!\nThere'll be no reward.",
             AssignVolume = new Sphere(Globals.World.Value.Wobs.Values.OfType<Station>().First().Pos, 50),
             CompleteMessage = "You found the correct planet,\nnice!",
             CompleteVolume = new Sphere(Globals.World.Value.Wobs.Values.OfType<Planet>().First().Pos, 80),
         };
 }
Exemplo n.º 5
0
 private void AssertDiffAndPatch(World world1, World world2, Action<WorldDiff> assertDiff)
 {
     var diff = new WorldDiff(world1, world2);
     assertDiff(diff);
     Assertions.WorldsEqual(world2, world1.Patch(diff));
 }