Click or drag to resize

ASLObjectSendAndSetClaim Method (ASLObjectClaimCallback, Int32, Boolean, GameLiftManagerOpFunctionCallback)

Claims an object for the user until someone steals it or the passed in claim time is reached. Changing the time you hold onto an object and deciding to reset or not the current amount of time you have held it is generally not recommended, but does have occasional applications

Namespace:  ASL
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0.0.0
Syntax
public void SendAndSetClaim(
	ASLObjectClaimCallback callback,
	int claimTimeOut = 1000,
	bool resetClaimTimeout = true,
	GameLiftManagerOpFunctionCallback opCallback = null
)

Parameters

callback
Type: ASLASLObjectClaimCallback
The callback to be called when the claim is approved by the server
claimTimeOut (Optional)
Type: SystemInt32
The amount of time in milliseconds the user will own this object. If set to less than 0, then the user will own the object until it gets stolen.
resetClaimTimeout (Optional)
Type: SystemBoolean
Flag indicating whether or not a claim should reset the claim timer for this object
opCallback (Optional)
Type: ASLGameLiftManagerOpFunctionCallback
The optional callback function for OpFunction
Examples
void SomeFunction()
{
    //Claim the object
    gameobject.GetComponent<ASL.ASLObject>().SendAndSetClaim(() =>
    {
        //Whatever code we want to execute AFTER we have successfully claimed this object, such as:
        gameobject.GetComponent<ASL.ASLObject>().DeleteObject(); //Delete our object
        //or
        gameobject.GetComponent<ASL.ASLObject>().SendAndSetLocalPosition(new Vector3(5, 0, -2)); //Move our object in its local space to 5, 0, -2
    });
}
void SomeFunction()
{
    //Claim an object and then execute the ActionToTake function after a successful claim
    gameobject.GetComponent<ASL.ASLObject>().SendAndSetClaim(ActionToTake);
}
//The function to call after a successful claim
private void ActionToTake()
{
    gameobject.GetComponent<ASL.ASLObject>().DeleteObject(); //Delete our object
}
void SomeOtherFunction()
{
    //Same as before, but this time specify the time to hold onto our object before releasing back to the server - default time is 1000 (or 1 second)
    gameobject.GetComponent<ASL.ASLObject>().SendAndSetClaim(ADifferentActionToTake, 2000); //Hold onto this object before releasing it to the server for 2 seconds
}
//The function to call after a successful claim
private void ADifferentActionToTake()
{
    gameobject.GetComponent<ASL.ASLObject>().SendAndSetLocalPosition(new Vector3(5, 0, -2)); //Move our object in its local space to 5, 0, -2
}
void SomeFunction()
{
    //Claim an object and then (notice the 0 after the last curly brace) hang onto this object until someone steals it from us (do not auto-release to the server)
    gameobject.GetComponent<ASL.ASLObject>().SendAndSetClaim(() =>
    {
        //Whatever code we want to execute after we have successfully claimed this object, such as:
        gameobject.GetComponent<ASL.ASLObject>().DeleteObject(); //Delete our object
        //or
        gameobject.GetComponent<ASL.ASLObject>().SendAndSetLocalPosition(new Vector3(5, 0, -2)); //Move our object in its local space to 5, 0, -2
    }, 0); //Hold onto this object until someone steals it
}
void SomeFunction()
{
    //Claim an object for 1 second, but don't reset whatever our current time length of time we have already held on to it for.
    //Normally if you claim an object, and then claim it again, by default, it will reset the release claim timer - in this case it does not
    gameobject.GetComponent<ASL.ASLObject>().SendAndSetClaim(SomeActionToTake, 1000, false); 
}
private void SomeActionToTake()
{
    gameobject.GetComponent<ASL.ASLObject>().DeleteObject(); //Delete our object
}
void SomeFunction()
{
    gameobject.GetComponent<ASL.ASLObject>().SendAndSetClaim(() =>
    {
        //Whatever code we want to execute after we have successfully claimed this object, such as:
        gameobject.GetComponent<ASL.ASLObject>().DeleteObject(); //Delete our object
        //or
        gameobject.GetComponent<ASL.ASLObject>().SendAndSetLocalPosition(new Vector3(5, 0, -2)); //Move our object in its local space to 5, 0, -2
    }, 0, false); //Hold on to this object until someone steals it, but don't reset whatever our current length of time we have already held on to it for
}
See Also