-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcue.gd
More file actions
166 lines (138 loc) · 6.1 KB
/
Copy pathcue.gd
File metadata and controls
166 lines (138 loc) · 6.1 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
class_name Multrapool_Cue
static var MOD_NAME := "Multrapool-Cue"
static var CUE_VERSION := ""
static var CUE_ERA := "Chalk"
### libs
static var GALLERY
static func _create_singletons(holder:Node):
var sub_holder:Node = load("res://mods-unpacked/Multrapool-Cue/libs/lib_holder.tscn")\
.instantiate()
holder.add_child(sub_holder)
GALLERY=sub_holder.get_node("Multrapool_LibGallery")
### take over
static var _virtual_files:= []
static var modded_balls:=[]
static var _global_thingy_bc_godot_is_silly:= []
## Registers this file into the vanilla game files so it can be found where its supposed to be[br][br]
##
## [param modName]: The name of this mod[br]
## [param path]: The path of this file after res://mods-unpacked/modName/overwrites
static func take_over(modName:String, path:String):
var to_take_over = load("res://mods-unpacked/"+modName+"/overwrites/"+path)
to_take_over.take_over_path("res://"+path)
_virtual_files.append("res://"+path)
_global_thingy_bc_godot_is_silly.append(to_take_over)
if path.begins_with("data/balls_data/"):
var resource = load("res://"+path)
if resource is BallResource:
modded_balls.append(resource.id)
### events
class _eventHolder:
const POCKET = 'POCKET'
const POCKET_ANOTHER = &"POCKET-ANOTHER"
const SPAWN = 'SPAWN'
const SPAWN_ANOTHER = &"SPAWN-ANOTHER"
const ROUND_START = &"ROUND-START"
const HIT = &"HIT"
const HIT_WALL = &"HIT-WALL"
const SCORE = &"SCORE"
const REACH_SCORE = &"REACH-SCORE"
const SCORE_CHANGE = &"SCORE-CHANGE"
const ROUND_END = &"ROUND-END"
const MAX_ROLL = &"MAX-ROLL"
const TRANSFORM = &"TRANSFORM"
const TRANSFORM_ANOTHER = &"TRANSFORM-ANOTHER"
const PICKUP_DROPLET = &"PICKUP-DROPLET"
const SHOOT = &"SHOOT"
const ENTER_SHOP = &"ENTER-SHOP"
const UPGRADE_BALL = &"UPGRADE-BALL"
const SELL_SELF = &"SELL-SELF"
const SELL_ANOTHER = &"SELL-ANOTHER"
const REROLL_SHOP = &"REROLL-SHOP"
const BUY = &"BUY"
const BUY_ANOTHER = &"BUY-ANOTHER"
const BUFF = &"BUFF"
const SPAWN_DROPLET = "Multrapool-SPAWN_DROPLET"
static var Events = _eventHolder.new()
static var _registeredBallEvents = {}
## Registers a callback to be run on some ball event[br][br]
##
## [param ball_id]: The id of the type of ball that should run this action[br]
## [param event]: A member of [ballEventHolder] (or a string, if you're using a custom event)[br]
## [param action]: A function that takes a [Ball], a dictionary of assorted values, and if it is the mixed side, and performs the event action[br]
## [param action] = func(ball:Ball, assorted:Dictionary, isMixedSide:bool)
static func register_ball_event(ball_id:String, event:String, action:Callable):
if !_registeredBallEvents.has(event):
_registeredBallEvents[event] = {}
_registeredBallEvents[event][ball_id] = action
if event != "SPAWN" and event != "POCKET":
Global.eventManager.HARDCODED_EVENT_LISTENERS[event].append(ball_id)
elif event == "SPAWN":
Global.eventManager.SPAWN_EFFECTS.set(ball_id,"")
else:
Global.eventManager.POCKET_EFFECTS.set(ball_id,"")
## Gets the event for a ball[br][br]
##
## [param ball_id]: The id of the type of ball[br]
## [param event]: A member of [ballEventHolder] (or a string, if you're using a custom event)
## Returns the action that this ball will run, or null
static func get_ball_event(ball_id:String, event:String) -> Callable:
if _registeredBallEvents.has(event) and _registeredBallEvents[event].has(ball_id):
return _registeredBallEvents[event][ball_id]
return func(_a,_b,_c):return
## Checks if there is an event for a ball[br][br]
##
## [param ball_id]: The id of the type of ball[br]
## [param event]: A member of [ballEventHolder] (or a string, if you're using a custom event)
static func has_ball_event(ball_id:String, event:String) -> bool:
if _registeredBallEvents[event] == null:
return false
return _registeredBallEvents[event][ball_id] != null
static func call_ball_event(ball, event:String, additional:Dictionary):
var real_ball_item
if ball is Ball:
real_ball_item=ball.ball_item_og
if ball is ShopBall:
real_ball_item=ball.ball_item
assert(real_ball_item != null)
get_ball_event(real_ball_item.data.id, event).call(ball, additional, false)
if real_ball_item.is_mixed():
get_ball_event(real_ball_item.mixed_data.id, event).call(ball, additional, true)
static var _registeredEvents = {}
### Registers a callback to be run on some event[br][br]
###
### [param event]: A member of [eventHolder] (or a string, if you're using a custom event)[br]
### [param action]: A function that takes a dictionary of assorted values and performs the event action[br]
### [param action] = func(assorted:Dictionary)
static func register_event(event:String, action:Callable):
if !_registeredEvents.has(event):
_registeredEvents[event] = []
_registeredEvents[event].append(action)
static func call_event(event:String, additional:Dictionary):
if _registeredEvents.has(event):
for callback in _registeredEvents[event]:
callback.call(additional)
### custom droplets
static var _last_used_droplet = load("res://droplet.gd").DROPLET_TYPE.size()-1
static var _droplet_data := {}
static func register_droplet(init:Callable,
on_ball:Callable,
process:Callable,
remove:Callable) -> int:
_last_used_droplet+=1
_droplet_data[_last_used_droplet] = {
init=init,
on_ball=on_ball,
process=process,
remove=remove
}
return _last_used_droplet
### misc
static var initial_masses_and_scales:={}
### [param callback]: func(otherball_if_mixed:[BallResource]) -> [br]
### { weight_state:[enum Ball.WEIGHT_STATE], mass:[float], scale:[float] }[br][br]
###
### If any of the values of the dictionary are null,
### they will be set to their default values (NORMAL, 1, 1)
static func initial_mass_scale_callback(ball_id:String, callback:Callable):
initial_masses_and_scales[ball_id] = callback