1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
/*
Copyright (C) 1997-2001 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 08.11.2003 by RST.
// $Id: entity_state_t.java,v 1.3 2004-08-20 21:29:58 salomo Exp $
package jake2.game;
import java.io.IOException;
import java.io.RandomAccessFile;
import jake2.util.Math3D;
import jake2.util.QuakeFile;
public class entity_state_t implements Cloneable
{
/** entity_state_t is the information conveyed from the server
in an update message about entities that the client will
need to render in some way. */
public entity_state_t(edict_t ent)
{
this.surrounding_ent = ent;
}
/** edict index. */
public int number = -99999;
public edict_t surrounding_ent = null;
public float[] origin = { 0, 0, 0 };
public float[] angles = { 0, 0, 0 };
/** for lerping. */
public float[] old_origin = { 0, 0, 0 };
public int modelindex;
/** weapons, CTF flags, etc. */
public int modelindex2, modelindex3, modelindex4;
public int frame;
public int skinnum;
/** PGM - we're filling it, so it needs to be unsigned. */
public int effects;
public int renderfx;
public int solid;
// for client side prediction, 8*(bits 0-4) is x/y radius
// 8*(bits 5-9) is z down distance, 8(bits10-15) is z up
// gi.linkentity sets this properly
public int sound; // for looping sounds, to guarantee shutoff
public int event; // impulse events -- muzzle flashes, footsteps, etc
// events only go out for a single frame, they
// are automatically cleared each frame
/** Writes the entity state to the file. */
public void write(QuakeFile f) throws IOException
{
f.writeEdictRef(surrounding_ent);
f.writeVector(origin);
f.writeVector(angles);
f.writeVector(old_origin);
f.writeInt(modelindex);
f.writeInt(modelindex2);
f.writeInt(modelindex3);
f.writeInt(modelindex4);
f.writeInt(frame);
f.writeInt(skinnum);
f.writeInt(effects);
f.writeInt(renderfx);
f.writeInt(solid);
f.writeInt(sound);
f.writeInt(event);
}
/** Reads the entity state from the file. */
public void read(QuakeFile f) throws IOException
{
surrounding_ent = f.readEdictRef();
origin = f.readVector();
angles = f.readVector();
old_origin = f.readVector();
modelindex = f.readInt();
modelindex2= f.readInt();
modelindex3= f.readInt();
modelindex4= f.readInt();
frame = f.readInt();
skinnum = f.readInt();
effects = f.readInt();
renderfx = f.readInt();
solid = f.readInt();
sound = f.readInt();
event = f.readInt();
}
public entity_state_t getClone()
{
entity_state_t out = new entity_state_t(this.surrounding_ent);
out.set(this);
return out;
}
public void set(entity_state_t from)
{
number = from.number;
Math3D.VectorCopy(from.origin, origin);
Math3D.VectorCopy(from.angles, angles);
Math3D.VectorCopy(from.old_origin, old_origin);
modelindex = from.modelindex;
modelindex2 = from.modelindex2;
modelindex3 = from.modelindex3;
modelindex4 = from.modelindex4;
frame = from.frame;
skinnum = from.skinnum;
effects = from.effects;
renderfx = from.renderfx;
solid = from.solid;
sound = from.sound;
event = from.event;
}
}
|