@@ -77,22 +77,23 @@ public struct SpawnInfo : IEquatable<SpawnInfo>
77
77
internal Vector3 Scale { get ; }
78
78
// For the sake of backwards compatibility, a scale of 0x0x0 is automatically converted to 1x1x1. Sorry, no 0x scale entities allowed.
79
79
internal Vector3 ActualScale => Scale == default ? Vector3 . one : Scale ;
80
+ internal Action < GameObject > OnSpawned { get ; }
80
81
81
82
/// <summary>
82
83
/// Initializes a new <see cref="SpawnInfo"/>.
83
84
/// </summary>
84
85
/// <param name="techType">TechType to spawn.</param>
85
86
/// <param name="spawnPosition">Position to spawn into.</param>
86
87
public SpawnInfo ( TechType techType , Vector3 spawnPosition )
87
- : this ( default , techType , spawnPosition , Quaternion . identity , Vector3 . one ) { }
88
+ : this ( default , techType , spawnPosition , Quaternion . identity , Vector3 . one , null ) { }
88
89
89
90
/// <summary>
90
91
/// Initializes a new <see cref="SpawnInfo"/>.
91
92
/// </summary>
92
93
/// <param name="classId">ClassID to spawn.</param>
93
94
/// <param name="spawnPosition">Position to spawn into.</param>
94
95
public SpawnInfo ( string classId , Vector3 spawnPosition )
95
- : this ( classId , default , spawnPosition , Quaternion . identity , Vector3 . one ) { }
96
+ : this ( classId , default , spawnPosition , Quaternion . identity , Vector3 . one , null ) { }
96
97
97
98
/// <summary>
98
99
/// Initializes a new <see cref="SpawnInfo"/>.
@@ -101,7 +102,7 @@ public SpawnInfo(string classId, Vector3 spawnPosition)
101
102
/// <param name="spawnPosition">Position to spawn into.</param>
102
103
/// <param name="rotation">Rotation to spawn at.</param>
103
104
public SpawnInfo ( TechType techType , Vector3 spawnPosition , Quaternion rotation )
104
- : this ( default , techType , spawnPosition , rotation , Vector3 . one ) { }
105
+ : this ( default , techType , spawnPosition , rotation , Vector3 . one , null ) { }
105
106
106
107
/// <summary>
107
108
/// Initializes a new <see cref="SpawnInfo"/>.
@@ -110,7 +111,7 @@ public SpawnInfo(TechType techType, Vector3 spawnPosition, Quaternion rotation)
110
111
/// <param name="spawnPosition">Position to spawn into.</param>
111
112
/// <param name="rotation">Rotation to spawn at.</param>
112
113
public SpawnInfo ( string classId , Vector3 spawnPosition , Quaternion rotation )
113
- : this ( classId , default , spawnPosition , rotation , Vector3 . one ) { }
114
+ : this ( classId , default , spawnPosition , rotation , Vector3 . one , null ) { }
114
115
115
116
/// <summary>
116
117
/// Initializes a new <see cref="SpawnInfo"/>.
@@ -120,7 +121,7 @@ public SpawnInfo(string classId, Vector3 spawnPosition, Quaternion rotation)
120
121
/// <param name="rotation">Rotation to spawn at.</param>
121
122
/// <param name="scale">Scale to spawn with.</param>
122
123
public SpawnInfo ( TechType techType , Vector3 spawnPosition , Quaternion rotation , Vector3 scale )
123
- : this ( default , techType , spawnPosition , rotation , scale ) { }
124
+ : this ( default , techType , spawnPosition , rotation , scale , null ) { }
124
125
125
126
/// <summary>
126
127
/// Initializes a new <see cref="SpawnInfo"/>.
@@ -130,7 +131,7 @@ public SpawnInfo(TechType techType, Vector3 spawnPosition, Quaternion rotation,
130
131
/// <param name="rotation">Rotation to spawn at.</param>
131
132
/// <param name="scale">Scale to spawn with.</param>
132
133
public SpawnInfo ( string classId , Vector3 spawnPosition , Quaternion rotation , Vector3 scale )
133
- : this ( classId , default , spawnPosition , rotation , scale ) { }
134
+ : this ( classId , default , spawnPosition , rotation , scale , null ) { }
134
135
135
136
/// <summary>
136
137
/// Initializes a new <see cref="SpawnInfo"/>.
@@ -139,7 +140,7 @@ public SpawnInfo(string classId, Vector3 spawnPosition, Quaternion rotation, Vec
139
140
/// <param name="spawnPosition">Position to spawn into.</param>
140
141
/// <param name="rotation">Rotation to spawn at.</param>
141
142
public SpawnInfo ( TechType techType , Vector3 spawnPosition , Vector3 rotation )
142
- : this ( default , techType , spawnPosition , Quaternion . Euler ( rotation ) , Vector3 . one ) { }
143
+ : this ( default , techType , spawnPosition , Quaternion . Euler ( rotation ) , Vector3 . one , null ) { }
143
144
144
145
/// <summary>
145
146
/// Initializes a new <see cref="SpawnInfo"/>.
@@ -148,7 +149,7 @@ public SpawnInfo(TechType techType, Vector3 spawnPosition, Vector3 rotation)
148
149
/// <param name="spawnPosition">Position to spawn into.</param>
149
150
/// <param name="rotation">Rotation to spawn at.</param>
150
151
public SpawnInfo ( string classId , Vector3 spawnPosition , Vector3 rotation )
151
- : this ( classId , default , spawnPosition , Quaternion . Euler ( rotation ) , Vector3 . one ) { }
152
+ : this ( classId , default , spawnPosition , Quaternion . Euler ( rotation ) , Vector3 . one , null ) { }
152
153
153
154
/// <summary>
154
155
/// Initializes a new <see cref="SpawnInfo"/>.
@@ -158,7 +159,7 @@ public SpawnInfo(string classId, Vector3 spawnPosition, Vector3 rotation)
158
159
/// <param name="rotation">Rotation to spawn at.</param>
159
160
/// <param name="scale">Scale to spawn with.</param>
160
161
public SpawnInfo ( TechType techType , Vector3 spawnPosition , Vector3 rotation , Vector3 scale )
161
- : this ( default , techType , spawnPosition , Quaternion . Euler ( rotation ) , scale ) { }
162
+ : this ( default , techType , spawnPosition , Quaternion . Euler ( rotation ) , scale , null ) { }
162
163
163
164
/// <summary>
164
165
/// Initializes a new <see cref="SpawnInfo"/>.
@@ -168,10 +169,32 @@ public SpawnInfo(TechType techType, Vector3 spawnPosition, Vector3 rotation, Vec
168
169
/// <param name="rotation">Rotation to spawn at.</param>
169
170
/// <param name="scale">Scale to spawn with.</param>
170
171
public SpawnInfo ( string classId , Vector3 spawnPosition , Vector3 rotation , Vector3 scale )
171
- : this ( classId , default , spawnPosition , Quaternion . Euler ( rotation ) , scale ) { }
172
+ : this ( classId , default , spawnPosition , Quaternion . Euler ( rotation ) , scale , null ) { }
173
+
174
+ /// <summary>
175
+ /// Initializes a new <see cref="SpawnInfo"/>.
176
+ /// </summary>
177
+ /// <param name="techType">TechType to spawn.</param>
178
+ /// <param name="spawnPosition">Position to spawn into.</param>
179
+ /// <param name="rotation">Rotation to spawn at.</param>
180
+ /// <param name="scale">Scale to spawn with.</param>
181
+ /// <param name="onSpawned">Callback that is used when the object is successfully spawned.</param>
182
+ public SpawnInfo ( TechType techType , Vector3 spawnPosition , Quaternion rotation , Vector3 scale , Action < GameObject > onSpawned )
183
+ : this ( default , techType , spawnPosition , rotation , scale , onSpawned ) { }
172
184
185
+ /// <summary>
186
+ /// Initializes a new <see cref="SpawnInfo"/>.
187
+ /// </summary>
188
+ /// <param name="classId">ClassID to spawn.</param>
189
+ /// <param name="spawnPosition">Position to spawn into.</param>
190
+ /// <param name="rotation">Rotation to spawn at.</param>
191
+ /// <param name="scale">Scale to spawn with.</param>
192
+ /// <param name="onSpawned">Callback that is used when the object is successfully spawned.</param>
193
+ public SpawnInfo ( string classId , Vector3 spawnPosition , Quaternion rotation , Vector3 scale , Action < GameObject > onSpawned )
194
+ : this ( classId , default , spawnPosition , rotation , scale , onSpawned ) { }
195
+
173
196
[ JsonConstructor ]
174
- internal SpawnInfo ( string classId , TechType techType , Vector3 spawnPosition , Quaternion rotation , Vector3 scale )
197
+ internal SpawnInfo ( string classId , TechType techType , Vector3 spawnPosition , Quaternion rotation , Vector3 scale , Action < GameObject > onSpawned )
175
198
{
176
199
ClassId = classId ;
177
200
TechType = techType ;
@@ -183,6 +206,7 @@ internal SpawnInfo(string classId, TechType techType, Vector3 spawnPosition, Qua
183
206
_ => SpawnType . TechType
184
207
} ;
185
208
Scale = scale ;
209
+ OnSpawned = onSpawned ;
186
210
}
187
211
188
212
/// <summary>
0 commit comments