X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_playermodel.pas;h=7a55bf758b8b9744c5a7883c43fbcb0659d23351;hb=d52e9d7b6bcc5c1846c82c3908a4688339e736f3;hp=34dbdfdbe02be7ea1dc9a4056f684f3a3b92e5cd;hpb=6cdd36d2fb73f13be7b6ea1870a8b3b0817b37f1;p=d2df-sdl.git diff --git a/src/game/g_playermodel.pas b/src/game/g_playermodel.pas index 34dbdfd..7a55bf7 100644 --- a/src/game/g_playermodel.pas +++ b/src/game/g_playermodel.pas @@ -18,7 +18,7 @@ unit g_playermodel; interface - uses MAPDEF, g_textures, g_base, g_basic, g_weapons, utils; + uses MAPDEF, g_animations, g_base, g_basic, g_weapons, utils; const A_STAND = 0; @@ -56,17 +56,17 @@ const W_POS_NORMAL = 0; W_POS_UP = 1; W_POS_DOWN = 2; + W_POS_LAST = W_POS_DOWN; W_ACT_NORMAL = 0; W_ACT_FIRE = 1; + W_ACT_LAST = W_ACT_FIRE; FLAG_BASEPOINT: TDFPoint = (X:16; Y:43); type TWeaponPoints = Array [WP_FIRST + 1..WP_LAST, A_STAND..A_LAST, TDirection.D_LEFT..TDirection.D_RIGHT] of Array of TDFPoint; - TModelMatrix = Array [TDirection.D_LEFT..TDirection.D_RIGHT, A_STAND..A_LAST] of TAnimationState; - TModelTextures = Array [TDirection.D_LEFT..TDirection.D_RIGHT, A_STAND..A_LAST] of record Resource: String; Mask: String; @@ -87,14 +87,12 @@ type TModelSoundArray = Array of TModelSound; - TGibsArray = Array of Integer; - TPlayerModel = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF} private FDirection: TDirection; FColor: TRGB; FCurrentAnimation: Byte; - FAnimState: TAnimationState; + FAnimState: TAnimState; FCurrentWeapon: Byte; FFlag: Byte; FFireCounter: Byte; @@ -124,7 +122,7 @@ type public property Color: TRGB read FColor write FColor; - property AnimState: TAnimationState read FAnimState; + property AnimState: TAnimState read FAnimState; property CurrentAnimation: Byte read FCurrentAnimation; property CurrentWeapon: Byte read FCurrentWeapon; property Flag: Byte read FFlag; @@ -136,7 +134,6 @@ procedure g_PlayerModel_FreeData(); function g_PlayerModel_Load(FileName: String): Boolean; function g_PlayerModel_GetNames(): SSArray; function g_PlayerModel_Get(ModelName: String): TPlayerModel; -function g_PlayerModel_GetGibs (ModelID: Integer; var Gibs: TGibsArray): Boolean; function g_PlayerModel_GetIndex (ModelName: String): Integer; {$IFDEF ENABLE_GFX} @@ -166,10 +163,12 @@ procedure g_PlayerModel_LoadFake (ModelName, FileName: String); // ======================= FileName: String; Anim: TModelTextures; - GibsCount: Integer; - GibsResource:String; - GibsMask: String; - GibsOnce: Integer; + {$IFDEF ENABLE_GIBS} + GibsCount: Integer; + GibsResource:String; + GibsMask: String; + GibsOnce: Integer; + {$ENDIF} end; var @@ -462,10 +461,12 @@ begin SlopSound := Min(Max(config.ReadInt('Sound', 'slop', 0), 0), 2); - GibsCount := config.ReadInt('Gibs', 'count', 0); - GibsResource := config.ReadStr('Gibs', 'resource', 'GIBS'); - GibsMask := config.ReadStr('Gibs', 'mask', 'GIBSMASK'); - GibsOnce := config.ReadInt('Gibs', 'once', -1); + {$IFDEF ENABLE_GIBS} + GibsCount := config.ReadInt('Gibs', 'count', 0); + GibsResource := config.ReadStr('Gibs', 'resource', 'GIBS'); + GibsMask := config.ReadStr('Gibs', 'mask', 'GIBSMASK'); + GibsOnce := config.ReadInt('Gibs', 'once', -1); + {$ENDIF} ok := True; for aa := WP_FIRST + 1 to WP_LAST do @@ -598,35 +599,6 @@ begin end; end; - function g_PlayerModel_GetGibs (ModelID: Integer; var Gibs: TGibsArray): Boolean; - var i, b: Integer; c: Boolean; - begin - Gibs := nil; - Result := False; - if (PlayerModelsArray = nil) or (gGibsCount = 0) then - Exit; - - c := False; - SetLength(Gibs, gGibsCount); - for i := 0 to High(Gibs) do - begin - if c and (PlayerModelsArray[ModelID].GibsCount = 1) then - begin - SetLength(Gibs, i); - Break; - end; - - repeat - b := Random(PlayerModelsArray[ModelID].GibsCount); - until not ((PlayerModelsArray[ModelID].GibsOnce = b + 1) and c); - - Gibs[i] := b; - - c := PlayerModelsArray[ModelID].GibsOnce = b + 1; - end; - Result := True; - end; - function g_PlayerModel_GetNames(): SSArray; var i: DWORD; @@ -687,21 +659,21 @@ end; { TPlayerModel } procedure TPlayerModel.ChangeAnimation (Animation: Byte; Force: Boolean = False); - var once: Boolean; speed, count: Integer; + var loop: Boolean; speed, count: Integer; begin if not Force then if FCurrentAnimation = Animation then Exit; FCurrentAnimation := Animation; - once := FCurrentAnimation in [A_STAND, A_WALK]; + loop := FCurrentAnimation in [A_STAND, A_WALK]; speed := PlayerModelsArray[FID].ModelSpeed[FCurrentAnimation]; count := PlayerModelsArray[FID].Anim[FDirection, FCurrentAnimation].Frames; - FAnimState := TAnimationState.Create(once, speed, count); + FAnimState := TAnimState.Create(loop, speed, count); end; destructor TPlayerModel.Destroy(); begin - FAnimState.Free; + FAnimState.Invalidate; inherited; end; @@ -802,7 +774,7 @@ end; procedure TPlayerModel.Update; begin - if FAnimState <> nil then + if FAnimState.IsValid() then FAnimState.Update; if FFireCounter > 0 then Dec(FFireCounter)