2 REGISTER_NET_LINKED(ENT_CLIENT_CONVEYOR)
4 IntrusiveList g_conveyed;
5 STATIC_INIT(g_conveyed) { g_conveyed = IL_NEW(); }
7 void conveyor_think(entity this)
10 // TODO: check if this is what is causing the glitchiness when switching between them
11 float dt = time - this.move_time;
12 this.move_time = time;
13 if(dt <= 0) { return; }
16 // set mythis as current conveyor where possible
17 IL_EACH(g_conveyed, it.conveyor == this,
20 IL_REMOVE(g_conveyed, it);
25 FOREACH_ENTITY_RADIUS((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1, !it.conveyor.state && isPushable(it),
27 vector emin = it.absmin;
28 vector emax = it.absmax;
29 if(this.solid == SOLID_BSP)
34 if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
35 if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, it)) // accurate
38 IL_PUSH(g_conveyed, it);
43 IL_EACH(g_conveyed, it.conveyor == this,
45 if(IS_CLIENT(it)) // doing it via velocity has quite some advantages
46 continue; // done in SV_PlayerPhysics continue;
48 setorigin(it, it.origin + this.movedir * PHYS_INPUT_FRAMETIME);
49 move_out_of_solid(it);
51 UpdateCSQCProjectile(it);
54 // stupid conveyor code
55 tracebox(it.origin, it.mins, it.maxs, it.origin + this.movedir * sys_frametime, MOVE_NORMAL, it);
56 if(trace_fraction > 0)
57 setorigin(it, trace_endpos);
63 this.nextthink = time;
69 void conveyor_use(entity this, entity actor, entity trigger)
71 this.state = !this.state;
76 void conveyor_reset(entity this)
78 this.state = (this.spawnflags & 1);
83 bool conveyor_send(entity this, entity to, int sf)
85 WriteHeader(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
86 WriteByte(MSG_ENTITY, sf);
90 WriteByte(MSG_ENTITY, this.warpzone_isboxy);
91 WriteCoord(MSG_ENTITY, this.origin_x);
92 WriteCoord(MSG_ENTITY, this.origin_y);
93 WriteCoord(MSG_ENTITY, this.origin_z);
95 WriteCoord(MSG_ENTITY, this.mins_x);
96 WriteCoord(MSG_ENTITY, this.mins_y);
97 WriteCoord(MSG_ENTITY, this.mins_z);
98 WriteCoord(MSG_ENTITY, this.maxs_x);
99 WriteCoord(MSG_ENTITY, this.maxs_y);
100 WriteCoord(MSG_ENTITY, this.maxs_z);
102 WriteCoord(MSG_ENTITY, this.movedir_x);
103 WriteCoord(MSG_ENTITY, this.movedir_y);
104 WriteCoord(MSG_ENTITY, this.movedir_z);
106 WriteByte(MSG_ENTITY, this.speed);
107 WriteByte(MSG_ENTITY, this.state);
109 WriteString(MSG_ENTITY, this.targetname);
110 WriteString(MSG_ENTITY, this.target);
114 WriteByte(MSG_ENTITY, this.state);
119 void conveyor_init(entity this)
121 if (!this.speed) this.speed = 200;
122 this.movedir *= this.speed;
123 setthink(this, conveyor_think);
124 this.nextthink = time;
127 this.use = conveyor_use;
128 this.reset = conveyor_reset;
136 Net_LinkEntity(this, 0, false, conveyor_send);
141 spawnfunc(trigger_conveyor)
148 spawnfunc(func_conveyor)
151 InitMovingBrushTrigger(this);
152 set_movetype(this, MOVETYPE_NONE);
158 void conveyor_draw(entity this) { conveyor_think(this); }
160 void conveyor_init(entity this)
162 this.draw = conveyor_draw;
163 IL_PUSH(g_drawables, this);
164 this.drawmask = MASK_NORMAL;
166 set_movetype(this, MOVETYPE_NONE);
168 this.solid = SOLID_TRIGGER;
169 this.move_time = time;
172 NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
178 this.warpzone_isboxy = ReadByte();
179 this.origin_x = ReadCoord();
180 this.origin_y = ReadCoord();
181 this.origin_z = ReadCoord();
182 setorigin(this, this.origin);
184 this.mins_x = ReadCoord();
185 this.mins_y = ReadCoord();
186 this.mins_z = ReadCoord();
187 this.maxs_x = ReadCoord();
188 this.maxs_y = ReadCoord();
189 this.maxs_z = ReadCoord();
190 setsize(this, this.mins, this.maxs);
192 this.movedir_x = ReadCoord();
193 this.movedir_y = ReadCoord();
194 this.movedir_z = ReadCoord();
196 this.speed = ReadByte();
197 this.state = ReadByte();
199 this.targetname = strzone(ReadString());
200 this.target = strzone(ReadString());
206 this.state = ReadByte();