sbox-issues icon indicating copy to clipboard operation
sbox-issues copied to clipboard

Get the sbox.game ident of a resource.

Open badandbest opened this issue 1 year ago • 0 comments

For?

S&Box

What can't you do?

I need the to get the ident of published GameResources from in-game so that my library's backend is able to get the packageinfo. ( Thumbnail, title, descritpion, etc. )


Users of my library would upload a GameResource to like this.

image

When the player has defeated a boss, for example, the gamemode would do

public class BossManager : Component
{
    [Property] public Quest BossQuest { get; set; }
    
    public void CompleteBoss()
    {
        BossQuest.Complete();
    }
}

...in which the library would show a pop-up on a web surface.

It would be something like this mockup, except instead of displaying sbox.game it would be my s&box service.

https://github.com/user-attachments/assets/e8301cde-8d3c-45c8-82a4-1287539e8e06

How would you like it to work?

GameResources already stores referenced packages. image Maybe it could store its own package too as __ident?

What have you tried?

Here's a list of ways I tried to get the ident:

  1. My first idea was to read the .meta file to get the ident. This method was unreliable because assets downloaded from the cloud don't have .meta files.

  2. The Asset type in the editor has direct access to the PublishConfig, so my second idea was to subscribe to GameResource.ProcessSerializedObject and serialize the ident. This method was also unreliable because changing publish settings did not cause the GameResource to serialize.

    {
      "Reward": 200,
      "__references": [],
      "__version": 0,
      "__ident": "local.hard_quest"
    }
    
  3. My third idea was to ge thet list of active packages and find the package containing the game resource. This method was not viable because as far as I'm aware there is no way to get the list of active packages in-game. Perhaps a Package.All or Package.GetInProject() would be useful in this case?

Additional context

No response

badandbest avatar Aug 11 '24 12:08 badandbest