Skip to content

Commit a292eb4

Browse files
committed
2 parents 8fdbaa3 + bee681a commit a292eb4

1 file changed

Lines changed: 76 additions & 27 deletions

File tree

  • Example/modules/IronPythonModule/plugins/Test

Example/modules/IronPythonModule/plugins/Test/Test.py

Lines changed: 76 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,110 @@
44
clr.AddReferenceByPartialName("Fougerite")
55
import UnityEngine
66
import Fougerite
7+
from UnityEngine import Debug
78

89
class Test:
9-
def GetPlugin(self, plugin): # not yet done
10-
plugin.Name = "TestPluginName"
11-
plugin.Author = "balu92"
12-
plugin.Version = "1.0.0.0"
13-
return plugin
14-
1510
def On_TablesLoaded(self, tables):
16-
UnityEngine.Debug.Log("OnTablesLoaded hooked with " + tables.Count.ToString() + " element, from Python")
11+
# Debug.Log("On_TablesLoaded hooked with " + tables.Count.ToString() + " element, from Python")
12+
Plugin.DumpPropsToFile("On_TablesLoaded.Tables", tables)
1713
return tables
1814

1915
def On_AllPluginsLoaded(self):
20-
UnityEngine.Debug.Log("The knights who say NI! I mean HI!")
16+
Debug.Log("The knights who say NI! I mean HI!")
2117

2218
def On_ServerInit(self):
23-
UnityEngine.Debug.Log("OnServerInit hooked from Python")
19+
Debug.Log("On_ServerInit hooked from Python")
2420
dic = Plugin.CreateDict()
25-
dic.Add("key", "value")
21+
dic.Add("first", "timer is:")
22+
dic.Add("second", "working")
2623
Plugin.CreateTimer("testtimer", 5000, dic).Start()
2724

2825
def testtimerCallback(self, dic):
2926
plug2 = Plugin.GetPlugin("Test2")
30-
plug2.Invoke("TestSharedFunction", "Hello", "world!")
31-
UnityEngine.Debug.Log(dic["key"])
27+
plug2.Invoke("TestSharedFunction", dic["first"], dic["second"])
28+
Debug.Log(dic["first"])
29+
Debug.Log(dic["second"])
30+
Plugin.DumpPropsToFile("testtimerCallback.dic", dic)
31+
Plugin.KillTimers()
3232

3333
def On_PluginInit(self):
34-
UnityEngine.Debug.Log("ONPluginInit hooked from Python")
34+
Debug.Log("On_PluginInit hooked from Python")
3535

3636
def On_ServerShutdown(self):
37-
UnityEngine.Debug.Log("OnServerShutdown hooked from Python")
37+
Debug.Log("On_ServerShutdown hooked from Python")
38+
39+
def On_ItemsLoaded(self, items):
40+
# Debug.Log("On_ItemsLoaded hooked with " + items.Count + " element, from Python")
41+
Plugin.DumpPropsToFile("On_ItemsLoaded.Items", items)
42+
return items
3843

39-
# def OnItemsLoaded(self, items):
40-
# UnityEngine.Debug.Log("OnItemsLoaded hooked with " + items.Count + " element, from Python")
41-
# return items ## not sure if you need to return the 'items' here
4244
def On_Chat(self, Player, Text):
43-
UnityEngine.Debug.Log(Player.Name + " says: " + Text)
45+
# Debug.Log(Player.Name + " says: " + Text)
46+
Plugin.DumpPropsToFile("On_Chat.Player", Player)
47+
Plugin.DumpPropsToFile("On_Chat.Text", Text)
4448

4549
def On_BlueprintUse(self, Player, BPUseEvent):
46-
UnityEngine.Debug.Log(Player.Name + " researched " + BPUseEvent.ItemName)
50+
# Debug.Log(Player.Name + " researched " + BPUseEvent.ItemName)
51+
Plugin.DumpPropsToFile("On_BlueprintUse.Player", Player)
52+
Plugin.DumpPropsToFile("On_BlueprintUse.BPUseEvent", BPUseEvent)
4753

4854
def On_Command(self, Player, cmd, args):
49-
UnityEngine.Debug.Log("On_Command(" + Player.Name + ", " + cmd + ", " + args + ")")
55+
# Debug.Log("On_Command(" + Player.Name + ", " + cmd + ", " + args + ")")
56+
Plugin.DumpPropsToFile("On_Command.Player", Player)
57+
Plugin.DumpPropsToFile("On_Command.cmd", cmd)
58+
Plugin.DumpPropsToFile("On_Command.args", args)
5059

5160
def On_Console(self, Player, Arg):
52-
UnityEngine.Debug.Log(Player.Name + " used " + Arg.Class + "." + Arg.Function + " in console ")
61+
# Debug.Log(Player.Name + " used " + Arg.Class + "." + Arg.Function + " in console ")
62+
Plugin.DumpPropsToFile("On_Console.Player", Player)
63+
Plugin.DumpPropsToFile("On_Console.Arg", Arg)
5364

5465
def On_DoorUse(self, Player, DoorEvent):
55-
UnityEngine.Debug.Log(Player.Name + " tried to use a door")
56-
UnityEngine.Debug.Log("Succeded? " + ("yes" if DoorEvent.Open else "no"))
66+
# Debug.Log(Player.Name + " tried to use a door")
67+
# Debug.Log("Succeded? " + ("yes" if DoorEvent.Open else "no"))
68+
Plugin.DumpPropsToFile("On_DoorUse.Player", Player)
69+
Plugin.DumpPropsToFile("On_DoorUse.DoorEvent", DoorEvent)
70+
71+
def On_EntityDecay(self, DecayEvent):
72+
Plugin.DumpPropsToFile("On_EntityDecay.DecayEvent", DecayEvent)
73+
return DecayEvent.DamageAmount
5774

58-
# def On_EntityDecay(self, DecayEvent):
59-
# return DecayEvent.DamageAmount
6075
def On_EntityDeployed(self, Player, Enity):
61-
UnityEngine.Debug.Log(Player.Name + " deployed a(n) " + Entity.Name + " @ " + Player.Location.ToString())
76+
Plugin.DumpPropsToFile("On_EntityDeployed.Player", Player)
77+
Plugin.DumpPropsToFile("On_EntityDeployed.Enity", Enity)
6278

6379
def On_EntityHurt(self, he):
64-
UnityEngine.Debug.Log("python: " + he.Attacker.TimeOnline.ToString())
80+
Plugin.DumpPropsToFile("On_EntityHurt.HurtEvent", he)
81+
82+
def On_EntityDestroyed(self, de):
83+
Plugin.DumpPropsToFile("On_EntityDestroyed.DestroyEvent", de)
84+
85+
def On_NPCKilled(self, de):
86+
Plugin.DumpPropsToFile("On_NPCKilled.DeathEvent", de)
87+
88+
def On_NPCHurt(self, he):
89+
Plugin.DumpPropsToFile("On_NPCHurt.HurtEvent", he)
90+
91+
def On_PlayerGathering(self, Player, ge):
92+
Plugin.DumpPropsToFile("On_PlayerGathering.Player", Player)
93+
Plugin.DumpPropsToFile("On_PlayerGathering.GatherEvent", ge)
94+
95+
def On_PlayerSpawn(self, Player, se):
96+
Plugin.DumpPropsToFile("On_PlayerSpawn.Player", Player)
97+
Plugin.DumpPropsToFile("On_PlayerSpawn.SpawnEvent", se)
98+
99+
def On_PlayerSpawned(self, Player, se):
100+
Plugin.DumpPropsToFile("On_PlayerSpawned.Player", Player)
101+
Plugin.DumpPropsToFile("On_PlayerSpawned.SpawnEvent", se)
102+
103+
def On_PlayerKilled(self, de):
104+
Plugin.DumpPropsToFile("On_PlayerKilled.DeathEvent", de)
105+
106+
def On_PlayerHurt(self, he):
107+
Plugin.DumpPropsToFile("On_PlayerHurt.HurtEvent", he)
108+
109+
def On_PlayerConnected(self, Player):
110+
Plugin.DumpPropsToFile("On_PlayerConnected.Player", Player)
111+
112+
def On_PlayerDisconnected(self, he):
113+
Plugin.DumpPropsToFile("On_PlayerDisconnected.Player", Player)

0 commit comments

Comments
 (0)