mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-24 13:45:37 +03:00
Added item.SetProperty, item.SubmitProperties
This commit is contained in:
parent
bda8b5b956
commit
44a6f42f8e
@ -63,6 +63,70 @@ public override int GetHashCode()
|
||||
{
|
||||
return !c1.Equals( c2 );
|
||||
}
|
||||
|
||||
SteamNative.SteamInventoryUpdateHandle_t updateHandle;
|
||||
|
||||
private void UpdatingProperties()
|
||||
{
|
||||
if (updateHandle != 0) return;
|
||||
|
||||
updateHandle = Definition.inventory.inventory.StartUpdateProperties();
|
||||
}
|
||||
|
||||
public bool SetProperty( string name, string value )
|
||||
{
|
||||
UpdatingProperties();
|
||||
Properties[name] = value.ToString();
|
||||
return Definition.inventory.inventory.SetProperty(updateHandle, Id, name, value);
|
||||
}
|
||||
|
||||
public bool SetProperty(string name, bool value)
|
||||
{
|
||||
UpdatingProperties();
|
||||
Properties[name] = value.ToString();
|
||||
return Definition.inventory.inventory.SetProperty0(updateHandle, Id, name, value);
|
||||
}
|
||||
|
||||
public bool SetProperty(string name, long value)
|
||||
{
|
||||
UpdatingProperties();
|
||||
Properties[name] = value.ToString();
|
||||
return Definition.inventory.inventory.SetProperty1(updateHandle, Id, name, value);
|
||||
}
|
||||
|
||||
public bool SetProperty(string name, float value)
|
||||
{
|
||||
UpdatingProperties();
|
||||
Properties[name] = value.ToString();
|
||||
return Definition.inventory.inventory.SetProperty2(updateHandle, Id, name, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called to finalize any changes made using SetProperty
|
||||
/// </summary>
|
||||
public bool SubmitProperties()
|
||||
{
|
||||
if (updateHandle == 0)
|
||||
throw new Exception("SubmitProperties called without updating properties");
|
||||
|
||||
try
|
||||
{
|
||||
SteamNative.SteamInventoryResult_t result = -1;
|
||||
|
||||
if (!Definition.inventory.inventory.SubmitUpdateProperties(updateHandle, ref result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Definition.inventory.inventory.DestroyResult(result);
|
||||
|
||||
return true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
updateHandle = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user