public void NavigatorFindsPathToWaypoint() { var startPos = new Vector3(-2, 0, -2); var endPos = new Vector3(2, 0, 2); // Vector3[] want = // { // // startPos, -- Don't think I actually want to have the start if I can swing it, so that warping is easier. // new Vector3(1f, 0f, 1f), // endPos // }; var zone = new Zone("tests"); var grid = SetupZoneMap.SetupMediumGrid(); zone.Map = grid; var traveler = new Traveler { CurrentZone = zone }; traveler.Walker.CurrentPosition = startPos; traveler.PathMaker = new GridPathMaker { ZoneMap = zone.Map }; traveler.PathfindAndWalkToFarAwayWorldMapPosition(endPos); Assert.Equal(endPos, traveler.Walker.CurrentPosition); }
public void TravelerMarksNodesAsUnWalkableWhenStuck() { const string unused = @" ------------------- | e | | ? | ------------------- | x | x | | ------------------- | s | | ? | ------------------- "; // setup the world var zoneMap = ZoneMap.TinyMap(); var zone = new Zone("test") { Map = zoneMap }; var world = new World(); world.Zones.Add(zone); var walker = new Walker(new Vector3(-1, 0, -1)); // Create the map the blind traveler will move against var knownGrid = ZoneMap.TinyMap(); knownGrid.AddUnWalkableNode(Vector3.Zero); knownGrid.AddUnWalkableNode(new Vector3(-1, 0, 0)); var revealedZone = new Zone("test"); revealedZone.Map = knownGrid; walker.RevealedZone = revealedZone; var traveler = new Traveler("test", world, walker); var stubPersister = new StubPersister(); var actor = new KnownNodeActor(stubPersister, traveler.CurrentZone.Map); var watcher = new Watcher(traveler, actor); // For this to work in the FFXI Finite State Machine this currently needs to exit // Frequently to allow for mobs and other stuff to get targeted. Should customize this behavior // To either break on events in the FSM or allow for extension to choose whether to exit under // certain conditions or not. for (int i = 0; i < 10; i++) { traveler.PathfindAndWalkToFarAwayWorldMapPosition(new Vector3(-1, 0, 1)); } var want = new Vector3(-1, 0, 1); var got = traveler.Position; Assert.Equal(want, got); Assert.Equal(2, traveler.CurrentZone.Map.UnknownNodes.Count); // Assert.Equal(traveler.PositionHistory); // Assert.Equal(want, got); }
public void GetSignet() { // Search List of NPCs for Signet NPC var signetNpc = Traveler.SearchForClosestSignetNpc(Nation, Traveler.World.Npcs); // Walk to Signet NPC zone Traveler.WalkToZone(signetNpc.MapName); // Interact with them to Get Signet Traveler.PathfindAndWalkToFarAwayWorldMapPosition(signetNpc.Position); // Get signet TalkToSignetPerson(signetNpc); }
public void MappingThreadOpens() { const string expectedUnknowns = @" ------------------------------- | ? | ? | ? | ? | | ------------------------------- | ? | ? | ? | | ? | ------------------------------- | ? | ? | | ? | ? | ------------------------------- | ? | | ? | ? | ? | ------------------------------- | | ? | ? | ? | ? | ------------------------------- "; // start the watcher and map var zone = new Zone("tests"); var grid = SetupZoneMap.SetupMediumGrid(); zone.Map = grid; var stubPersister = new StubPersister(); var actor = new KnownNodeActor(stubPersister, grid); // Walk a Path var startPos = new Vector3(-2, 0, -2); var endPos = new Vector3(2, 0, 2); Vector3[] path = { startPos, new Vector3(-1f, 0f, -1f), new Vector3(0), new Vector3(1f, 0f, 1f), endPos }; var traveler = new Traveler(); // Watcher must be watching traveler before it gets it's current position otherwise it won't record the starting // position var watcher = new Watcher(traveler, actor); traveler.CurrentZone = zone; traveler.Position = new Vector3(-2, 0, -2); traveler.PathMaker = new GridPathMaker { ZoneMap = zone.Map }; // Walked path traveler.PathfindAndWalkToFarAwayWorldMapPosition(endPos); var got = traveler.Walker.PositionHistory.ToArray(); AssertVectorArrayEqual(path, got); // Visual Representation string actualUnknonws = grid.PrintKnown(); Assert.Equal(expectedUnknowns, actualUnknonws); // Unknown Nodes correct var expectedGrid = SetupZoneMap.SetupMediumGrid(); foreach (var position in path) { expectedGrid.AddKnownNode(position); } Assert.Equal(expectedGrid.UnknownNodes.Count, grid.UnknownNodes.Count); Assert.Equal(expectedGrid.UnknownNodes, grid.UnknownNodes); }