private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) { FriendsService.Delete(agentID, exfriendID.ToString()); FriendsService.Delete(exfriendID, agentID.ToString()); // Update local cache UpdateFriendsCache(agentID); client.SendTerminateFriend(exfriendID); // // Notify the friend // // Try local if (LocalFriendshipTerminated(exfriendID, agentID)) { return; } UserInfo friendSession = m_Scenes[0].RequestModuleInterface <IAgentInfoService>().GetUserInfo(exfriendID.ToString()); if (friendSession != null && friendSession.IsOnline) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.CurrentRegionID); AsyncMessagePostService.Post(region.RegionHandle, SyncMessageHelper.FriendTerminated( agentID, exfriendID, region.RegionHandle)); } }
private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List <UUID> callingCardFolders) { m_log.DebugFormat("[FRIENDS]: {0} denied friendship to {1}", agentID, friendID); FriendsService.Delete(agentID, friendID.ToString()); FriendsService.Delete(friendID, agentID.ToString()); // // Notify the friend // // Try local if (LocalFriendshipDenied(agentID, client.Name, friendID)) { return; } UserInfo friendSession = m_Scenes[0].RequestModuleInterface <IAgentInfoService>().GetUserInfo(friendID.ToString()); if (friendSession != null && friendSession.IsOnline) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.CurrentRegionID); AsyncMessagePostService.Post(region.RegionHandle, SyncMessageHelper.FriendshipDenied( agentID, client.Name, friendID, region.RegionHandle)); } }
void OnDrawGizmos() { if (Application.isPlaying) { GridService.DrawGizmos(); } }
private void ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im) { // !!!!!!!! This is a hack so that we don't have to keep state (transactionID/imSessionID) // We stick this agent's ID as imSession, so that it's directly available on the receiving end im.imSessionID = im.fromAgentID; // Try the local sim UserAccount account = UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, agentID); im.fromAgentName = (account == null) ? "Unknown" : account.FirstName + " " + account.LastName; if (LocalFriendshipOffered(friendID, im)) { return; } // The prospective friend is not here [as root]. Let's forward. UserInfo friendSession = m_Scenes[0].RequestModuleInterface <IAgentInfoService>().GetUserInfo(friendID.ToString()); if (friendSession != null && friendSession.IsOnline) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.CurrentRegionID); AsyncMessagePostService.Post(region.RegionHandle, SyncMessageHelper.FriendshipOffered( agentID, friendID, im, region.RegionHandle)); } // If the prospective friend is not online, he'll get the message upon login. }
public void SpawnEnemy() { int x = GridService.WIDTH - 1; if (UnityEngine.Random.Range(0, 2) == 0) { x = 0; } // find lowest possible block to spawn on int lowestY = -1; for (int y = GridService.HEIGHT - 1; y >= 0; y--) { if (GridService.GetInstance().Get(x, y) == null) { lowestY = y; } else { Transform next = GridService.GetInstance().Get(x, y); if (next != null && next.gameObject.name == "StoppedCell") { break; } } } if (lowestY >= 0) { Instantiate(enemy, new Vector3(x, lowestY), Quaternion.identity); } }
public void Slice_Layout_With_Area_Same_Size_As_Two_Tiles_Horizontal() { const string inputPath = @"./Layouts/04.bmp"; var layout = Image.FromFile(inputPath); var loggerMock = new Mock <ILogger <GridService> >(); var sut = new GridService(loggerMock.Object); var result = sut.Slice(layout, TileWidth); var elements = result.GetElements().ToArray(); elements.Should().HaveCount(3); var firstElement = elements[0]; var secondElement = elements[1]; var thirdElement = elements[2]; firstElement.Coordinate.X.Should().Be(0); firstElement.Coordinate.Y.Should().Be(0); secondElement.Coordinate.X.Should().Be(50); secondElement.Coordinate.Y.Should().Be(0); thirdElement.Coordinate.X.Should().Be(150); thirdElement.Coordinate.Y.Should().Be(0); new Bitmap(firstElement.Value).Height.Should().Be(100); new Bitmap(firstElement.Value).Width.Should().Be(50); new Bitmap(secondElement.Value).Height.Should().Be(100); new Bitmap(secondElement.Value).Width.Should().Be(100); new Bitmap(thirdElement.Value).Height.Should().Be(100); new Bitmap(thirdElement.Value).Width.Should().Be(50); }
public void RemoveFriendship(IClientAPI client, UUID exfriendID) { if (!DeleteFriendship(client.AgentId, exfriendID)) { client.SendAlertMessage("Unable to terminate friendship on this sim."); } // Update local cache RecacheFriends(client); client.SendTerminateFriend(exfriendID); // // Notify the friend // // Try local if (LocalFriendshipTerminated(client.AgentId, exfriendID)) { return; } PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { exfriendID.ToString() }); if (friendSessions != null && friendSessions.Length > 0) { PresenceInfo friendSession = friendSessions[0]; if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); m_FriendsSimConnector.FriendshipTerminated(region, client.AgentId, exfriendID); } } }
public void GivenABlockOfColouredPixels_AndPixelPositionInBlockGiven__WhenFloodCalledWithPixelPos_ThenAdjacentPixelsAreReturned() { _colourGridService = new GridService(4, _startIndexPosition); var expectedColour = "red"; var expectedNewFloodColour = "white"; var start = 1; var end = 2; _colourGridService.FillRow(expectedColour, 1, start, end); _colourGridService.FillRow(expectedColour, 2, start, end); _colourGridService.FloodBlockWithColour(expectedNewFloodColour, new PixelPosition { X = 1, Y = 1 }); Assert.That(_colourGridService.GetPixelColour(new PixelPosition { X = 2, Y = 1 }), Is.EqualTo(expectedNewFloodColour)); Assert.That(_colourGridService.GetPixelColour(new PixelPosition { X = 1, Y = 1 }), Is.EqualTo(expectedNewFloodColour)); Assert.That(_colourGridService.GetPixelColour(new PixelPosition { X = 1, Y = 2 }), Is.EqualTo(expectedNewFloodColour)); Assert.That(_colourGridService.GetPixelColour(new PixelPosition { X = 2, Y = 2 }), Is.EqualTo(expectedNewFloodColour)); }
public App() { InitializeComponent(); IGridService gridService = new GridService(); MainPage = new MainPage(new MainPageViewModel(gridService)); }
private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List <UUID> callingCardFolders) { m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID); FriendsService.StoreFriend(agentID, friendID.ToString(), 1); FriendsService.StoreFriend(friendID, agentID.ToString(), 1); // Update the local cache UpdateFriendsCache(agentID); // // Notify the friend // // Try Local if (LocalFriendshipApproved(agentID, client.Name, friendID)) { client.SendAgentOnline(new UUID[] { friendID }); return; } // The friend is not here PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); if (friendSessions != null && friendSessions.Length > 0) { PresenceInfo friendSession = friendSessions[0]; if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID); client.SendAgentOnline(new UUID[] { friendID }); } } }
private void ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im) { // !!!!!!!! This is a hack so that we don't have to keep state (transactionID/imSessionID) // We stick this agent's ID as imSession, so that it's directly available on the receiving end im.imSessionID = im.fromAgentID; // Try the local sim UserAccount account = UserAccountService.GetUserAccount(Scene.RegionInfo.ScopeID, agentID); im.fromAgentName = (account == null) ? "Unknown" : account.FirstName + " " + account.LastName; if (LocalFriendshipOffered(friendID, im)) { return; } // The prospective friend is not here [as root]. Let's forward. PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); if (friendSessions != null && friendSessions.Length > 0) { PresenceInfo friendSession = friendSessions[0]; if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); } } // If the prospective friend is not online, he'll get the message upon login. }
protected override async Task OnInitializedAsync() { Action <IGridColumnCollection <InvitationViewModel> > columns = c => { c.Add(o => o.Id).Titled("Id").Sortable(true); c.Add(o => o.To).Titled("To").Sortable(true); c.Add(o => o.SentBy).Titled("By").Sortable(true); c.Add(o => o.SentAt).Titled("Sent").Sortable(true); c.Add(o => o.Error).Titled("Error").Sortable(true); c.Add(o => o.AcceptedAt).Titled("Accepted").Sortable(true); c.Add().Titled("Expired").RenderValueAs(i => i.Expired.ToString()).Sortable(true); }; var query = new QueryDictionary <StringValues>(); query.Add("grid-page", "1"); var client = new GridClient <InvitationViewModel>(q => GridService.GetRows(columns, q), query, false, "grid", columns); Grid = client.Grid; // Set new items to grid Task = client.UpdateGrid(); await Task; }
private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List <UUID> callingCardFolders) { m_log.DebugFormat("[FRIENDS]: {0} denied friendship to {1}", agentID, friendID); FriendsService.Delete(agentID, friendID.ToString()); FriendsService.Delete(friendID, agentID.ToString()); // // Notify the friend // // Try local if (LocalFriendshipDenied(agentID, client.Name, friendID)) { return; } PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); if (friendSessions != null && friendSessions.Length > 0) { PresenceInfo friendSession = friendSessions[0]; if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); if (region != null) { m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID); } else { m_log.WarnFormat("[FRIENDS]: Could not find region {0} in locating {1}", friendSession.RegionID, friendID); } } } }
public void CountOfTargetBeingGreenWithSetTargetSellAfterGenerateShouldReturnRigthCount() { // Arrange var grid = MockGrid.Context(); var gridService = new GridService(grid); var cellActionService = new CellActionService(gridService); var twoDGridService = new TwoDGridActionService(grid, cellActionService); var targetY = 2; var targetX = 2; var numberOfGeneration = 15; twoDGridService.SetNeighboursToAllCells(); twoDGridService.SetTargetCell(targetY, targetX); // Act twoDGridService.Generate(numberOfGeneration); // Assert twoDGridService .GetCountOfTargetBeingGreen() .Should() .Be(14); }
private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) { FriendsService.Delete(agentID, exfriendID.ToString()); FriendsService.Delete(exfriendID, agentID.ToString()); // Update local cache UpdateFriendsCache(agentID); client.SendTerminateFriend(exfriendID); // // Notify the friend // // Try local if (LocalFriendshipTerminated(exfriendID)) { return; } PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { exfriendID.ToString() }); if (friendSessions != null && friendSessions.Length > 0) { PresenceInfo friendSession = friendSessions[0]; if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); } } }
public void AddFriendship(IClientAPI client, UUID friendID) { StoreFriendships(client.AgentId, friendID); // Update the local cache RecacheFriends(client); // // Notify the friend // // Try Local if (LocalFriendshipApproved(client.AgentId, client.Name, friendID)) { client.SendAgentOnline(new UUID[] { friendID }); return; } // The friend is not here PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); if (friendSessions != null && friendSessions.Length > 0) { PresenceInfo friendSession = friendSessions[0]; if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); m_FriendsSimConnector.FriendshipApproved(region, client.AgentId, client.Name, friendID); client.SendAgentOnline(new UUID[] { friendID }); } } }
public override void GetDesiredSteering(SteeringResult rst) { if (Finish) { return; } if (Vector3d.SqrDistance(Target, Self.Position) < FixedMath.One / 100) { Finish = true; GridService.Clear(Target, Self as SceneObject); GridService.TagAs(Self.Position, Self as SceneObject, GridService.NodeType.BeTaken); return; } if (GridService.IsNotEmptyBy(Target) != Self) { GridService.SearchNearEmptyPoint(Target, out Target); GridService.TagAs(Target, Self as SceneObject, GridService.NodeType.FlagAsTarget); } Vector3d dir = Target - Self.Position; Vector3d desiredVelocity = dir.Normalize() * Self.Speed; var acc = (desiredVelocity - Self.Velocity) / (LockFrameMgr.FixedFrameTime); rst.DesiredSteering = acc; }
public void SetNeighboursToAllCellsShouldSetEightNeighboursToMiddleCells() { // Arrange var grid = MockGrid.Context(); var gridService = new GridService(grid); var cellActionService = new CellActionService(gridService); var twoDGridService = new TwoDGridActionService(grid, cellActionService); // Act twoDGridService.SetNeighboursToAllCells(); // Assert grid[1][2] .Neighbours .Count .Should() .Be(8); grid[2][2] .Neighbours .Count .Should() .Be(8); }
public Services(IConfigSource config, string configName, WebApp webApp) { m_log.Debug("[Wifi]: Services Starting..."); m_WebApp = webApp; m_ServerAdminPassword = webApp.RemoteAdminPassword; //m_log.DebugFormat("[Services]: RemoteAdminPassword is {0}", m_ServerAdminPassword); m_LastStatisticsUpdate = new DateTime(); // Create the necessary services m_UserAccountService = new UserAccountService(config); m_AuthenticationService = new PasswordAuthenticationService(config); m_InventoryService = new InventoryService(config); m_GridService = new GridService(config); m_GridUserService = new GridUserService(config); m_AvatarService = new AvatarService(config); // Create the "God" account if it doesn't exist CreateGod(); // Connect to our outgoing mail server for password forgetfulness m_Client = new SmtpClient(m_WebApp.SmtpHost, m_WebApp.SmtpPort); if (m_WebApp.SmtpPort == 25) { m_Client.EnableSsl = false; } else { m_Client.EnableSsl = true; } m_Client.Credentials = new NetworkCredential(m_WebApp.SmtpUsername, m_WebApp.SmtpPassword); m_Client.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback); }
protected virtual bool ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im) { // !!!!!!!! This is a hack so that we don't have to keep state (transactionID/imSessionID) // We stick this agent's ID as imSession, so that it's directly available on the receiving end im.imSessionID = im.fromAgentID; im.fromAgentName = GetFriendshipRequesterName(agentID); // Try the local sim if (LocalFriendshipOffered(friendID, im)) { return(true); } // The prospective friend is not here [as root]. Let's forward. PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); if (friendSessions != null && friendSessions.Length > 0) { PresenceInfo friendSession = friendSessions[0]; if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); return(true); } } // If the prospective friend is not online, he'll get the message upon login. return(false); }
public void GivenAnInvalidPixelPosition_WhenFillPixelIsCalled_ThenExceptionThrown() { _colourGridService = new GridService(4, _startIndexPosition); Assert.Throws <ApplicationException>(() => _colourGridService.FillPixel("red", new PixelPosition { X = 9, Y = 9 })); }
public GameViewModel(ScoringService scoringService, GridService gridService) { _scoringService = scoringService; _gridService = gridService; Cells = new ObservableCollection <GridCell>(); StartGame.Execute(null); }
// returns the singleton instance // if the class hasn't been instatiated, it does so public static GridService GetInstance() { if (instance == null) { instance = new GridService(); } return(instance); }
private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) { m_log.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights, target); FriendInfo[] friends = GetFriends(remoteClient.AgentId); if (friends.Length == 0) { return; } // Let's find the friend in this user's friend list FriendInfo friend = GetFriend(friends, target); if (friend != null) // Found it { // Store it on the DB if (!StoreRights(requester, target, rights)) { remoteClient.SendAlertMessage("Unable to grant rights."); return; } // Store it in the local cache int myFlags = friend.MyFlags; friend.MyFlags = rights; // Always send this back to the original client remoteClient.SendChangeUserRights(requester, target, rights); // // Notify the friend // // Try local if (LocalGrantRights(requester, target, myFlags, rights)) { return; } PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); if (friendSessions != null && friendSessions.Length > 0) { PresenceInfo friendSession = friendSessions[0]; if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); // TODO: You might want to send the delta to save the lookup // on the other end!! m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); } } } else { m_log.DebugFormat("[FRIENDS MODULE]: friend {0} not found for {1}", target, requester); } }
public override void RelocateRegion(GridVector location) { RegionInfo ri = GetRegionInfo(); ri.Location = location; GridService.RegisterRegion(ri); GridPosition = location; RegionStorage?.RegisterRegion(ri); }
public void CanDetectGameOverState(string gridText, bool gameOver) { var service = new GridService(new RandomService()); var grid = ParseGrid(gridText); var canMove = service.CanBeMoved(grid); canMove.Should().Be(!gameOver); }
public void CaculateLastAlignment() { if (_npcs.Count == 0) { return; } int x, y; GridService.GetCoordinate(_commander.Position, out x, out y); int radius = 1; int index = _npcs.Count - 1; while (true) { for (int i = radius; i >= -radius; i--) { for (int j = radius; j >= -radius; j--) { if (i != radius && i != -radius) { if (j == radius || j == -radius) { if (GridService.IsEmpty(j + x, i + y)) { for (int k = 0; k < _npcs.Count; k++) { if (_npcs[k].AlignmentX != j || _npcs[k].AlignmentY != i) { _npcs[index].AlignmentX = j; _npcs[index].AlignmentY = i; return; } } } } } else { if (GridService.IsEmpty(j + x, i + y)) { for (int k = 0; k < _npcs.Count; k++) { if (_npcs[k].AlignmentX != j || _npcs[k].AlignmentY != i) { _npcs[index].AlignmentX = j; _npcs[index].AlignmentY = i; return; } } } } } } radius++; } }
private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) { if (!m_Friends.ContainsKey(remoteClient.AgentId)) { return; } m_log.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights, target); // Let's find the friend in this user's friend list UserFriendData fd = m_Friends[remoteClient.AgentId]; FriendInfo friend = null; foreach (FriendInfo fi in fd.Friends) { if (fi.Friend == target.ToString()) { friend = fi; } } if (friend != null) // Found it { // Store it on the DB FriendsService.StoreFriend(requester, target.ToString(), rights); // Store it in the local cache int myFlags = friend.MyFlags; friend.MyFlags = rights; // Always send this back to the original client remoteClient.SendChangeUserRights(requester, target, rights); // // Notify the friend // // Try local if (LocalGrantRights(requester, target, myFlags, rights)) { return; } PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); if (friendSessions != null && friendSessions.Length > 0) { PresenceInfo friendSession = friendSessions[0]; if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); // TODO: You might want to send the delta to save the lookup // on the other end!! m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); } } } }
public GridServiceProvider() { //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; SetupResolver(); GetServiceURL(_conFigHelper.LOGIN_DOMAIN); if (_serviceUrls != null) { _gridService = new bLoyal.Connectors.Grid.GridService(_serviceUrls.GridApiUrl, _conFigHelper.ACCESS_KEY); } }
public void GivenAPixelPositionAndColour_WhenFillPixelIsCalled_PixelShouldBeExpectedColour() { _colourGridService = new GridService(4, _startIndexPosition); var expectedColour = "red"; var pixelPosition = new PixelPosition { X = 1, Y = 2 }; _colourGridService.FillPixel(expectedColour, pixelPosition); Assert.That(_colourGridService.GetPixelColour(pixelPosition), Is.EqualTo(expectedColour)); }