Skip to content

Code Samples

DillyzThe1 edited this page Dec 26, 2022 · 6 revisions

Code Samples

NOTE: These code samples are intended to be modified. They may not work as intended until said action is done.

Summary

This is a page in which you can find examples of custom Code Samples made to recreate certain aspects or functions.
Have fun.

Kill Button

Note: This will not work unless you have an embedded resource of kill.png and replace the asset path with one output by the game console saying your embedded resource's path.
Explanation [1] [2]

CustomButton killButton = DillyzUtil.addButton(System.Reflection.Assembly.GetExecutingAssembly(), "Kill Button", "ExampleRolePackage.kill.png", -1f, true, new string[] { "Impostor", "ShapeShifter" }, new string[] { "Impostor", "ShapeShifter" }, delegate(KillButtonCustomData button, bool success) {
    if (!success)
        return;
    DillyzUtil.RpcCommitAssassination(PlayerControl.LocalPlayer, button.killButton.currentTarget);
});
killButton.buttonText = "Kill";
killButton.textOutlineColor = new Color32(253, 25, 25, 255);

Impostor Role

[Explanation]

CustomRole impostorRole = DillyzUtil.createRole("Impostor", "Kill crewmates and hide in vents.", true, false, new Color32(253, 25, 25, 255), true, CustomRoleSide.Impostor, VentPrivilege.Impostor, true, true);
impostorRole.a_or_an = "an";

Crewmate Role

[Explanation]

CustomRole crewmateRole = DillyzUtil.createRole("Crewmate", "Do tasks and vote out suspects.", false, false, new Color32(139, 253, 253, 255), false, CustomRoleSide.Crewmate, VentPrivilege.None, false, false);
crewmateRole.a_or_an = "an";

Custom GameObject

Note: This will not work unless you have an embedded resource of your png and replace the asset path with one output by the game console saying your embedded resource's path.
Explanation [1] [2] [3] [4]

GameObject customObject = new GameObject(); // [1]
customObject.name = "goober";
customObject.transform.position = PlayerControl.LocalPlayer.transform.position; // [2]
SpriteRenderer sprrend = customObject.AddComponent<SpriteRenderer>(); // [3]
sprrend.sprite = DillyzUtil.getSprite(System.Reflection.Assembly.GetExecutingAssembly(), "ExampleRolePack.goober.png"); // [4]
Clone this wiki locally