Skip to content

Commit 4eaf6cd

Browse files
committed
"entity remove" fix
1 parent 76738ef commit 4eaf6cd

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

Client/Client.yyp

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Client/objects/oEntityManager/Create_0.gml

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ base_update = -1
1010
next_update = -1
1111
third_update = -1
1212

13+
entities_to_remove = {}
14+
1315
interpolateEntity = function(t, t1, inst, t2, s2, t3, s3) {
1416
var var_names = variable_struct_get_names(inst.__interpolation)
1517
for(var i = 0; i < array_length(var_names); i++) {

Client/objects/oEntityManager/Step_0.gml

+13-8
Original file line numberDiff line numberDiff line change
@@ -92,31 +92,36 @@ for(i = 0; i < l; i++) {
9292
var idx2 = next_e_idx[$ uuid]
9393
var idx3 = third_e_idx[$ uuid]
9494

95-
var will_exist = !is_undefined(idx2)
95+
var will_exist = !is_undefined(idx2) and is_undefined(entities_to_remove[$ uuid])
9696

9797
// don't create entities 1 frame before they are gone
9898
if (!existed and !will_exist) {
9999
continue
100100
}
101101

102-
var inst = find_or_create(uuid, type, , props)
103-
104102
// if it was just created - it's remote
105103
if (!existed) {
106-
inst.remote = true
107-
inst.x = entity.x
108-
inst.y = entity.y
104+
props.remote = true
109105
}
110-
106+
111107
if (uuid == global.player_uuid) {
112-
inst.remote = false
108+
props.remote = false
109+
}
110+
111+
var inst = find_or_create(uuid, type, , props)
112+
113+
if (entities_to_remove[$ uuid]) {
114+
instance_destroy(inst)
115+
continue
113116
}
114117

115118
// the reason I'm not using a with() statement here is because for some reason it is not equivallent to this, and produces weird errors (due to this being called in an Async event)
116119
inst.image_xscale = entity.xs
117120
inst.image_yscale = entity.ys
118121
inst.x = entity.x
119122
inst.y = entity.y
123+
inst.image_angle = entity.a
124+
inst.a = entity.a // set for interpolation
120125

121126
inst.state = state
122127

Client/scripts/entityHandlers/entityHandlers.gml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// a list of entities
22
addHandler("entities", function(data) {
3-
//if (use_timestamps(data)) return;
43

54
// don't spawn in entities if we're not playing (e.x in menus)
65
if (!global.playing) {
@@ -44,12 +43,13 @@ addHandler("entity remove", function(data) {
4443
if (use_timestamps(data))
4544
return;
4645

47-
trace("entity remove: %", data.id)
48-
4946
var uuid = data.id
5047
var obj = asset_get_index(data.obj)
5148
var inst = find_by_uuid(uuid, obj)
5249

50+
if (instance_exists(oEntityManager))
51+
oEntityManager.entities_to_remove[$ uuid] = true
52+
5353
if (instance_exists(inst))
5454
instance_destroy(inst)
5555
})

0 commit comments

Comments
 (0)