{"id":23536387,"url":"https://github.com/developerfred/mud-rpg","last_synced_at":"2025-05-14T22:33:08.748Z","repository":{"id":237456509,"uuid":"644087617","full_name":"developerfred/mud-rpg","owner":"developerfred","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-15T23:26:53.000Z","size":529,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-17T06:42:18.105Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/developerfred.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-22T19:39:15.000Z","updated_at":"2023-05-22T19:39:22.000Z","dependencies_parsed_at":"2024-05-02T02:40:44.440Z","dependency_job_id":"683c35f1-1137-47ea-b915-dc181089bcd7","html_url":"https://github.com/developerfred/mud-rpg","commit_stats":null,"previous_names":["developerfred/mud-rpg"],"tags_count":0,"template":false,"template_full_name":"emergenceland/mud-template-unity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developerfred%2Fmud-rpg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developerfred%2Fmud-rpg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developerfred%2Fmud-rpg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developerfred%2Fmud-rpg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/developerfred","download_url":"https://codeload.github.com/developerfred/mud-rpg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254239551,"owners_count":22037725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-26T02:20:06.423Z","updated_at":"2025-05-14T22:33:08.707Z","avatar_url":"https://github.com/developerfred.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MUD Template Unity\n\n## Prerequisites\n\n1. git ([download](https://git-scm.com/downloads))\n2. foundry (forge, anvil, cast) ([download](https://book.getfoundry.sh/getting-started/installation), make sure to foundryup at least once)\n3. node.js (v16+) ([download](https://nodejs.org/en/download))\n4. pnpm (after installing node: npm install --global pnpm)\n5. Unity ([download](https://unity.com/download))\n6. The .NET SDK (7.0) ([download](https://dotnet.microsoft.com/en-us/download))\n\nIf you are using Windows:\n\n1. install git bash (gitforwindows.org)\n2. install nodejs, including “native modules” (nodejs.org/en/download) (re native modules: just keep the checkmark, it’s enabled by default in the installer)\n3. Install foundry via foundryup using Git bash\n\n## Tutorial\n\nThe tutorial repo for this template can be found [here](https://github.com/emergenceland/tankmud-tutorial).\n\n## Quickstart\n\nRun the following command in the root:\n\n```\npnpm install\n```\n\nThen, open two terminal tabs.\n\nIn tab 1:\n\n```\npnpm run dev:node\n```\n\nIn tab 2:\n\n```\npnpm run dev\n```\n\nIn Unity, Open the Main scene if you haven’t already `(packages/client/Assets/Scenes/Main.unity)`.\nPress play. Click to increment the counter.\n\n## Usage\n\nMUD Template Unity autogenerates C# definitions for your Tables when you run `pnpm dev`. These should appear in `packages/client/Assets/Scripts/codegen/`.\n\n### Getting a value\n\n```csharp\nvar addressKey = net.addressKey;\n// get by key\nvar currentPlayer = PlayerTable.GetTableValue(addressKey);\n\n// currentPlayer is strongly typed\nstring name = currentPlayer.name;\n```\n\n### Subscribing to updates\n\n```csharp\nvar playerSubInsert = PlayerTable.OnRecordInsert().ObserveOnMainThread().Subscribe(OnInsertPlayers);\n\nvar playerSubUpdate = PlayerTable.OnRecordUpdate().ObserveOnMainThread().Subscribe(OnDeletePlayers);\n\nvar playerSubDelete = PlayerTable.OnRecordDelete().ObserveOnMainThread().Subscribe(OnDeletePlayers);\n\nvar playerSubDeleteInsert = PlayerTable.OnRecordInsert.Merge(PlayerTable.OnRecordDelete).ObserveOnMainThread().Subscribe(OnInsertDeletePlayers);\n\n\nprivate void OnUpdatePlayers(PlayerTableUpdate update)\n{\n\t// PlayerTableUpdate has a TypedValue, which is a Tuple of \u003cPlayerTable,PlayerTable\u003e\n\t// Item 1 is the current value, and Item 2 is the previous value.\n\tvar currentValue = update.TypedValue.Item1;\n\tif (currentValue == null) return;\n\tvar previousValue = update.TypedValue.Item2;\n\n // PlayerTableUpdate inherits from UniMUD's RecordUpdate\n // So you can still get the key, table, and untyped values.\n\tvar playerPosition = PositionTable.GetTableValue(update.Key);\n\tif (playerPosition == null) return;\n\n\tvar playerSpawnPoint = new Vector3((float)playerPosition.x, 0, (float)playerPosition.y);\n\tvar player = Instantiate(playerPrefab, playerSpawnPoint, Quaternion.identity);\n\n\tif (update.Key == net.addressKey) {\n\t\tDebug.Log(\"Is local player\");\n\t}\n}\n```\n\n### Making a transaction\n\nThis template generates Nethereum bindings for your World contract, which, we can access to make a transaction.\nNote that not all Unity functions can be async, so you may need to wrap your transaction in a coroutine.\n\n```csharp\n\tasync void Spawn(NetworkManager nm)\n\t{\n\t\tvar addressKey = net.addressKey;\n\t\tvar currentPlayer = PlayerTable.GetTableValue(addressKey);\n\t\tif (currentPlayer == null)\n\t\t{\n\t\t\t// spawn the player\n\t\t\tawait nm.worldSend.TxExecute\u003cSpawnFunction\u003e(0, 0);\n\t\t}\n\t}\n\n\t// For example, with the UniTask library:\n\tprivate async UniTaskVoid SendIncrementTxAsync()\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait net.worldSend.TxExecute\u003cIncrementFunction\u003e();\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\t// Handle your exception here\n\t\t\tDebug.LogException(ex);\n\t\t}\n\t}\n```\n\n### Deploying to a Testnet\n\nYou can deploy to any non-local chain with `cd packages/contracts \u0026\u0026 pnpm run deploy:testnet`.\nBe sure to properly set the ChainID and RPC urls in the **NetworkManager** component.\n\nUniMUD currently doesn’t implement the faucet service, so you must manually send testnet funds to your address. Your address is logged in Debug mode, but you can also create a UI component to fetch and display it from the NetworkManager.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperfred%2Fmud-rpg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeveloperfred%2Fmud-rpg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperfred%2Fmud-rpg/lists"}