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 if (WarpZoneLib_ExactTrigger_Touch(this, it, false))
27 IL_PUSH(g_conveyed, it);
32 IL_EACH(g_conveyed, it.conveyor == this,
34 if(IS_CLIENT(it)) // doing it via velocity has quite some advantages
35 continue; // done in SV_PlayerPhysics continue;
37 setorigin(it, it.origin + this.movedir * PHYS_INPUT_FRAMETIME);
38 move_out_of_solid(it);
40 UpdateCSQCProjectile(it);
43 // stupid conveyor code
44 tracebox(it.origin, it.mins, it.maxs, it.origin + this.movedir * sys_frametime, MOVE_NORMAL, it);
45 if(trace_fraction > 0)
46 setorigin(it, trace_endpos);
52 this.nextthink = time;
58 bool conveyor_send(entity this, entity to, int sendflags)
60 WriteHeader(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
61 WriteByte(MSG_ENTITY, sendflags);
63 if(sendflags & SF_TRIGGER_INIT)
65 WriteByte(MSG_ENTITY, this.warpzone_isboxy);
66 WriteVector(MSG_ENTITY, this.origin);
68 WriteVector(MSG_ENTITY, this.mins);
69 WriteVector(MSG_ENTITY, this.maxs);
71 WriteVector(MSG_ENTITY, this.movedir);
73 WriteByte(MSG_ENTITY, this.speed);
74 WriteByte(MSG_ENTITY, this.active);
76 WriteString(MSG_ENTITY, this.targetname);
77 WriteString(MSG_ENTITY, this.target);
80 if(sendflags & SF_TRIGGER_UPDATE)
81 WriteByte(MSG_ENTITY, this.active);
86 void conveyor_init(entity this)
88 if (!this.speed) this.speed = 200;
89 this.movedir *= this.speed;
90 setthink(this, conveyor_think);
91 this.nextthink = time;
92 this.setactive = generic_netlinked_setactive;
93 if(this.targetname && this.targetname != "")
95 // backwards compatibility
96 this.use = generic_netlinked_legacy_use;
98 this.reset = generic_netlinked_reset;
101 Net_LinkEntity(this, 0, false, conveyor_send);
103 this.SendFlags |= SF_TRIGGER_INIT;
106 spawnfunc(trigger_conveyor)
113 spawnfunc(func_conveyor)
116 InitMovingBrushTrigger(this);
117 set_movetype(this, MOVETYPE_NONE);
123 void conveyor_draw(entity this) { conveyor_think(this); }
125 void conveyor_init(entity this, bool isnew)
128 IL_PUSH(g_drawables, this);
129 this.draw = conveyor_draw;
130 this.drawmask = MASK_NORMAL;
132 set_movetype(this, MOVETYPE_NONE);
134 this.solid = SOLID_TRIGGER;
135 this.move_time = time;
138 NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
140 int sendflags = ReadByte();
142 if(sendflags & SF_TRIGGER_INIT)
144 this.warpzone_isboxy = ReadByte();
145 this.origin = ReadVector();
146 setorigin(this, this.origin);
148 this.mins = ReadVector();
149 this.maxs = ReadVector();
150 setsize(this, this.mins, this.maxs);
152 this.movedir = ReadVector();
154 this.speed = ReadByte();
155 this.active = ReadByte();
157 this.targetname = strzone(ReadString());
158 this.target = strzone(ReadString());
160 conveyor_init(this, isnew);
163 if(sendflags & SF_TRIGGER_UPDATE)
164 this.active = ReadByte();