Gorilla Tag 的 PC 库,处理各种与房间相关的事情(以及更多?)
如果您不想手动安装,可以使用 Monke Mod Manager 安装此模组
如果您的游戏未使用 BepinEx 进行修改,请先这样做!只需转到最新的 BepinEx 版本并将 BepinEx_x64_VERSION.zip 直接解压到游戏文件夹中,然后运行一次游戏即可正确安装 BepinEx。
接下来,转到该模组的最新版本并将其直接解压到您的游戏文件夹中。确保将其直接提取到游戏文件夹中,而不是提取到子文件夹中!
随着 Utilla 1.5.0 的发布,模组只能在模组游戏模式下运行,而不是在任何私人大厅中运行。 Utilla 提供了易于使用的属性,使这种转换尽可能轻松。请参阅此提交以获取更新 mod 以使用新系统的示例。
处理玩家是否在模组房间中是确保您的模组不会被用来作弊的一个非常重要的部分。 Utilla 通过提供在加入修改后的大厅时触发的属性来简化此操作。
[ModdedGamemode]
必须应用于您的 mod 的插件类才能使用其他属性。 [ModdedGamemodeJoin]
和[ModdedGamemodeLeave]
可以应用于此类中的任何 void 方法,并带有包含完整游戏模式字符串的可选字符串参数。当加入或离开已修改的房间时,将分别调用这些方法。
using System ;
using BepInEx ;
using Utilla ;
namespace ExamplePlugin
{
[ BepInPlugin ( " org.legoandmars.gorillatag.exampleplugin " , " Example Plugin " , " 1.0.0 " ) ]
[ BepInDependency ( " org.legoandmars.gorillatag.utilla " , " 1.5.0 " ) ] // Make sure to add Utilla 1.5.0 as a dependency!
[ ModdedGamemode ] // Enable callbacks in default modded gamemodes
public class ExamplePlugin : BaseUnityPlugin
{
bool inAllowedRoom = false ;
private void Update ( )
{
if ( inAllowedRoom )
{
// Do mod stuff
}
}
[ ModdedGamemodeJoin ]
private void RoomJoined ( string gamemode )
{
// The room is modded. Enable mod stuff.
inAllowedRoom = true ;
}
[ ModdedGamemodeLeave ]
private void RoomLeft ( string gamemode )
{
// The room was left. Disable mod stuff.
inAllowedRoom = false ;
}
}
}
Utilla 1.5.0 为 Gorilla Tag 带来了对自定义游戏模式的支持。 mod可以通过[ModdedGamemode]
属性注册自定义游戏模式,并且会出现在游戏中默认游戏模式的旁边。
[ BepInPlugin ( " org.legoandmars.gorillatag.exampleplugin " , " Example Plugin " , " 1.0.0 " ) ]
[ BepInDependency ( " org.legoandmars.gorillatag.utilla " , " 1.5.0 " ) ] // Make sure to add Utilla 1.5.0 as a dependency!
[ ModdedGamemode ( " mygamemodeid " , " MY GAMEMODE " , Models . BaseGamemode . Casual ) ] // Enable callbacks in a new casual gamemode called "MY GAMEMODE"
public class ExamplePlugin : BaseUnityPlugin { }
此外,通过创建继承GorillaGameManager
的类,可以使用完全自定义的游戏管理器。创建自定义游戏模式需要对 Gorilla Tag 的网络代码有深入的了解。目前,匹配不适用于完全自定义的游戏模式,但仍然可以通过房间代码使用它们。
[ BepInPlugin ( " org.legoandmars.gorillatag.exampleplugin " , " Example Plugin " , " 1.0.0 " ) ]
[ BepInDependency ( " org.legoandmars.gorillatag.utilla " , " 1.5.0 " ) ] // Make sure to add Utilla 1.5.0 as a dependency!
[ ModdedGamemode ( " mygamemodeid " , " MY GAMEMODE " , typeof ( MyGameManager ) ) ] // Enable callbacks in a new custom gamemode using MyGameManager
public class ExamplePlugin : BaseUnityPlugin { }
public class MyGameManager : GorillaGameManager
{
// The game calls this when this is the gamemode for the room.
public override void StartPlaying ( )
{
// Base needs to run for base GorillaGamanger functionality to run.
base . StartPlaying ( ) ;
}
// Called by game when you leave a room or gamemode is changed.
public override void StopPlaying ( )
{
// Base needs to run for the game mode stop base GorillaGameManager functionality from running.
base . StopPlaying ( ) ;
}
// Called by the game when you leave a room after StopPlaying, use this for all important clean up and resetting the state of your game mode.
public override void Reset ( )
{
}
// Gamemode names must not have spaces and must not contain "CASUAL", "INFECTION", "HUNT", or "BATTLE".
// Names that contain the name of other custom gamemodes will confilict.
public override string GameModeName ( )
{
return " CUSTOM " ;
}
// GameModeType is an enum which is really an int, so any int value will work.
// Make sure to use a unique value not taken by other game modes.
public override GameModeType GameType ( )
{
return ( GameModeType ) 765 ;
}
public override int MyMatIndex ( Player forPlayer )
{
return 3 ;
}
}
Utilla 提供在任何房间加入时广播的事件。不建议他们启用和禁用您的 mod,因为使用如上所述的属性。 Utilla 提供了两个房间加入和离开的事件, Utilla.Events.RoomJoined
和Utilla.Events.RoomLeft
using System ;
using BepInEx ;
using Utilla ;
namespace ExamplePlugin
{
[ BepInPlugin ( " org.legoandmars.gorillatag.exampleplugin " , " Example Plugin " , " 1.0.0 " ) ]
[ BepInDependency ( " org.legoandmars.gorillatag.utilla " , " 1.5.0 " ) ] // Make sure to add Utilla as a dependency!
public class ExamplePlugin : BaseUnityPlugin
{
void Awake ( )
{
Utilla . Events . RoomJoined += RoomJoined ;
Utilla . Events . RoomLeft += RoomLeft ;
}
private void RoomJoined ( object sender , Events . RoomJoinedArgs e )
{
UnityEngine . Debug . Log ( $" Private room: { e . isPrivate } , Gamemode: { e . Gamemode } " ) ;
}
private void RoomLeft ( object sender , Events . RoomJoinedArgs e )
{
UnityEngine . Debug . Log ( $" Private room: { e . isPrivate } , Gamemode: { e . Gamemode } " ) ;
}
}
}
Utilla 提供了一个在 Gorilla Tag 初始化后触发的事件,如果您在单例对象(例如GorillaLocomotion.Player.Instance
上遇到空引用错误,请使用此事件
using System ;
using BepInEx ;
using Utilla ;
namespace ExamplePlugin
{
[ BepInPlugin ( " org.legoandmars.gorillatag.exampleplugin " , " Example Plugin " , " 1.0.0 " ) ]
[ BepInDependency ( " org.legoandmars.gorillatag.utilla " , " 1.5.0 " ) ] // Make sure to add Utilla as a dependency!
public class ExamplePlugin : BaseUnityPlugin
{
void Awake ( )
{
Utilla . Events . GameInitialized += GameInitialized ;
}
private void GameInitialized ( object sender , EventArgs e )
{
// Player instance has been created
UnityEngine . Debug . Log ( GorillaLocomotion . Player . Instance . jumpMultiplier ) ;
}
}
}
如果您想使用您的 mod 加入自定义私人大厅,Utilla 也实现了相应的方法。
Utilla . Utils . RoomUtils . JoinPrivateLobby ( ) // Joins a private lobby with a random 6 character code
Utilla . Utils . RoomUtils . JoinPrivateLobby ( " TestLobby " ) // Joins a private lobby with the code TestLobby
Utilla . Utils . RoomUtils . JoinPrivateLobby ( " TestLobby " , true ) // Joins a private casual lobby with the code TestLobby
如果您想在您的 mod 中使用自定义队列,Utilla 也实现了该方法。
Utilla . Utils . RoomUtils . JoinModdedLobby ( " TestQueue " ) // Joins a random room in the queue TestQueue
Utilla . Utils . RoomUtils . JoinModdedLobby ( " TestQueue " , true ) // Joins a random casual room in the queue TestQueue
该项目是使用 .NET Standard 使用 C# 构建的。
作为参考,请在与项目解决方案相同的文件夹中创建一个 Libs 文件夹。在此文件夹内,您需要复制:
0Harmony.dll
BepInEx.dll
BepInEx.Harmony.dll
来自Gorilla TagBepInExplugins
,以及
Assembly-CSharp.dll
PhotonRealtime.dll
PhotonUnityNetworking.dll
UnityEngine.dll
UnityEngine.CoreModule.dll
来自Gorilla TagGorilla Tag_DataManaged
。
本产品不隶属于 Gorilla Tag 或 Another Axiom LLC,也未得到 Another Axiom LLC 的认可或赞助。本文包含的部分材料属于 Another Axiom LLC 的财产。 ©2021 Another Axiom LLC。