bombsquad-community / plugin-manager

A Plugin Manager for Bombsquad 1.7+
https://bombsquad-community.web.app/pluginmanager
Other
38 stars 28 forks source link

Install custom models/textures through plugin manager #112

Open rikkolovescats opened 1 year ago

rikkolovescats commented 1 year ago

How about we have different directory in plugin manager repo called "assets" which'll look like this:

assets/
├── newLevel/
│   ├── newLevel.bob
│   ├── newLevel.cob
│   └── newLevel.dds
├── newCharacter/
│   ├── newCharacterHead.bob
│   ├── newCharacterHand.bob
│   ├── newCharacterOuch.ogg
|   ├── ...
├── ...

This directory won't be visible from plugin manager in-game, but any usual .py plugins that require custom assets can have a new method which'll signal plugin manager to automatically download and install assets from this "assets" directory available on GitHub:

class MyPlugin(ba.Plugin):
    def on_app_running(self):
        register_new_level()

    def custom_assets(self):
        # this method'll signal plugin manager to download n install 
        # all stuff available in assets/newLevel/ directory on github
        return ["newLevel",]
        # debatable - to handle assets stored in 3rd party sources, prefixing
        # this directory with the source url should help solve it:
        # return ["rikkolovescats/sahilp-plugins/newLevel",]

It might also be a good idea to wait until 1.8 to see if we can change or complement our ideas based on how the official game implements it.

rikkolovescats commented 1 year ago

I thought about this a little more. I think the best way to implement this would be to mention custom assets in the plugin/minigame's corresponding json metadata file.

For example, soccer currently looks like this: https://github.com/bombsquad-community/plugin-manager/blob/7f84e4911a104e19dc58c496065372471b0aa7e6/plugins/minigames.json#L6-L24

If it were to use custom assets, it could look something like this:

"soccer": {
  "description": "Shoot the ball in left or right edge of the map to score",
  "external_url": "",
  "authors": [
    {
      "name": "Stary_Agent",
      "email": "",
      "discord": ""
    }
  ],
  "versions": {
    "1.0.0": {
      "api_version": 7,
      "commit_sha": "e59073b",
      "released_on": "02-11-2022",
      "md5sum": "ceb7ac417c85396722fa9f7fee3cfc01",
      "custom_assets": [
        {
          "file": "newLevel/newLevel.bob",
          "md5sum": "e0b0b3b0e0b0b3b0e0b0b3b0e0b0b3b0",
        },
        {
          "file": "newLevel/newLevel.cob",
          "md5sum": "c0c3c0e0c0c3c0e0c0c3c0e0c0c03c0e",
        },
        {
          "file": "newLevel/newLevel.dds",
          "md5sum": "b0b3b0e0b0b3b0e0b0b3b0e0b0b3b0e0",
        }
      ]
    }
  }
},

I think maintaining versions for every asset (like the way we do for plugins/minigames) seems unnecessary, so for now I think let's just use the present version of the asset. In case the local md5sum of the asset ever stops matching with the one present in this repo, plugin manager can attempt to update the local asset.

We can also auto populate the md5sum for assets using ci similar to how we do it for plugins.