protected override void Draw(DrawingHandleBase handle) { var worldHandle = (DrawingHandleWorld)handle; var viewport = _eyeManager.GetWorldViewport(); worldHandle.DrawRect(viewport, Color.White); }
/// <inheritdoc /> public override void FrameUpdate(float frameTime) { var renderTreeSystem = EntitySystemManager.GetEntitySystem <RenderingTreeSystem>(); // So we could calculate the correct size of the entities based on the contents of their sprite... // Or we can just assume that no entity is larger than 10x10 and get a stupid easy check. var pvsBounds = _eyeManager.GetWorldViewport().Enlarged(5); var currentMap = _eyeManager.CurrentMap; if (currentMap == MapId.Nullspace) { return; } var mapTree = renderTreeSystem.GetSpriteTreeForMap(currentMap); var pvsEntities = mapTree.Query(pvsBounds, true); foreach (var sprite in pvsEntities) { if (sprite.IsInert) { continue; } sprite.FrameUpdate(frameTime); } }
/// <inheritdoc /> public override void FrameUpdate(float frameTime) { var renderTreeSystem = EntitySystemManager.GetEntitySystem <RenderingTreeSystem>(); // So we could calculate the correct size of the entities based on the contents of their sprite... // Or we can just assume that no entity is larger than 10x10 and get a stupid easy check. var pvsBounds = _eyeManager.GetWorldViewport().Enlarged(5); var currentMap = _eyeManager.CurrentMap; if (currentMap == MapId.Nullspace) { return; } var mapTree = renderTreeSystem.GetSpriteTreeForMap(currentMap); mapTree.QueryAabb(ref frameTime, (ref float state, in SpriteComponent value) => { if (value.IsInert) { return(true); } value.FrameUpdate(state); return(true); }, pvsBounds, approx: true); }
/// <inheritdoc /> public override void FrameUpdate(float frameTime) { // So we could calculate the correct size of the entities based on the contents of their sprite... // Or we can just assume that no entity is larger than 10x10 and get a stupid easy check. var pvsBounds = _eyeManager.GetWorldViewport().Enlarged(5); var currentMap = _eyeManager.CurrentMap; if (currentMap == MapId.Nullspace) { return; } foreach (var gridId in _mapManager.FindGridIdsIntersecting(currentMap, pvsBounds, true)) { var gridBounds = gridId == GridId.Invalid ? pvsBounds : pvsBounds.Translated(-_mapManager.GetGrid(gridId).WorldPosition); var mapTree = _treeSystem.GetSpriteTreeForMap(currentMap, gridId); mapTree.QueryAabb(ref frameTime, (ref float state, in SpriteComponent value) => { if (value.IsInert) { return(true); } value.FrameUpdate(state); return(true); }, gridBounds, approx: true); } }
protected override void Draw(DrawingHandleBase handle, OverlaySpace currentSpace) { handle.UseShader(_shader); var worldHandle = (DrawingHandleWorld)handle; var viewport = _eyeManager.GetWorldViewport(); worldHandle.DrawRect(viewport, Color.White); }
protected override void Draw(DrawingHandleBase handle, OverlaySpace currentSpace) { if (!CritOverlay.LocalPlayerHasState(_playerManager, false, true)) { return; } handle.UseShader(_shader); var worldHandle = (DrawingHandleWorld)handle; var viewport = _eyeManager.GetWorldViewport(); worldHandle.DrawRect(viewport, Color.White); }
private void DrawScreen(DrawingHandleScreen screen) { var viewport = _eyeManager.GetWorldViewport(); var ent = _playerManager.LocalPlayer?.ControlledEntity; if (ent == null || ent.TryGetComponent(out SuspicionRoleComponent sus) != true) { return; } foreach (var(_, uid) in sus.Allies) { // Otherwise the entity can not exist yet if (!_entityManager.TryGetEntity(uid, out var ally)) { return; } if (!ally.TryGetComponent(out IPhysicsComponent physics)) { return; } if (!ExamineSystemShared.InRangeUnOccluded(ent.Transform.MapPosition, ally.Transform.MapPosition, 15, entity => entity == ent || entity == ally)) { return; } // all entities have a TransformComponent var transform = physics.Entity.Transform; // if not on the same map, continue if (transform.MapID != _eyeManager.CurrentMap || !transform.IsMapTransform) { continue; } var worldBox = physics.WorldAABB; // if not on screen, or too small, continue if (!worldBox.Intersects(in viewport) || worldBox.IsEmpty()) { continue; } var screenCoordinates = _eyeManager.WorldToScreen(physics.WorldAABB.TopLeft + (0, 0.5f)); DrawString(screen, _font, screenCoordinates, _traitorText, Color.OrangeRed); } }
public override void Update(float frameTime) { base.Update(frameTime); if (_tooltips == 0) { if (_aiBoxes.Count > 0) { foreach (var(_, panel) in _aiBoxes) { panel.Dispose(); } _aiBoxes.Clear(); } return; } var deletedEntities = new List <IEntity>(0); foreach (var(entity, panel) in _aiBoxes) { if (entity.Deleted) { deletedEntities.Add(entity); continue; } if (!_eyeManager.GetWorldViewport().Contains(entity.Transform.WorldPosition)) { panel.Visible = false; continue; } var(x, y) = _eyeManager.CoordinatesToScreen(entity.Transform.Coordinates).Position; var offsetPosition = new Vector2(x - panel.Width / 2, y - panel.Height - 50f); panel.Visible = true; LayoutContainer.SetPosition(panel, offsetPosition); } foreach (var entity in deletedEntities) { _aiBoxes.Remove(entity); } }
private void DrawScreen(DrawingHandleScreen screen) { var viewport = _eyeManager.GetWorldViewport(); foreach (var uid in _allies) { // Otherwise the entity can not exist yet if (!_entityManager.TryGetEntity(uid, out var ally)) { return; } if (!ally.TryGetComponent(out ICollidableComponent collidable)) { return; } if (!ExamineSystemShared.InRangeUnOccluded(_user.Transform.MapPosition, ally.Transform.MapPosition, 15, entity => entity == _user || entity == ally)) { return; } // all entities have a TransformComponent var transform = collidable.Entity.Transform; // if not on the same map, continue if (transform.MapID != _eyeManager.CurrentMap || !transform.IsMapTransform) { continue; } var worldBox = collidable.WorldAABB; // if not on screen, or too small, continue if (!worldBox.Intersects(in viewport) || worldBox.IsEmpty()) { continue; } var screenCoordinates = _eyeManager.WorldToScreen(collidable.WorldAABB.TopLeft + (0, 0.5f)); DrawString(screen, _font, screenCoordinates, _traitorText, Color.OrangeRed); } }
protected override void Draw(DrawingHandleBase handle, OverlaySpace currentSpace) { if (Modes == 0) { return; } handle.UseShader(_shader); var screenHandle = (DrawingHandleScreen)handle; var viewport = _eyeManager.GetWorldViewport(); if ((Modes & PathfindingDebugMode.Route) != 0) { DrawAStarRoutes(screenHandle, viewport); DrawJpsRoutes(screenHandle, viewport); } if ((Modes & PathfindingDebugMode.Nodes) != 0) { DrawAStarNodes(screenHandle, viewport); DrawJpsNodes(screenHandle, viewport); } if ((Modes & PathfindingDebugMode.Graph) != 0) { DrawGraph(screenHandle, viewport); } if ((Modes & PathfindingDebugMode.CachedRegions) != 0) { DrawCachedRegions(screenHandle, viewport); } if ((Modes & PathfindingDebugMode.Regions) != 0) { DrawRegions(screenHandle, viewport); } }
#pragma warning restore 649 /// <inheritdoc /> public override void FrameUpdate(float frameTime) { // So we could calculate the correct size of the entities based on the contents of their sprite... // Or we can just assume that no entity is larger than 10x10 and get a stupid easy check. var pvsBounds = _eyeManager.GetWorldViewport().Enlarged(5); var pvsEntities = EntityManager.GetEntitiesIntersecting(_eyeManager.CurrentMap, pvsBounds, true); foreach (var entity in pvsEntities) { if (!entity.TryGetComponent(out ISpriteComponent sprite)) { continue; } if (sprite.IsInert) { continue; } sprite.FrameUpdate(frameTime); } }
public override void Update(float frameTime) { base.Update(frameTime); var currentTime = _gameTiming.CurTime; // Can't see any I guess? if (_attachedEntity is not { Valid : true } entity || Deleted(entity)) { return; } var viewbox = _eyeManager.GetWorldViewport().Enlarged(2.0f); foreach (var comp in EntityManager.EntityQuery <DoAfterComponent>(true)) { var doAfters = comp.DoAfters.ToList(); var compPos = EntityManager.GetComponent <TransformComponent>(comp.Owner).WorldPosition; if (doAfters.Count == 0 || EntityManager.GetComponent <TransformComponent>(comp.Owner).MapID != EntityManager.GetComponent <TransformComponent>(entity).MapID || !viewbox.Contains(compPos)) { comp.Disable(); continue; } var range = (compPos - EntityManager.GetComponent <TransformComponent>(entity).WorldPosition).Length + 0.01f; if (comp.Owner != _attachedEntity && !ExamineSystemShared.InRangeUnOccluded( EntityManager.GetComponent <TransformComponent>(entity).MapPosition, EntityManager.GetComponent <TransformComponent>(comp.Owner).MapPosition, range, entity => entity == comp.Owner || entity == _attachedEntity)) { comp.Disable(); continue; } comp.Enable(); var userGrid = EntityManager.GetComponent <TransformComponent>(comp.Owner).Coordinates; // Check cancellations / finishes foreach (var(id, doAfter) in doAfters) { var elapsedTime = (currentTime - doAfter.StartTime).TotalSeconds; // If we've passed the final time (after the excess to show completion graphic) then remove. if (elapsedTime > doAfter.Delay + ExcessTime) { comp.Remove(doAfter); continue; } // Don't predict cancellation if it's already finished. if (elapsedTime > doAfter.Delay) { continue; } // Predictions if (doAfter.BreakOnUserMove) { if (!userGrid.InRange(EntityManager, doAfter.UserGrid, doAfter.MovementThreshold)) { comp.Cancel(id, currentTime); continue; } } if (doAfter.BreakOnTargetMove) { if (EntityManager.EntityExists(doAfter.TargetUid) && !EntityManager.GetComponent <TransformComponent>(doAfter.TargetUid).Coordinates.InRange(EntityManager, doAfter.TargetGrid, doAfter.MovementThreshold)) { comp.Cancel(id, currentTime); continue; } } } var count = comp.CancelledDoAfters.Count; // Remove cancelled DoAfters after ExcessTime has elapsed for (var i = count - 1; i >= 0; i--) { var cancelled = comp.CancelledDoAfters[i]; if ((currentTime - cancelled.CancelTime).TotalSeconds > ExcessTime) { comp.Remove(cancelled.Message); } } } }