2 REGISTER_NET_LINKED(ENT_CLIENT_CONVEYOR)
4 void conveyor_think(entity this)
7 // TODO: check if this is what is causing the glitchiness when switching between them
8 float dt = time - this.move_time;
10 if(dt <= 0) { return; }
13 // set myself as current conveyor where possible
14 IL_EACH(g_conveyed, it.conveyor == this,
17 IL_REMOVE(g_conveyed, it);
20 if(this.active == ACTIVE_ACTIVE)
22 FOREACH_ENTITY_RADIUS((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1, it.conveyor.active == ACTIVE_NOT && isPushable(it),
24 vector emin = it.absmin;
25 vector emax = it.absmax;
26 if(this.solid == SOLID_BSP)
31 if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
32 if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, it)) // accurate
35 IL_PUSH(g_conveyed, it);
40 IL_EACH(g_conveyed, it.conveyor == this,
42 if(IS_CLIENT(it)) // doing it via velocity has quite some advantages
43 continue; // done in SV_PlayerPhysics continue;
45 setorigin(it, it.origin + this.movedir * PHYS_INPUT_FRAMETIME);
46 move_out_of_solid(it);
48 UpdateCSQCProjectile(it);
51 // stupid conveyor code
52 tracebox(it.origin, it.mins, it.maxs, it.origin + this.movedir * sys_frametime, MOVE_NORMAL, it);
53 if(trace_fraction > 0)
54 setorigin(it, trace_endpos);
60 this.nextthink = time;
66 bool conveyor_send(entity this, entity to, int sendflags)
68 WriteHeader(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
69 WriteByte(MSG_ENTITY, sendflags);
71 if(sendflags & SF_TRIGGER_INIT)
73 WriteByte(MSG_ENTITY, this.warpzone_isboxy);
74 WriteVector(MSG_ENTITY, this.origin);
76 WriteVector(MSG_ENTITY, this.mins);
77 WriteVector(MSG_ENTITY, this.maxs);
79 WriteVector(MSG_ENTITY, this.movedir);
81 WriteByte(MSG_ENTITY, this.speed);
82 WriteByte(MSG_ENTITY, this.active);
84 WriteString(MSG_ENTITY, this.targetname);
85 WriteString(MSG_ENTITY, this.target);
88 if(sendflags & SF_TRIGGER_UPDATE)
89 WriteByte(MSG_ENTITY, this.active);
94 void conveyor_init(entity this)
96 if (!this.speed) this.speed = 200;
97 this.movedir *= this.speed;
98 setthink(this, conveyor_think);
99 this.nextthink = time;
100 this.setactive = generic_netlinked_setactive;
103 // backwards compatibility
104 this.use = generic_netlinked_legacy_use;
106 this.reset = generic_netlinked_reset;
111 Net_LinkEntity(this, 0, false, conveyor_send);
113 this.SendFlags |= SF_TRIGGER_INIT;
116 spawnfunc(trigger_conveyor)
123 spawnfunc(func_conveyor)
126 InitMovingBrushTrigger(this);
127 set_movetype(this, MOVETYPE_NONE);
133 void conveyor_draw(entity this) { conveyor_think(this); }
135 void conveyor_init(entity this, bool isnew)
138 IL_PUSH(g_drawables, this);
139 this.draw = conveyor_draw;
140 this.drawmask = MASK_NORMAL;
142 set_movetype(this, MOVETYPE_NONE);
144 this.solid = SOLID_TRIGGER;
145 this.move_time = time;
148 NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
150 int sendflags = ReadByte();
152 if(sendflags & SF_TRIGGER_INIT)
154 this.warpzone_isboxy = ReadByte();
155 this.origin = ReadVector();
156 setorigin(this, this.origin);
158 this.mins = ReadVector();
159 this.maxs = ReadVector();
160 setsize(this, this.mins, this.maxs);
162 this.movedir = ReadVector();
164 this.speed = ReadByte();
165 this.active = ReadByte();
167 this.targetname = strzone(ReadString());
168 this.target = strzone(ReadString());
170 conveyor_init(this, isnew);
173 if(sendflags & SF_TRIGGER_UPDATE)
174 this.active = ReadByte();