-
Notifications
You must be signed in to change notification settings - Fork 8
Mod Creation_C# Programming_Game Code_Tips and Tricks
Quentin E. / iDeath edited this page Jul 1, 2022
·
5 revisions
https://docs.unity3d.com/uploads/Main/monobehaviour_flowchart.svg
RoR2.Util has a lot of existing helping methods such as CheckRoll, ApplySpread, QuaternionSafeLookRotation, and PlaySound. Consider taking a look there before making any existing methods.
for (int i = 0; i < CharacterMaster.readOnlyInstancesList.Count; i++)
{
//CharacterMaster.readOnlyInstancesList[i] is the player.
}
or
var instances = PlayerCharacterMasterController.instances;
foreach (PlayerCharacterMasterController playerCharacterMaster in instances)
{
//You can get the master via playerCharacterMaster.master
//and the body via playerCharacterMaster.master.GetBody()
}
PlayerCharacterMasterController.instances[0].master
On.RoR2.HealthComponent.TakeDamage += (orig, self, damageInfo) => {
var charComponent = self.GetComponent<CharacterBody>();
if (charComponent != null && charComponent.isPlayerControlled)
{
return;
}
orig(self, damageInfo);
};
using R2API.Utils;
public int ToggleCursor()
{
var pes = MPEventSystemManager.primaryEventSystem;
pes.cursorOpenerCount = pes.cursorOpenerCount > 0 ? 0 : 1;
return pes.cursorOpenerCount;
}
On.RoR2.RoR2Application.UnitySystemConsoleRedirector.Redirect += orig => { };
Chat.SendBroadcastChat(new SimpleChatMessage { baseToken = "<color=#e5eefc>{0}: {1}</color>", paramTokens = new [] { "SOME_USERNAME_STRING", "SOME_TEXT_STRING" } })
If you want to send something custom
Chat.SendBroadcastChat(new SimpleChatMessage { baseToken = "<color=#e5eefc>{0}</color>", paramTokens = new [] { "SOME_TEXT_STRING" } })