DEADSOFTWARE

net: sync moving items and flags
[d2df-sdl.git] / src / game / g_panel.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
16 {$M+}
17 unit g_panel;
19 interface
21 uses
22 SysUtils, Classes,
23 MAPDEF, g_textures, xdynrec;
25 type
26 TAddTextureArray = Array of
27 record
28 Texture: Cardinal;
29 Anim: Boolean;
30 end;
32 PPanel = ^TPanel;
33 TPanel = Class (TObject)
34 private
35 const
36 private
37 mGUID: Integer; // will be assigned in "g_map.pas"
38 FTextureWidth: Word;
39 FTextureHeight: Word;
40 FAlpha: Byte;
41 FBlending: Boolean;
42 FTextureIDs: Array of
43 record
44 case Anim: Boolean of
45 False: (Tex: Cardinal);
46 True: (AnTex: TAnimation);
47 end;
49 mMovingSpeed: TDFPoint;
50 mMovingStart: TDFPoint;
51 mMovingEnd: TDFPoint;
52 mMovingActive: Boolean;
53 mMoveOnce: Boolean;
55 mOldMovingActive: Boolean;
57 mSizeSpeed: TDFSize;
58 mSizeEnd: TDFSize;
60 mEndPosTrig: Integer;
61 mEndSizeTrig: Integer;
63 mNeedSend: Boolean; // for network
65 private
66 function getx1 (): Integer; inline;
67 function gety1 (): Integer; inline;
68 function getvisvalid (): Boolean; inline;
70 function getMovingSpeedX (): Integer; inline;
71 procedure setMovingSpeedX (v: Integer); inline;
72 function getMovingSpeedY (): Integer; inline;
73 procedure setMovingSpeedY (v: Integer); inline;
75 function getMovingStartX (): Integer; inline;
76 procedure setMovingStartX (v: Integer); inline;
77 function getMovingStartY (): Integer; inline;
78 procedure setMovingStartY (v: Integer); inline;
80 function getMovingEndX (): Integer; inline;
81 procedure setMovingEndX (v: Integer); inline;
82 function getMovingEndY (): Integer; inline;
83 procedure setMovingEndY (v: Integer); inline;
85 function getSizeSpeedX (): Integer; inline;
86 procedure setSizeSpeedX (v: Integer); inline;
87 function getSizeSpeedY (): Integer; inline;
88 procedure setSizeSpeedY (v: Integer); inline;
90 function getSizeEndX (): Integer; inline;
91 procedure setSizeEndX (v: Integer); inline;
92 function getSizeEndY (): Integer; inline;
93 procedure setSizeEndY (v: Integer); inline;
95 public
96 FCurTexture: Integer; // Íîìåð òåêóùåé òåêñòóðû
97 FCurFrame: Integer;
98 FCurFrameCount: Byte;
99 FX, FY: Integer;
100 FOldX, FOldY: Integer;
101 FWidth, FHeight: Word;
102 FOldW, FOldH: Word;
103 FPanelType: Word;
104 FEnabled: Boolean;
105 FDoor: Boolean;
106 FLiftType: Byte;
107 FLastAnimLoop: Byte;
108 // sorry, there fields are public to allow setting 'em in g_map; this should be fixed later
109 // for now, PLEASE, don't modify 'em, or all hell will break loose
110 arrIdx: Integer; // index in one of internal arrays; sorry
111 tag: Integer; // used in coldets and such; sorry; see g_map.GridTagXXX
112 proxyId: Integer; // proxy id in map grid (DO NOT USE!)
113 mapId: AnsiString; // taken directly from map file; dunno why it is here
114 hasTexTrigger: Boolean; // HACK: true when there's a trigger than can change my texture
116 constructor Create(PanelRec: TDynRecord;
117 AddTextures: TAddTextureArray;
118 CurTex: Integer;
119 var Textures: TLevelTextureArray; aguid: Integer);
120 destructor Destroy(); override;
122 procedure Draw (hasAmbient: Boolean; constref ambColor: TDFColor);
123 procedure DrawShadowVolume(lightX: Integer; lightY: Integer; radius: Integer);
124 procedure Update();
125 procedure SetFrame(Frame: Integer; Count: Byte);
126 procedure NextTexture(AnimLoop: Byte = 0);
127 procedure SetTexture(ID: Integer; AnimLoop: Byte = 0);
128 function GetTextureID(): Cardinal;
129 function GetTextureCount(): Integer;
130 function CanChangeTexture(): Boolean;
132 procedure SaveState (st: TStream);
133 procedure LoadState (st: TStream);
135 procedure positionChanged (); inline;
137 function getIsGBack (): Boolean; inline; // gRenderBackgrounds
138 function getIsGStep (): Boolean; inline; // gSteps
139 function getIsGWall (): Boolean; inline; // gWalls
140 function getIsGAcid1 (): Boolean; inline; // gAcid1
141 function getIsGAcid2 (): Boolean; inline; // gAcid2
142 function getIsGWater (): Boolean; inline; // gWater
143 function getIsGFore (): Boolean; inline; // gRenderForegrounds
144 function getIsGLift (): Boolean; inline; // gLifts
145 function getIsGBlockMon (): Boolean; inline; // gBlockMon
147 // get-and-clear
148 function gncNeedSend (): Boolean; inline;
149 procedure setDirty (); inline; // why `dirty`? 'cause i may introduce property `needSend` later
151 procedure lerp (t: Single; out tX, tY, tW, tH: Integer);
153 public
154 property visvalid: Boolean read getvisvalid; // panel is "visvalid" when it's width and height are positive
156 published
157 property guid: Integer read mGUID; // will be assigned in "g_map.pas"
158 property x0: Integer read FX;
159 property y0: Integer read FY;
160 property x1: Integer read getx1; // inclusive!
161 property y1: Integer read gety1; // inclusive!
162 property x: Integer read FX write FX;
163 property y: Integer read FY write FY;
164 property width: Word read FWidth write FWidth;
165 property height: Word read FHeight write FHeight;
166 property panelType: Word read FPanelType write FPanelType;
167 property enabled: Boolean read FEnabled write FEnabled;
168 property door: Boolean read FDoor write FDoor;
169 property liftType: Byte read FLiftType write FLiftType;
170 property lastAnimLoop: Byte read FLastAnimLoop write FLastAnimLoop;
172 property movingSpeedX: Integer read getMovingSpeedX write setMovingSpeedX;
173 property movingSpeedY: Integer read getMovingSpeedY write setMovingSpeedY;
174 property movingStartX: Integer read getMovingStartX write setMovingStartX;
175 property movingStartY: Integer read getMovingStartY write setMovingStartY;
176 property movingEndX: Integer read getMovingEndX write setMovingEndX;
177 property movingEndY: Integer read getMovingEndY write setMovingEndY;
178 property movingActive: Boolean read mMovingActive write mMovingActive;
179 property moveOnce: Boolean read mMoveOnce write mMoveOnce;
181 property sizeSpeedX: Integer read getSizeSpeedX write setSizeSpeedX;
182 property sizeSpeedY: Integer read getSizeSpeedY write setSizeSpeedY;
183 property sizeEndX: Integer read getSizeEndX write setSizeEndX;
184 property sizeEndY: Integer read getSizeEndY write setSizeEndY;
186 property isGBack: Boolean read getIsGBack;
187 property isGStep: Boolean read getIsGStep;
188 property isGWall: Boolean read getIsGWall;
189 property isGAcid1: Boolean read getIsGAcid1;
190 property isGAcid2: Boolean read getIsGAcid2;
191 property isGWater: Boolean read getIsGWater;
192 property isGFore: Boolean read getIsGFore;
193 property isGLift: Boolean read getIsGLift;
194 property isGBlockMon: Boolean read getIsGBlockMon;
196 public
197 property movingSpeed: TDFPoint read mMovingSpeed write mMovingSpeed;
198 property movingStart: TDFPoint read mMovingStart write mMovingStart;
199 property movingEnd: TDFPoint read mMovingEnd write mMovingEnd;
201 property sizeSpeed: TDFSize read mSizeSpeed write mSizeSpeed;
202 property sizeEnd: TDFSize read mSizeEnd write mSizeEnd;
204 property endPosTrigId: Integer read mEndPosTrig write mEndPosTrig;
205 property endSizeTrigId: Integer read mEndSizeTrig write mEndSizeTrig;
206 end;
208 TPanelArray = Array of TPanel;
210 const
211 LIFTTYPE_UP = 0;
212 LIFTTYPE_DOWN = 1;
213 LIFTTYPE_LEFT = 2;
214 LIFTTYPE_RIGHT = 3;
216 var
217 g_dbgpan_mplat_active: Boolean = {$IF DEFINED(D2F_DEBUG)}true{$ELSE}true{$ENDIF};
218 g_dbgpan_mplat_step: Boolean = false; // one step, and stop
221 implementation
223 uses
224 {$INCLUDE ../nogl/noGLuses.inc}
225 e_texture, g_basic, g_map, g_game, g_gfx, e_graphics, g_weapons, g_triggers,
226 g_console, g_language, g_monsters, g_player, g_grid, e_log, geom, utils, xstreams;
228 const
229 PANEL_SIGNATURE = $4C4E4150; // 'PANL'
231 { T P a n e l : }
233 constructor TPanel.Create(PanelRec: TDynRecord;
234 AddTextures: TAddTextureArray;
235 CurTex: Integer;
236 var Textures: TLevelTextureArray; aguid: Integer);
237 var
238 i: Integer;
239 tnum: Integer;
240 begin
241 X := PanelRec.X;
242 Y := PanelRec.Y;
243 FOldX := X;
244 FOldY := Y;
245 Width := PanelRec.Width;
246 Height := PanelRec.Height;
247 FOldW := Width;
248 FOldH := Height;
249 FAlpha := 0;
250 FBlending := False;
251 FCurFrame := 0;
252 FCurFrameCount := 0;
253 LastAnimLoop := 0;
255 mapId := PanelRec.id;
256 mGUID := aguid;
258 mMovingSpeed := PanelRec.moveSpeed;
259 mMovingStart := PanelRec.moveStart;
260 mMovingEnd := PanelRec.moveEnd;
261 mMovingActive := PanelRec['move_active'].value;
262 mOldMovingActive := mMovingActive;
263 mMoveOnce := PanelRec.moveOnce;
265 mSizeSpeed := PanelRec.sizeSpeed;
266 mSizeEnd := PanelRec.sizeEnd;
268 mEndPosTrig := PanelRec.endPosTrig;
269 mEndSizeTrig := PanelRec.endSizeTrig;
271 mNeedSend := false;
273 // Òèï ïàíåëè:
274 PanelType := PanelRec.PanelType;
275 Enabled := True;
276 Door := False;
277 LiftType := LIFTTYPE_UP;
278 hasTexTrigger := False;
280 case PanelType of
281 PANEL_OPENDOOR: begin Enabled := False; Door := True; end;
282 PANEL_CLOSEDOOR: Door := True;
283 PANEL_LIFTUP: LiftType := LIFTTYPE_UP; //???
284 PANEL_LIFTDOWN: LiftType := LIFTTYPE_DOWN;
285 PANEL_LIFTLEFT: LiftType := LIFTTYPE_LEFT;
286 PANEL_LIFTRIGHT: LiftType := LIFTTYPE_RIGHT;
287 end;
289 // Íåâèäèìàÿ:
290 if ByteBool(PanelRec.Flags and PANEL_FLAG_HIDE) then
291 begin
292 SetLength(FTextureIDs, 0);
293 FCurTexture := -1;
294 Exit;
295 end;
296 // Ïàíåëè, íå èñïîëüçóþùèå òåêñòóðû:
297 if ByteBool(PanelType and
298 (PANEL_LIFTUP or
299 PANEL_LIFTDOWN or
300 PANEL_LIFTLEFT or
301 PANEL_LIFTRIGHT or
302 PANEL_BLOCKMON)) then
303 begin
304 SetLength(FTextureIDs, 0);
305 FCurTexture := -1;
306 Exit;
307 end;
309 // Åñëè ýòî æèäêîñòü áåç òåêñòóðû - ñïåöòåêñòóðó:
310 if WordBool(PanelType and (PANEL_WATER or PANEL_ACID1 or PANEL_ACID2)) and
311 (not ByteBool(PanelRec.Flags and PANEL_FLAG_WATERTEXTURES)) then
312 begin
313 SetLength(FTextureIDs, 1);
314 FTextureIDs[0].Anim := False;
316 case PanelRec.PanelType of
317 PANEL_WATER:
318 FTextureIDs[0].Tex := LongWord(TEXTURE_SPECIAL_WATER);
319 PANEL_ACID1:
320 FTextureIDs[0].Tex := LongWord(TEXTURE_SPECIAL_ACID1);
321 PANEL_ACID2:
322 FTextureIDs[0].Tex := LongWord(TEXTURE_SPECIAL_ACID2);
323 end;
325 FCurTexture := 0;
326 Exit;
327 end;
329 SetLength(FTextureIDs, Length(AddTextures));
331 if CurTex < 0 then
332 FCurTexture := -1
333 else
334 if CurTex >= Length(FTextureIDs) then
335 FCurTexture := Length(FTextureIDs) - 1
336 else
337 FCurTexture := CurTex;
339 for i := 0 to Length(FTextureIDs)-1 do
340 begin
341 FTextureIDs[i].Anim := AddTextures[i].Anim;
342 if FTextureIDs[i].Anim then
343 begin // Àíèìèðîâàííàÿ òåêñòóðà
344 FTextureIDs[i].AnTex :=
345 TAnimation.Create(Textures[AddTextures[i].Texture].FramesID,
346 True, Textures[AddTextures[i].Texture].Speed);
347 FTextureIDs[i].AnTex.Blending := ByteBool(PanelRec.Flags and PANEL_FLAG_BLENDING);
348 FTextureIDs[i].AnTex.Alpha := PanelRec.Alpha;
349 end
350 else
351 begin // Îáû÷íàÿ òåêñòóðà
352 FTextureIDs[i].Tex := Textures[AddTextures[i].Texture].TextureID;
353 end;
354 end;
356 // Òåêñòóð íåñêîëüêî - íóæíî ñîõðàíÿòü òåêóùóþ:
357 //if Length(FTextureIDs) > 1 then SaveIt := True;
359 if (PanelRec.TextureRec = nil) then tnum := -1 else tnum := PanelRec.tagInt;
360 if (tnum < 0) then tnum := Length(Textures);
362 // Åñëè íå ñïåöòåêñòóðà, òî çàäàåì ðàçìåðû:
363 if ({PanelRec.TextureNum}tnum > High(Textures)) then
364 begin
365 e_WriteLog(Format('WTF?! tnum is out of limits! (%d : %d)', [tnum, High(Textures)]), TMsgType.Warning);
366 FTextureWidth := 2;
367 FTextureHeight := 2;
368 FAlpha := 0;
369 FBlending := ByteBool(0);
370 end
371 else if not g_Map_IsSpecialTexture(Textures[{PanelRec.TextureNum}tnum].TextureName) then
372 begin
373 FTextureWidth := Textures[{PanelRec.TextureNum}tnum].Width;
374 FTextureHeight := Textures[{PanelRec.TextureNum}tnum].Height;
375 FAlpha := PanelRec.Alpha;
376 FBlending := ByteBool(PanelRec.Flags and PANEL_FLAG_BLENDING);
377 end;
378 end;
380 destructor TPanel.Destroy();
381 var
382 i: Integer;
383 begin
384 for i := 0 to High(FTextureIDs) do
385 if FTextureIDs[i].Anim then
386 FTextureIDs[i].AnTex.Free();
387 SetLength(FTextureIDs, 0);
389 Inherited;
390 end;
392 procedure TPanel.lerp (t: Single; out tX, tY, tW, tH: Integer);
393 begin
394 if mMovingActive then
395 begin
396 tX := nlerp(FOldX, FX, t);
397 tY := nlerp(FOldY, FY, t);
398 tW := nlerp(FOldW, FWidth, t);
399 tH := nlerp(FOldH, FHeight, t);
400 end
401 else
402 begin
403 tX := FX;
404 tY := FY;
405 tW := FWidth;
406 tH := FHeight;
407 end;
408 end;
410 function TPanel.getx1 (): Integer; inline; begin result := X+Width-1; end;
411 function TPanel.gety1 (): Integer; inline; begin result := Y+Height-1; end;
412 function TPanel.getvisvalid (): Boolean; inline; begin result := (Width > 0) and (Height > 0); end;
414 function TPanel.getMovingSpeedX (): Integer; inline; begin result := mMovingSpeed.X; end;
415 procedure TPanel.setMovingSpeedX (v: Integer); inline; begin mMovingSpeed.X := v; end;
416 function TPanel.getMovingSpeedY (): Integer; inline; begin result := mMovingSpeed.Y; end;
417 procedure TPanel.setMovingSpeedY (v: Integer); inline; begin mMovingSpeed.Y := v; end;
419 function TPanel.getMovingStartX (): Integer; inline; begin result := mMovingStart.X; end;
420 procedure TPanel.setMovingStartX (v: Integer); inline; begin mMovingStart.X := v; end;
421 function TPanel.getMovingStartY (): Integer; inline; begin result := mMovingStart.Y; end;
422 procedure TPanel.setMovingStartY (v: Integer); inline; begin mMovingStart.Y := v; end;
424 function TPanel.getMovingEndX (): Integer; inline; begin result := mMovingEnd.X; end;
425 procedure TPanel.setMovingEndX (v: Integer); inline; begin mMovingEnd.X := v; end;
426 function TPanel.getMovingEndY (): Integer; inline; begin result := mMovingEnd.Y; end;
427 procedure TPanel.setMovingEndY (v: Integer); inline; begin mMovingEnd.Y := v; end;
429 function TPanel.getSizeSpeedX (): Integer; inline; begin result := mSizeSpeed.w; end;
430 procedure TPanel.setSizeSpeedX (v: Integer); inline; begin mSizeSpeed.w := v; end;
431 function TPanel.getSizeSpeedY (): Integer; inline; begin result := mSizeSpeed.h; end;
432 procedure TPanel.setSizeSpeedY (v: Integer); inline; begin mSizeSpeed.h := v; end;
434 function TPanel.getSizeEndX (): Integer; inline; begin result := mSizeEnd.w; end;
435 procedure TPanel.setSizeEndX (v: Integer); inline; begin mSizeEnd.w := v; end;
436 function TPanel.getSizeEndY (): Integer; inline; begin result := mSizeEnd.h; end;
437 procedure TPanel.setSizeEndY (v: Integer); inline; begin mSizeEnd.h := v; end;
439 function TPanel.getIsGBack (): Boolean; inline; begin result := ((tag and GridTagBack) <> 0); end;
440 function TPanel.getIsGStep (): Boolean; inline; begin result := ((tag and GridTagStep) <> 0); end;
441 function TPanel.getIsGWall (): Boolean; inline; begin result := ((tag and (GridTagWall or GridTagDoor)) <> 0); end;
442 function TPanel.getIsGAcid1 (): Boolean; inline; begin result := ((tag and GridTagAcid1) <> 0); end;
443 function TPanel.getIsGAcid2 (): Boolean; inline; begin result := ((tag and GridTagAcid2) <> 0); end;
444 function TPanel.getIsGWater (): Boolean; inline; begin result := ((tag and GridTagWater) <> 0); end;
445 function TPanel.getIsGFore (): Boolean; inline; begin result := ((tag and GridTagFore) <> 0); end;
446 function TPanel.getIsGLift (): Boolean; inline; begin result := ((tag and GridTagLift) <> 0); end;
447 function TPanel.getIsGBlockMon (): Boolean; inline; begin result := ((tag and GridTagBlockMon) <> 0); end;
449 function TPanel.gncNeedSend (): Boolean; inline; begin result := mNeedSend; mNeedSend := false; end;
450 procedure TPanel.setDirty (); inline; begin mNeedSend := true; end;
453 procedure TPanel.Draw (hasAmbient: Boolean; constref ambColor: TDFColor);
454 var
455 tx, ty, tw, th: Integer;
456 xx, yy: Integer;
457 NoTextureID: DWORD;
458 NW, NH: Word;
459 begin
460 if {Enabled and} (FCurTexture >= 0) and
461 (Width > 0) and (Height > 0) and (FAlpha < 255) {and
462 g_Collide(X, Y, Width, Height, sX, sY, sWidth, sHeight)} then
463 begin
464 lerp(gLerpFactor, tx, ty, tw, th);
465 if FTextureIDs[FCurTexture].Anim then
466 begin // Àíèìèðîâàííàÿ òåêñòóðà
467 if FTextureIDs[FCurTexture].AnTex = nil then
468 Exit;
470 for xx := 0 to (tw div FTextureWidth)-1 do
471 for yy := 0 to (th div FTextureHeight)-1 do
472 FTextureIDs[FCurTexture].AnTex.Draw(
473 tx + xx*FTextureWidth,
474 ty + yy*FTextureHeight, TMirrorType.None);
475 end
476 else
477 begin // Îáû÷íàÿ òåêñòóðà
478 case FTextureIDs[FCurTexture].Tex of
479 LongWord(TEXTURE_SPECIAL_WATER): e_DrawFillQuad(tx, ty, tx+tw-1, ty+th-1, 0, 0, 255, 0, TBlending.Filter);
480 LongWord(TEXTURE_SPECIAL_ACID1): e_DrawFillQuad(tx, ty, tx+tw-1, ty+th-1, 0, 230, 0, 0, TBlending.Filter);
481 LongWord(TEXTURE_SPECIAL_ACID2): e_DrawFillQuad(tx, ty, tx+tw-1, ty+th-1, 230, 0, 0, 0, TBlending.Filter);
482 LongWord(TEXTURE_NONE):
483 if g_Texture_Get('NOTEXTURE', NoTextureID) then
484 begin
485 e_GetTextureSize(NoTextureID, @NW, @NH);
486 e_DrawFill(NoTextureID, tx, ty, tw div NW, th div NH, 0, False, False);
487 end
488 else
489 begin
490 xx := tx + (tw div 2);
491 yy := ty + (th div 2);
492 e_DrawFillQuad(tx, ty, xx, yy, 255, 0, 255, 0);
493 e_DrawFillQuad(xx, ty, tx+tw-1, yy, 255, 255, 0, 0);
494 e_DrawFillQuad(tx, yy, xx, ty+th-1, 255, 255, 0, 0);
495 e_DrawFillQuad(xx, yy, tx+tw-1, ty+th-1, 255, 0, 255, 0);
496 end;
497 else
498 begin
499 if not mMovingActive then
500 e_DrawFill(FTextureIDs[FCurTexture].Tex, tx, ty, tw div FTextureWidth, th div FTextureHeight, FAlpha, True, FBlending, hasAmbient)
501 else
502 e_DrawFillX(FTextureIDs[FCurTexture].Tex, tx, ty, tw, th, FAlpha, True, FBlending, g_dbg_scale, hasAmbient);
503 if hasAmbient then e_AmbientQuad(tx, ty, tw, th, ambColor.r, ambColor.g, ambColor.b, ambColor.a);
504 end;
505 end;
506 end;
507 end;
508 end;
510 procedure TPanel.DrawShadowVolume(lightX: Integer; lightY: Integer; radius: Integer);
511 var
512 tx, ty, tw, th: Integer;
514 procedure extrude (x: Integer; y: Integer);
515 begin
516 glVertex2i(x+(x-lightX)*500, y+(y-lightY)*500);
517 //e_WriteLog(Format(' : (%d,%d)', [x+(x-lightX)*300, y+(y-lightY)*300]), MSG_WARNING);
518 end;
520 procedure drawLine (x0: Integer; y0: Integer; x1: Integer; y1: Integer);
521 begin
522 // does this side facing the light?
523 if ((x1-x0)*(lightY-y0)-(lightX-x0)*(y1-y0) >= 0) then exit;
524 //e_WriteLog(Format('lightpan: (%d,%d)-(%d,%d)', [x0, y0, x1, y1]), MSG_WARNING);
525 // this edge is facing the light, extrude and draw it
526 glVertex2i(x0, y0);
527 glVertex2i(x1, y1);
528 extrude(x1, y1);
529 extrude(x0, y0);
530 end;
532 begin
533 if radius < 4 then exit;
534 if Enabled and (FCurTexture >= 0) and (Width > 0) and (Height > 0) and (FAlpha < 255) {and
535 g_Collide(X, Y, tw, th, sX, sY, sWidth, sHeight)} then
536 begin
537 lerp(gLerpFactor, tx, ty, tw, th);
538 if not FTextureIDs[FCurTexture].Anim then
539 begin
540 case FTextureIDs[FCurTexture].Tex of
541 LongWord(TEXTURE_SPECIAL_WATER): exit;
542 LongWord(TEXTURE_SPECIAL_ACID1): exit;
543 LongWord(TEXTURE_SPECIAL_ACID2): exit;
544 LongWord(TEXTURE_NONE): exit;
545 end;
546 end;
547 if (tx+tw < lightX-radius) then exit;
548 if (ty+th < lightY-radius) then exit;
549 if (tx > lightX+radius) then exit;
550 if (ty > lightY+radius) then exit;
551 //e_DrawFill(FTextureIDs[FCurTexture].Tex, X, Y, tw div FTextureWidth, th div FTextureHeight, FAlpha, True, FBlending);
553 glBegin(GL_QUADS);
554 drawLine(tx, ty, tx+tw, ty); // top
555 drawLine(tx+tw, ty, tx+tw, ty+th); // right
556 drawLine(tx+tw, ty+th, tx, ty+th); // bottom
557 drawLine(tx, ty+th, tx, ty); // left
558 glEnd();
559 end;
560 end;
563 procedure TPanel.positionChanged (); inline;
564 var
565 px, py, pw, ph: Integer;
566 begin
567 if (proxyId >= 0) then
568 begin
569 mapGrid.getBodyDims(proxyId, px, py, pw, ph);
570 if (px <> x) or (py <> y) or (pw <> Width) or (ph <> Height) then
571 begin
573 e_LogWritefln('panel moved: arridx=%s; guid=%s; proxyid=%s; old:(%s,%s)-(%sx%s); new:(%s,%s)-(%sx%s)',
574 [arrIdx, mGUID, proxyId, px, py, pw, ph, x, y, width, height]);
576 g_Mark(px, py, pw, ph, MARK_WALL, false);
577 if (Width < 1) or (Height < 1) then
578 begin
579 mapGrid.proxyEnabled[proxyId] := false;
580 end
581 else
582 begin
583 mapGrid.proxyEnabled[proxyId] := Enabled;
584 if (pw <> Width) or (ph <> Height) then
585 begin
586 //writeln('panel resize!');
587 mapGrid.moveResizeBody(proxyId, X, Y, Width, Height)
588 end
589 else
590 begin
591 mapGrid.moveBody(proxyId, X, Y);
592 end;
593 g_Mark(X, Y, Width, Height, MARK_WALL);
594 end;
595 end;
596 end;
597 end;
600 var
601 monCheckList: array of TMonster = nil;
602 monCheckListUsed: Integer = 0;
604 procedure TPanel.Update();
605 var
606 ox, oy: Integer;
607 nx, ny, nw, nh: Integer;
608 ex, ey, nex, ney: Integer;
609 mpw, mph: Integer;
610 conveyor: Boolean;
612 // return `true` if we should move by dx,dy
613 function tryMPlatMove (px, py, pw, ph: Integer; out dx, dy: Integer; out squash: Boolean; ontop: PBoolean=nil): Boolean;
614 var
615 u0: Single;
616 tex, tey: Integer;
617 pdx, pdy: Integer;
618 trtag: Integer;
619 szdx, szdy: Integer;
620 begin
621 squash := false;
622 tex := px;
623 tey := py;
624 pdx := mMovingSpeed.X;
625 pdy := mMovingSpeed.Y;
626 // standing on the platform?
627 if (py+ph = oy) then
628 begin
629 if (ontop <> nil) then ontop^ := true;
630 // yes, move with it; but skip steps (no need to process size change here, 'cause platform top cannot be changed with it)
631 mapGrid.traceBox(tex, tey, px, py, pw, ph, pdx, pdy, (GridTagWall or GridTagDoor));
632 end
633 else
634 begin
635 if (ontop <> nil) then ontop^ := false;
636 // not standing on the platform: trace platform to see if it hits the entity
637 // first, process size change (as we cannot sweeptest both move and size change)
638 // but we don't have to check for pushing if the panel is shrinking
639 szdx := nw-mpw;
640 szdy := nh-mph;
641 if (szdx > 0) or (szdy > 0) then
642 begin
643 // ignore shrinking dimension
644 if (szdx < 0) then szdx := 0;
645 if (szdy < 0) then szdy := 0;
646 // move platform by szd* back, and check for szd* movement
647 if sweepAABB(ox-szdx, oy-szdy, nw, nh, szdx, szdy, px, py, pw, ph, @u0) then
648 begin
649 // yes, platform hits the entity, push the entity in the resizing direction
650 u0 := 1.0-u0; // how much path left?
651 szdx := trunc(szdx*u0);
652 szdy := trunc(szdy*u0);
653 if (szdx <> 0) or (szdy <> 0) then
654 begin
655 // has some path to go, trace the entity
656 trtag := (GridTagWall or GridTagDoor);
657 // if we're moving down, consider steps too
658 if (szdy > 0) then trtag := trtag or GridTagStep;
659 mapGrid.traceBox(tex, tey, px, py, pw, ph, szdx, szdy, trtag);
660 end;
661 end;
662 end;
663 // second, process platform movement, using te* as entity starting point
664 if sweepAABB(ox, oy, nw, nh, pdx, pdy, tex, tey, pw, ph, @u0) then
665 begin
666 //e_LogWritefln('T: platsweep; u0=%s; u1=%s; hedge=%s; sweepAABB(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)', [u0, u1, hedge, ox, oy, mpw, mph, pdx, pdy, px-1, py-1, pw+2, ph+2]);
667 // yes, platform hits the entity, push the entity in the direction of the platform
668 u0 := 1.0-u0; // how much path left?
669 pdx := trunc(pdx*u0);
670 pdy := trunc(pdy*u0);
671 //e_LogWritefln(' platsweep; uleft=%s; pd=(%s,%s)', [u0, pdx, pdy]);
672 if (pdx <> 0) or (pdy <> 0) then
673 begin
674 // has some path to go, trace the entity
675 trtag := (GridTagWall or GridTagDoor);
676 // if we're moving down, consider steps too
677 if (pdy > 0) then trtag := trtag or GridTagStep;
678 mapGrid.traceBox(tex, tey, px, py, pw, ph, pdx, pdy, trtag);
679 end;
680 end;
681 end;
682 // done with entity movement, new coords are in te*
683 dx := tex-px;
684 dy := tey-py;
685 result := (dx <> 0) or (dy <> 0);
686 if not conveyor and ((tag and (GridTagWall or GridTagDoor)) <> 0) then
687 begin
688 // check for squashing; as entity cannot be pushed into a wall, check only collision with the platform itself
689 squash := g_Collide(tex, tey, pw, ph, nx, ny, nw, nh); // squash, if still in platform
690 end;
691 end;
693 function monCollect (mon: TMonster): Boolean;
694 begin
695 result := false; // don't stop
696 if (monCheckListUsed >= Length(monCheckList)) then SetLength(monCheckList, monCheckListUsed+128);
697 monCheckList[monCheckListUsed] := mon;
698 Inc(monCheckListUsed);
699 end;
701 var
702 cx0, cy0, cx1, cy1, cw, ch: Integer;
703 f: Integer;
704 px, py, pw, ph, pdx, pdy: Integer;
705 squash: Boolean;
706 plr: TPlayer;
707 gib: PGib;
708 cor: TCorpse;
709 mon: TMonster;
710 mpfrid: LongWord;
711 ontop: Boolean;
712 actMoveTrig: Boolean;
713 actSizeTrig: Boolean;
714 begin
715 if (not Enabled) or (Width < 1) or (Height < 1) then exit;
717 if (FCurTexture >= 0) and
718 (FTextureIDs[FCurTexture].Anim) and
719 (FTextureIDs[FCurTexture].AnTex <> nil) and
720 (FAlpha < 255) then
721 begin
722 FTextureIDs[FCurTexture].AnTex.Update();
723 FCurFrame := FTextureIDs[FCurTexture].AnTex.CurrentFrame;
724 FCurFrameCount := FTextureIDs[FCurTexture].AnTex.CurrentCounter;
725 end;
727 if not g_dbgpan_mplat_active then exit;
729 if (mOldMovingActive <> mMovingActive) then mNeedSend := true;
730 mOldMovingActive := mMovingActive;
732 if not mMovingActive then exit;
733 if mMovingSpeed.isZero and mSizeSpeed.isZero then exit;
735 //TODO: write wall size change processing
737 // moving platform?
738 begin
739 (*
740 * collect all monsters and players (aka entities) along the possible platform path
741 * if entity is standing on a platform:
742 * try to move it along the platform path, checking wall collisions
743 * if entity is NOT standing on a platform, but hit with sweeped platform aabb:
744 * try to push entity
745 * if we can't push entity all the way, squash it
746 *)
747 ox := X;
748 oy := Y;
749 mpw := Width;
750 mph := Height;
752 // the mplat acts as a stationary conveyor belt when it's locked within a movement rect of zero area
753 conveyor := (mMovingEnd.X = mMovingStart.X) and (mMovingEnd.Y = mMovingStart.Y)
754 and (mMovingEnd.X = X) and (mMovingEnd.Y = Y);
756 nw := mpw+mSizeSpeed.w;
757 nh := mph+mSizeSpeed.h;
758 nx := ox;
759 ny := oy;
760 if not conveyor then
761 begin
762 nx += mMovingSpeed.X;
763 ny += mMovingSpeed.Y;
764 end;
766 // force network updates only if some sudden change happened
767 // set the flag here, so we can sync affected monsters
768 if not mSizeSpeed.isZero and (nw = mSizeEnd.w) and (nh = mSizeEnd.h) then
769 begin
770 mNeedSend := true;
771 end
772 else if ((mMovingSpeed.X < 0) and (nx <= mMovingStart.X)) or ((mMovingSpeed.X > 0) and (nx >= mMovingEnd.X)) then
773 begin
774 mNeedSend := true;
775 end
776 else if ((mMovingSpeed.Y < 0) and (ny <= mMovingStart.Y)) or ((mMovingSpeed.Y > 0) and (ny >= mMovingEnd.Y)) then
777 begin
778 mNeedSend := true;
779 end;
781 // if pannel disappeared, we don't have to do anything
782 if (nw > 0) and (nh > 0) then
783 begin
784 // old rect
785 ex := ox+mpw-1;
786 ey := ox+mph-1;
787 // new rect
788 nex := nx+nw-1;
789 ney := ny+nh-1;
790 // full rect
791 cx0 := nmin(ox, nx);
792 cy0 := nmin(oy, ny);
793 cx1 := nmax(ex, nex);
794 cy1 := nmax(ey, ney);
795 // extrude
796 cx0 -= 1;
797 cy0 -= 1;
798 cx1 += 1;
799 cy1 += 1;
800 cw := cx1-cx0+1;
801 ch := cy1-cy0+1;
803 // process "obstacle" panels
804 if ((tag and GridTagObstacle) <> 0) then
805 begin
806 // temporarily turn off this panel, so it won't interfere with collision checks
807 mapGrid.proxyEnabled[proxyId] := false;
809 // process players
810 for f := 0 to High(gPlayers) do
811 begin
812 plr := gPlayers[f];
813 if (plr = nil) or (not plr.alive) then continue;
814 plr.getMapBox(px, py, pw, ph);
815 if not g_Collide(px, py, pw, ph, cx0, cy0, cw, ch) then continue;
816 if tryMPlatMove(px, py, pw, ph, pdx, pdy, squash) then
817 begin
818 // set new position
819 plr.moveBy(pdx, pdy); // this will call `positionChanged()` for us
820 end;
821 // squash player, if necessary
822 if not g_Game_IsClient and squash then plr.Damage(15000, 0, 0, 0, HIT_TRAP);
823 end;
825 // process gibs
826 for f := 0 to High(gGibs) do
827 begin
828 gib := @gGibs[f];
829 if not gib.alive then continue;
830 gib.getMapBox(px, py, pw, ph);
831 if not g_Collide(px, py, pw, ph, cx0, cy0, cw, ch) then continue;
832 if tryMPlatMove(px, py, pw, ph, pdx, pdy, squash, @ontop) then
833 begin
834 // set new position
835 gib.moveBy(pdx, pdy); // this will call `positionChanged()` for us
836 end;
837 end;
839 // move and push corpses
840 for f := 0 to High(gCorpses) do
841 begin
842 cor := gCorpses[f];
843 if (cor = nil) then continue;
844 cor.getMapBox(px, py, pw, ph);
845 if not g_Collide(px, py, pw, ph, cx0, cy0, cw, ch) then continue;
846 if tryMPlatMove(px, py, pw, ph, pdx, pdy, squash, @ontop) then
847 begin
848 // set new position
849 cor.moveBy(pdx, pdy); // this will call `positionChanged()` for us
850 end;
851 end;
853 // collect monsters
854 monCheckListUsed := 0;
855 g_Mons_ForEachAt(cx0, cy0, cw, ch, monCollect);
857 // process collected monsters
858 if (monCheckListUsed > 0) then
859 begin
860 mpfrid := g_Mons_getNewMPlatFrameId();
861 for f := 0 to monCheckListUsed do
862 begin
863 mon := monCheckList[f];
864 if (mon = nil) or (not mon.alive) or (mon.mplatCheckFrameId = mpfrid) then continue;
865 mon.mplatCheckFrameId := mpfrid;
866 mon.getMapBox(px, py, pw, ph);
867 //if not g_Collide(px, py, pw, ph, cx0, cy0, cw, ch) then continue;
868 if tryMPlatMove(px, py, pw, ph, pdx, pdy, squash) then
869 begin
870 // set new position
871 mon.moveBy(pdx, pdy); // this will call `positionChanged()` for us
872 //???FIXME: do we really need to send monsters over the net?
873 // i don't think so, as dead reckoning should take care of 'em
874 // ok, send new monster position only if platform is going to change it's direction
875 if mNeedSend then mon.setDirty();
876 end;
877 // squash monster, if necessary
878 if not g_Game_IsClient and squash then mon.Damage(15000, 0, 0, 0, HIT_TRAP);
879 end;
880 end;
882 // restore panel state
883 mapGrid.proxyEnabled[proxyId] := true;
884 end;
885 end;
887 // move panel
888 FOldX := X;
889 FOldY := Y;
890 X := nx;
891 Y := ny;
892 FOldW := FWidth;
893 FOldH := FHeight;
894 FWidth := nw;
895 FHeight := nh;
896 positionChanged();
898 actMoveTrig := false;
899 actSizeTrig := false;
901 // `mNeedSend` was set above
903 // check "size stop"
904 if not mSizeSpeed.isZero and (nw = mSizeEnd.w) and (nh = mSizeEnd.h) then
905 begin
906 mSizeSpeed.w := 0;
907 mSizeSpeed.h := 0;
908 actSizeTrig := true;
909 if (nw < 1) or (nh < 1) then mMovingActive := false; //HACK!
910 end;
912 if not conveyor then
913 begin
914 // reverse moving direction, if necessary
915 if ((mMovingSpeed.X < 0) and (nx <= mMovingStart.X)) or ((mMovingSpeed.X > 0) and (nx >= mMovingEnd.X)) then
916 begin
917 if mMoveOnce then mMovingActive := false else mMovingSpeed.X := -mMovingSpeed.X;
918 actMoveTrig := true;
919 end;
921 if ((mMovingSpeed.Y < 0) and (ny <= mMovingStart.Y)) or ((mMovingSpeed.Y > 0) and (ny >= mMovingEnd.Y)) then
922 begin
923 if mMoveOnce then mMovingActive := false else mMovingSpeed.Y := -mMovingSpeed.Y;
924 actMoveTrig := true;
925 end;
927 if (mOldMovingActive <> mMovingActive) then mNeedSend := true;
928 mOldMovingActive := mMovingActive;
929 end;
931 if not g_Game_IsClient then
932 begin
933 if actMoveTrig then g_Triggers_Press(mEndPosTrig, ACTIVATE_CUSTOM);
934 if actSizeTrig then g_Triggers_Press(mEndSizeTrig, ACTIVATE_CUSTOM);
935 end;
937 // some triggers may activate this, don't delay sending
938 //TODO: when triggers will be able to control speed and size, check that here too
939 if (mOldMovingActive <> mMovingActive) then mNeedSend := true;
940 mOldMovingActive := mMovingActive;
941 end;
942 end;
945 procedure TPanel.SetFrame(Frame: Integer; Count: Byte);
947 function ClampInt(X, A, B: Integer): Integer;
948 begin
949 Result := X;
950 if X < A then Result := A else if X > B then Result := B;
951 end;
953 begin
954 if Enabled and (FCurTexture >= 0) and
955 (FTextureIDs[FCurTexture].Anim) and
956 (FTextureIDs[FCurTexture].AnTex <> nil) and
957 (Width > 0) and (Height > 0) and (FAlpha < 255) then
958 begin
959 FCurFrame := ClampInt(Frame, 0, FTextureIDs[FCurTexture].AnTex.TotalFrames - 1);
960 FCurFrameCount := Count;
961 FTextureIDs[FCurTexture].AnTex.CurrentFrame := FCurFrame;
962 FTextureIDs[FCurTexture].AnTex.CurrentCounter := FCurFrameCount;
963 end;
964 end;
966 procedure TPanel.NextTexture(AnimLoop: Byte = 0);
967 begin
968 Assert(FCurTexture >= -1, 'FCurTexture < -1');
970 // Íåò òåêñòóð:
971 if Length(FTextureIDs) = 0 then
972 FCurTexture := -1
973 else
974 // Òîëüêî îäíà òåêñòóðà:
975 if Length(FTextureIDs) = 1 then
976 begin
977 if FCurTexture = 0 then
978 FCurTexture := -1
979 else
980 FCurTexture := 0;
981 end
982 else
983 // Áîëüøå îäíîé òåêñòóðû:
984 begin
985 // Ñëåäóþùàÿ:
986 Inc(FCurTexture);
987 // Ñëåäóþùåé íåò - âîçâðàò ê íà÷àëó:
988 if FCurTexture >= Length(FTextureIDs) then
989 FCurTexture := 0;
990 end;
992 // Ïåðåêëþ÷èëèñü íà âèäèìóþ àíèì. òåêñòóðó:
993 if (FCurTexture >= 0) and FTextureIDs[FCurTexture].Anim then
994 begin
995 if (FTextureIDs[FCurTexture].AnTex = nil) then
996 begin
997 g_FatalError(_lc[I_GAME_ERROR_SWITCH_TEXTURE]);
998 Exit;
999 end;
1001 if AnimLoop = 1 then
1002 FTextureIDs[FCurTexture].AnTex.Loop := True
1003 else
1004 if AnimLoop = 2 then
1005 FTextureIDs[FCurTexture].AnTex.Loop := False;
1007 FTextureIDs[FCurTexture].AnTex.Reset();
1008 end;
1010 LastAnimLoop := AnimLoop;
1011 end;
1013 procedure TPanel.SetTexture(ID: Integer; AnimLoop: Byte = 0);
1014 begin
1015 if (ID >= -1) and (ID < Length(FTextureIDs)) then
1016 FCurTexture := ID;
1018 // Ïåðåêëþ÷èëèñü íà âèäèìóþ àíèì. òåêñòóðó:
1019 if (FCurTexture >= 0) and FTextureIDs[FCurTexture].Anim then
1020 begin
1021 if (FTextureIDs[FCurTexture].AnTex = nil) then
1022 begin
1023 g_FatalError(_lc[I_GAME_ERROR_SWITCH_TEXTURE]);
1024 Exit;
1025 end;
1027 if AnimLoop = 1 then
1028 FTextureIDs[FCurTexture].AnTex.Loop := True
1029 else
1030 if AnimLoop = 2 then
1031 FTextureIDs[FCurTexture].AnTex.Loop := False;
1033 FTextureIDs[FCurTexture].AnTex.Reset();
1034 end;
1036 LastAnimLoop := AnimLoop;
1037 end;
1039 function TPanel.GetTextureID(): DWORD;
1040 begin
1041 Result := LongWord(TEXTURE_NONE);
1043 if (FCurTexture >= 0) then
1044 begin
1045 if FTextureIDs[FCurTexture].Anim then
1046 Result := FTextureIDs[FCurTexture].AnTex.FramesID
1047 else
1048 Result := FTextureIDs[FCurTexture].Tex;
1049 end;
1050 end;
1052 function TPanel.GetTextureCount(): Integer;
1053 begin
1054 Result := Length(FTextureIDs);
1055 if Enabled and (FCurTexture >= 0) then
1056 if (FTextureIDs[FCurTexture].Anim) and
1057 (FTextureIDs[FCurTexture].AnTex <> nil) and
1058 (Width > 0) and (Height > 0) and (FAlpha < 255) then
1059 Result := Result + 100;
1060 end;
1062 function TPanel.CanChangeTexture(): Boolean;
1063 begin
1064 Result := (GetTextureCount() > 1) or hasTexTrigger;
1065 end;
1067 const
1068 PAN_SAVE_VERSION = 1;
1070 procedure TPanel.SaveState (st: TStream);
1071 var
1072 anim: Boolean;
1073 begin
1074 if (st = nil) then exit;
1076 // Ñèãíàòóðà ïàíåëè
1077 utils.writeSign(st, 'PANL');
1078 utils.writeInt(st, Byte(PAN_SAVE_VERSION));
1079 // Îòêðûòà/çàêðûòà, åñëè äâåðü
1080 utils.writeBool(st, FEnabled);
1081 // Íàïðàâëåíèå ëèôòà, åñëè ëèôò
1082 utils.writeInt(st, Byte(FLiftType));
1083 // Íîìåð òåêóùåé òåêñòóðû
1084 utils.writeInt(st, Integer(FCurTexture));
1085 // Êîîðäèíàòû è ðàçìåð
1086 utils.writeInt(st, Integer(FX));
1087 utils.writeInt(st, Integer(FY));
1088 utils.writeInt(st, Word(FWidth));
1089 utils.writeInt(st, Word(FHeight));
1090 // Àíèìèðîâàíà ëè òåêóùàÿ òåêñòóðà
1091 if (FCurTexture >= 0) and (FTextureIDs[FCurTexture].Anim) then
1092 begin
1093 assert(FTextureIDs[FCurTexture].AnTex <> nil, 'TPanel.SaveState: No animation object');
1094 anim := true;
1095 end
1096 else
1097 begin
1098 anim := false;
1099 end;
1100 utils.writeBool(st, anim);
1101 // Åñëè äà - ñîõðàíÿåì àíèìàöèþ
1102 if anim then FTextureIDs[FCurTexture].AnTex.SaveState(st);
1104 // moving platform state
1105 utils.writeInt(st, Integer(mMovingSpeed.X));
1106 utils.writeInt(st, Integer(mMovingSpeed.Y));
1107 utils.writeInt(st, Integer(mMovingStart.X));
1108 utils.writeInt(st, Integer(mMovingStart.Y));
1109 utils.writeInt(st, Integer(mMovingEnd.X));
1110 utils.writeInt(st, Integer(mMovingEnd.Y));
1112 utils.writeInt(st, Integer(mSizeSpeed.w));
1113 utils.writeInt(st, Integer(mSizeSpeed.h));
1114 utils.writeInt(st, Integer(mSizeEnd.w));
1115 utils.writeInt(st, Integer(mSizeEnd.h));
1117 utils.writeBool(st, mMovingActive);
1118 utils.writeBool(st, mMoveOnce);
1120 utils.writeInt(st, Integer(mEndPosTrig));
1121 utils.writeInt(st, Integer(mEndSizeTrig));
1122 end;
1125 procedure TPanel.LoadState (st: TStream);
1126 begin
1127 if (st = nil) then exit;
1129 // Ñèãíàòóðà ïàíåëè
1130 if not utils.checkSign(st, 'PANL') then raise XStreamError.create('wrong panel signature');
1131 if (utils.readByte(st) <> PAN_SAVE_VERSION) then raise XStreamError.create('wrong panel version');
1132 // Îòêðûòà/çàêðûòà, åñëè äâåðü
1133 FEnabled := utils.readBool(st);
1134 // Íàïðàâëåíèå ëèôòà, åñëè ëèôò
1135 FLiftType := utils.readByte(st);
1136 // Íîìåð òåêóùåé òåêñòóðû
1137 FCurTexture := utils.readLongInt(st);
1138 // Êîîðäèíàòû è ðàçìåð
1139 FX := utils.readLongInt(st);
1140 FY := utils.readLongInt(st);
1141 FOldX := FX;
1142 FOldY := FY;
1143 FWidth := utils.readWord(st);
1144 FHeight := utils.readWord(st);
1145 FOldW := FWidth;
1146 FOldH := FHeight;
1147 // Àíèìèðîâàííàÿ ëè òåêóùàÿ òåêñòóðà
1148 if utils.readBool(st) then
1149 begin
1150 // Åñëè äà - çàãðóæàåì àíèìàöèþ
1151 Assert((FCurTexture >= 0) and
1152 (FTextureIDs[FCurTexture].Anim) and
1153 (FTextureIDs[FCurTexture].AnTex <> nil),
1154 'TPanel.LoadState: No animation object');
1155 FTextureIDs[FCurTexture].AnTex.LoadState(st);
1156 end;
1158 // moving platform state
1159 mMovingSpeed.X := utils.readLongInt(st);
1160 mMovingSpeed.Y := utils.readLongInt(st);
1161 mMovingStart.X := utils.readLongInt(st);
1162 mMovingStart.Y := utils.readLongInt(st);
1163 mMovingEnd.X := utils.readLongInt(st);
1164 mMovingEnd.Y := utils.readLongInt(st);
1166 mSizeSpeed.w := utils.readLongInt(st);
1167 mSizeSpeed.h := utils.readLongInt(st);
1168 mSizeEnd.w := utils.readLongInt(st);
1169 mSizeEnd.h := utils.readLongInt(st);
1171 mMovingActive := utils.readBool(st);
1172 mMoveOnce := utils.readBool(st);
1174 mEndPosTrig := utils.readLongInt(st);
1175 mEndSizeTrig := utils.readLongInt(st);
1177 positionChanged();
1178 //mapGrid.proxyEnabled[proxyId] := FEnabled; // done in g_map.pas
1179 end;
1182 end.