public IEnumerable <IEntity> GetPortableEntities() { foreach (var entity in _serverEntityManager.GetEntitiesIntersecting(Owner)) { if (IsEntityPortable(entity)) { yield return(entity); } } }
public void TryDirectedTeleport(IEntity user, MapCoordinates mapCoords) { // Checks if ((user.Transform.WorldPosition - mapCoords.Position).LengthSquared > _range * _range) { return; } if (_state == ItemTeleporterState.On) { return; } if (_avoidCollidable) { foreach (var entity in _serverEntityManager.GetEntitiesIntersecting(mapCoords)) { // Added this component to avoid stacking portals and causing shenanigans // TODO: Doesn't do a great job of stopping stacking portals for directed if (entity.HasComponent <IPhysicsComponent>() || entity.HasComponent <TeleporterComponent>()) { return; } } } // Start / Continue if (_state == ItemTeleporterState.Off) { SetState(ItemTeleporterState.Charging); // Play charging sound here if you want } if (_state != ItemTeleporterState.Charging) { return; } Timer.Spawn(TimeSpan.FromSeconds(_chargeTime), () => Teleport(user, mapCoords.Position)); StartCooldown(); }
public void TryDirectedTeleport(IEntity user, GridCoordinates grid) { // Checks if (user.Transform.GridPosition.Distance(_mapManager, grid) > _range) { return; } if (_state == ItemTeleporterState.On) { return; } if (_avoidCollidable) { foreach (var entity in _serverEntityManager.GetEntitiesIntersecting(grid)) { // Added this component to avoid stacking portals and causing shenanigans // TODO: Doesn't do a great job of stopping stacking portals for directed if (entity.HasComponent <CollidableComponent>() || entity.HasComponent <ServerTeleporterComponent>()) { return; } } } // Start / Continue if (_state == ItemTeleporterState.Off) { SetState(ItemTeleporterState.Charging); // Play charging sound here if you want } if (_state != ItemTeleporterState.Charging) { return; } Timer.Spawn(TimeSpan.FromSeconds(_chargeTime), () => Teleport(user, new Vector2(grid.X, grid.Y))); StartCooldown(); }