Sobre el proyecto
# Facepunch.Steamworks
Otra implementación de Steamworks en C#, diseñada para ser un envoltorio moderno y fácil de usar alrededor de la API de Steamworks. Su objetivo es ser una única DLL de C# sin dependencias nativas más allá de Steam mismo, compatible con Windows, Linux y MacOS, incluyendo Unity e IL2CPP.
## Características
- Multiplataforma: Windows, Linux, MacOS
- Soporte para Unity, incluyendo IL2CPP
- Callbacks asíncronos (resultados de llamadas de Steam) y eventos (callbacks de Steam)
- Una única DLL de C#, sin DLLs nativas de terceros
- Código abierto bajo la licencia MIT
- Soporta sistemas operativos de 32 bits
## Por Qué Esta Librería
El autor encontró que las implementaciones existentes de Steamworks en C# eran deficientes: no eran realmente idiomáticas en C#, estaban desactualizadas, requerían DLLs nativas, no podían compilarse en una DLL independiente en Unity, no eran gratuitas o tenían licencias restrictivas. Esta librería busca envolver la API de Steamworks de una manera que la haga más fácil de usar.
## Ejemplos de Uso
### Obtener Información del Usuario
```csharp
SteamClient.SteamId // Tu SteamId
SteamClient.Name // Tu Nombre
```
### Lista de Amigos
```csharp
foreach ( var friend in SteamFriends.GetFriends() )
{
Console.WriteLine( $"{friend.Id}: {friend.Name}" );
Console.WriteLine( $"{friend.IsOnline} / {friend.SteamLevel}" );
friend.SendMessage( "Hola Amigo" );
}
```
### Información de la Aplicación
```csharp
Console.WriteLine( SteamApps.GameLanguage );
var installDir = SteamApps.AppInstallDir( 4000 );
var fileinfo = await SteamApps.GetFileDetailsAsync( "hl2.exe" );
```
### Avatares
```csharp
var image = await SteamFriends.GetLargeAvatarAsync( steamid );
if ( !image.HasValue ) return DefaultImage;
return MakeTextureFromRGBA( image.Value.Data, image.Value.Width, image.Value.Height );
```
### Lista de Servidores
```csharp
using ( var list = new ServerList.Internet() )
{
list.AddFilter( "map", "de_dust" );
await list.RunQueryAsync();
foreach ( var server in list.Responsive )
{
Console.WriteLine( $"{server.Address} {server.Name}" );
}
}
```
### Logros
Listar y desbloquear logros:
```csharp
foreach ( var a in SteamUserStats.Achievements )
{
Console.WriteLine( $"{a.Name} ({a.State})" );
}
var ach = new Achievement( "GM_PLAYED_WITH_GARRY" );
ach.Trigger();
```
### Voz
```csharp
SteamUser.VoiceRecord = KeyDown( "V" );
if ( SteamUser.HasVoiceData )
{
var bytesrwritten = SteamUser.ReadVoiceData( stream );
}
```
### Autenticación
Autenticación de cliente y servidor:
```csharp
var ticket = SteamUser.GetAuthSessionTicket();
SteamServer.OnValidateAuthTicketResponse += ( steamid, ownerid, rsponse ) =>
{
if ( rsponse == AuthResponse.OK )
TellUserTheyCanBeOnServer( steamid );
else
KickUser( steamid );
};
if ( !SteamServer.BeginAuthSession( ticketData, clientSteamId ) )
{
KickUser( clientSteamId );
}
ticket.Cancel();
```
### Utilidades
```csharp
SteamUtils.SecondsSinceAppActive;
SteamUtils.SecondsSinceComputerActive;
SteamUtils.IpCountry;
SteamUtils.UsingBatteryPower;
SteamUtils.CurrentBatteryPower;
SteamUtils.AppId;
SteamUtils.IsOverlayEnabled;
SteamUtils.IsSteamRunningInVR;
SteamUtils.IsSteamInBigPictureMode;
```
### Workshop
Descargar, consultar y publicar elementos del workshop:
```csharp
SteamUGC.Download( 1717844711 );
var itemInfo = await Ugc.Item.Get( 1720164672 );
var q = Ugc.Query.All
.WithTag( "Diversión" )
.WithTag( "Película" )
.MatchAllTags();
var result = await q.GetPageAsync( 1 );
var q = Ugc.UserQuery.All.CreatedByFriends();
var q = Ugc.UserQuery.All.FromSelf();
var result = await Ugc.Editor.NewCommunityFile
.WithTitle( "Mi Nuevo Archivo" )
.WithDescription( "Esta es una descripción" )
.WithContent( "c:/carpeta/ubicación/addon" )
.WithTag( "increíble" )
.WithTag( "pequeño" )
.SubmitAsync( iProgressBar );
```
### Steam Cloud
```csharp
SteamRemoteStorage.FileWrite( "archivo.txt", fileContents );
var fileContents = SteamRemoteStorage.FileRead( "archivo.txt" );
foreach ( var file in SteamRemoteStorage.Files )
{
Console.WriteLine( $"{file} ({SteamRemoteStorage.FileSize(file)} {SteamRemoteStorage.FileTime( file )})" );
}
```
### Inventario de Steam
```csharp
foreach ( InventoryDef def in SteamInventory.Definitions )
{
Console.WriteLine( $"{def.Name}" );
}
var defs = await SteamInventory.GetDefinitionsWithPricesAsync();
var result = await SteamInventory.GetItems();
using ( result )
{
var items = result?.GetItems( bWithProperties );
foreach ( InventoryItem item in items )
{
Console.WriteLine( $"{item.Id} / {item.Quantity} / {item.Def.Name} " );
}
}
```
## Primeros Pasos
### Inicialización del Cliente
```csharp
using Steamworks;
try
{
SteamClient.Init( 4000 );
}
catch ( System.Exception e )
{
// No se pudo inicializar por alguna razón (steam está cerrado, etc.)
}
// Cuando termines:
SteamClient.Shutdown();
```
### Inicialización del Servidor
```csharp
var serverInit = new SteamServerInit( "gmod", "Garry Mode" )
{
GamePort = 28015,
Secure = true,
QueryPort = 28016
};
try
{
Steamworks.SteamServer.Init( 4000, serverInit );
}
catch ( System.Exception )
{
// No se pudo inicializar por alguna razón (errores de dll, puertos bloqueados)
}
```
## Ayuda y Contribución
Las contribuciones son bienvenidas a través de pull requests e informes de errores. Para ayuda y discusión, visita el [Hilo de Steamworks](http://steamcommunity.com/groups/steamworks/discussions/0/1319961618833314524/). También hay una [wiki](https://wiki.facepunch.com/steamworks/) con ejemplos y consejos.
## Licencia
MIT - haz lo que quieras.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.