public override void AlignPlacementMode(ScreenCoordinates mouseScreen) { MouseCoords = ScreenToCursorGrid(mouseScreen); CurrentTile = pManager.MapManager.GetGrid(MouseCoords.GridID).GetTileRef(MouseCoords); if (pManager.CurrentPermission.IsTile) { return; } var nodes = new List <Vector2>(); if (pManager?.CurrentPrototype.MountingPoints != null) { nodes.AddRange( pManager.CurrentPrototype.MountingPoints.Select( current => new Vector2(MouseCoords.X, CurrentTile.Y + current))); } else { nodes.Add(new Vector2(MouseCoords.X, CurrentTile.Y + 0.5f)); nodes.Add(new Vector2(MouseCoords.X, CurrentTile.Y + 1.0f)); nodes.Add(new Vector2(MouseCoords.X, CurrentTile.Y + 1.5f)); } Vector2 closestNode = (from Vector2 node in nodes orderby(node - MouseCoords.Position).LengthSquared ascending select node).First(); MouseCoords = new GridCoordinates(closestNode + new Vector2(pManager.PlacementOffset.X, pManager.PlacementOffset.Y), MouseCoords.GridID); }
public bool SetPosition(Vector2 position) { _checkDisposed(); var(x, y) = position; if (!ValidatePosition(x, y)) { return(false); } #if DEBUG // OpenAL doesn't seem to want to play stereo positionally. // Log a warning if people try to. if (_sourceStream.ChannelCount > 1 && !_didPositionWarning) { _didPositionWarning = true; Logger.WarningS("clyde.oal", "Attempting to set position on audio source with multiple audio channels! Stream: '{0}'", _sourceStream.Name); } #endif AL.Source(SourceHandle, ALSource3f.Position, x, y, 0); _checkAlError(); return(true); }
public bool SetPosition(Vector2 position) { _checkDisposed(); var(x, y) = position; if (!AreFinite(x, y)) { return(false); } #if DEBUG // OpenAL doesn't seem to want to play stereo positionally. // Log a warning if people try to. if (_sourceStream.ChannelCount > 1 && !_didPositionWarning) { _didPositionWarning = true; Logger.WarningS("clyde.oal", "Attempting to set position on audio source with multiple audio channels! Stream: '{0}'. Make sure the audio is MONO, not stereo.", _sourceStream.Name); // warning isn't enough, people just ignore it :( DebugTools.Assert(false, $"Attempting to set position on audio source with multiple audio channels! Stream: '{_sourceStream.Name}'. Make sure the audio is MONO, not stereo."); } #endif AL.Source(SourceHandle, ALSource3f.Position, x, y, 0); _master._checkAlError(); return(true); }
public void SetPosition(Vector2 position) { _checkDisposed(); _mono = true; var(x, y) = position; // ReSharper disable once PossibleInvalidOperationException AL.Source(SourceHandle.Value, ALSource3f.Position, x, y, 0); _checkAlError(); }
public void SetVelocity(Vector2 velocity) { _checkDisposed(); var(x, y) = velocity; if (!AreFinite(x, y)) { return; } AL.Source(SourceHandle, ALSource3f.Velocity, x, y, 0); _master._checkAlError(); }
public bool SetPosition(Vector2 position) { _checkDisposed(); var(x, y) = position; if (!ValidatePosition(x, y)) { return(false); } _mono = true; // ReSharper disable once PossibleInvalidOperationException AL.Source(SourceHandle.Value, ALSource3f.Position, x, y, 0); _checkAlError(); return(true); }
public static EntityCoordinates ToCoordinates(this IMapGrid grid, Vector2 offset) { return(ToCoordinates(grid.GridEntityId, offset)); }
public static EntityCoordinates ToCoordinates(this IEntity entity, Vector2 offset) { return(ToCoordinates(entity.Uid, offset)); }
public static EntityCoordinates ToCoordinates(this EntityUid id, Vector2 offset) { return(new EntityCoordinates(id, offset)); }