-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPlugin.cs
More file actions
108 lines (92 loc) · 3.36 KB
/
Plugin.cs
File metadata and controls
108 lines (92 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using BepInEx;
using System;
using System.IO;
using System.Reflection;
using UnityEngine;
using Utilla;
namespace GorillaTagGhostEntity
{
/// <summary>
/// This is your mod's main class.
/// </summary>
/* This attribute tells Utilla to look for [ModdedGameJoin] and [ModdedGameLeave] */
[ModdedGamemode]
[BepInDependency("org.legoandmars.gorillatag.utilla", "1.5.0")]
[BepInPlugin(PluginInfo.GUID, PluginInfo.Name, PluginInfo.Version)]
public class Plugin : BaseUnityPlugin
{
bool inRoom;
void OnEnable()
{
/* Set up your mod here */
/* Code here runs at the start and whenever your mod is enabled*/
HarmonyPatches.ApplyHarmonyPatches();
Utilla.Events.GameInitialized += OnGameInitialized;
}
void OnDisable()
{
/* Undo mod setup here */
/* This provides support for toggling mods with ComputerInterface, please implement it :) */
/* Code here runs whenever your mod is disabled (including if it disabled on startup)*/
HarmonyPatches.RemoveHarmonyPatches();
Utilla.Events.GameInitialized -= OnGameInitialized;
}
void OnGameInitialized(object sender, EventArgs e)
{
Debug.Log("GhostEntity");
Stream str = Assembly.GetExecutingAssembly().GetManifestResourceStream("GorillaTagGhostEntity.Assets.ghostentity");
AssetBundle bundle = AssetBundle.LoadFromStream(str);
GameObject asset = bundle.LoadAsset<GameObject>("GhostEntityParent 1");
var localasset = Instantiate(asset);
Entity = localasset;
GameObject soundobj = GameObject.Find("GhostEntityObject");
AudioSource[] Sounds;
Sounds = soundobj.GetComponents<AudioSource>();
daisy = Sounds[0];
daisy.volume = 0.3f;
join = Sounds[1];
localasset.SetActive(false);
}
public GameObject Entity;
public AudioSource daisy;
public AudioSource join;
public bool flag = false;
void Update()
{
if (inRoom)
{
if (!flag)
{
flag = true;
Entity.SetActive(true);
join.Play();
daisy.Play();
}
}
else
{
if (flag)
{
flag = false;
Entity.SetActive(false);
}
}
}
/* This attribute tells Utilla to call this method when a modded room is joined */
[ModdedGamemodeJoin]
public void OnJoin(string gamemode)
{
/* Activate your mod here */
/* This code will run regardless of if the mod is enabled*/
inRoom = true;
}
/* This attribute tells Utilla to call this method when a modded room is left */
[ModdedGamemodeLeave]
public void OnLeave(string gamemode)
{
/* Deactivate your mod here */
/* This code will run regardless of if the mod is enabled*/
inRoom = false;
}
}
}