public async Task <bool> Test(string prototype, float clickPosX, float clickPosY, double angle, float scale) { EntityUid entity = default; await _server.WaitPost(() => { var entMgr = IoCManager.Resolve <IEntityManager>(); var ent = entMgr.SpawnEntity(prototype, new MapCoordinates(0, 0, new MapId(1))); ent.Transform.LocalRotation = angle; ent.GetComponent <SpriteComponent>().Scale = (scale, scale); entity = ent.Uid; }); // Let client sync up. await RunTicksSync(_client, _server, 5); var hit = false; await _client.WaitPost(() => { var entMgr = IoCManager.Resolve <IEntityManager>(); var ent = entMgr.GetEntity(entity); var clickable = ent.GetComponent <ClickableComponent>(); hit = clickable.CheckClick((clickPosX, clickPosY), out _, out _); }); await _server.WaitPost(() => { var entMgr = IoCManager.Resolve <IEntityManager>(); entMgr.DeleteEntity(entity); }); return(hit); }
public async Task <bool> Test(string prototype, float clickPosX, float clickPosY, double angle, float scale) { Vector2? worldPos = null; EntityUid entity = default; var clientEntManager = _client.ResolveDependency <IEntityManager>(); var serverEntManager = _server.ResolveDependency <IEntityManager>(); var eyeManager = _client.ResolveDependency <IEyeManager>(); var mapManager = _server.ResolveDependency <IMapManager>(); var gameTicker = _server.ResolveDependency <IEntitySystemManager>().GetEntitySystem <GameTicker>(); await _server.WaitPost(() => { var gridEnt = mapManager.GetAllGrids().First().GridEntityId; worldPos = serverEntManager.GetComponent <TransformComponent>(gridEnt).WorldPosition; var ent = serverEntManager.SpawnEntity(prototype, new EntityCoordinates(gridEnt, 0f, 0f)); serverEntManager.GetComponent <TransformComponent>(ent).LocalRotation = angle; serverEntManager.GetComponent <SpriteComponent>(ent).Scale = (scale, scale); entity = ent; }); // Let client sync up. await RunTicksSync(_client, _server, 5); var hit = false; await _client.WaitPost(() => { // these tests currently all assume player eye is 0 eyeManager.CurrentEye.Rotation = 0; var clickable = clientEntManager.GetComponent <ClickableComponent>(entity); hit = clickable.CheckClick((clickPosX, clickPosY) + worldPos !.Value, out _, out _); }); await _server.WaitPost(() => { serverEntManager.DeleteEntity(entity); }); return(hit); }
public async Task <bool> Test(string prototype, float clickPosX, float clickPosY, double angle, float scale) { EntityUid entity = default; var clientEntManager = _client.ResolveDependency <IEntityManager>(); var serverEntManager = _server.ResolveDependency <IEntityManager>(); var eyeManager = _client.ResolveDependency <IEyeManager>(); var mapManager = _server.ResolveDependency <IMapManager>(); await _server.WaitPost(() => { var ent = serverEntManager.SpawnEntity(prototype, GetMainEntityCoordinates(mapManager)); serverEntManager.GetComponent <TransformComponent>(ent).WorldRotation = angle; serverEntManager.GetComponent <SpriteComponent>(ent).Scale = (scale, scale); entity = ent; }); // Let client sync up. await RunTicksSync(_client, _server, 5); var hit = false; await _client.WaitPost(() => { // these tests currently all assume player eye is 0 eyeManager.CurrentEye.Rotation = 0; var pos = clientEntManager.GetComponent <TransformComponent>(entity).WorldPosition; var clickable = clientEntManager.GetComponent <ClickableComponent>(entity); hit = clickable.CheckClick((clickPosX, clickPosY) + pos, out _, out _); }); await _server.WaitPost(() => { serverEntManager.DeleteEntity(entity); }); return(hit); }