move Attack out of GameState

This commit is contained in:
Glenn Maynard
2003-10-25 22:00:58 +00:00
parent cefc7f6685
commit e550d16195
15 changed files with 118 additions and 79 deletions
+18
View File
@@ -0,0 +1,18 @@
#include "global.h"
#include "Attack.h"
#include "GameState.h"
#include "song.h"
void Attack::GetAttackBeats( const Song *song, PlayerNumber pn, float &fStartBeat, float &fEndBeat ) const
{
if( fStartSecond >= 0 )
{
fStartBeat = song->GetBeatFromElapsedTime( fStartSecond );
fEndBeat = song->GetBeatFromElapsedTime( fStartSecond+fSecsRemaining );
} else {
/* We're setting this effect on the fly. If it's an arrow-changing effect
* (transform or note skin), apply it in the future, past what's currently on
* screen, so new arrows will scroll on screen with this effect. */
GAMESTATE->GetUndisplayedBeats( pn, fSecsRemaining, fStartBeat, fEndBeat );
}
}
+22
View File
@@ -0,0 +1,22 @@
#ifndef ATTACK_H
#define ATTACK_H
#include "GameConstantsAndTypes.h"
#include "PlayerNumber.h"
class Song;
struct Attack
{
AttackLevel level;
float fStartSecond; // -1 = now
float fSecsRemaining;
CString sModifier;
void GetAttackBeats( const Song *song, PlayerNumber pn, float &fStartBeat, float &fEndBeat ) const;
bool IsBlank() { return sModifier.empty(); }
void MakeBlank() { sModifier=""; }
Attack() { fStartSecond = -1; }
};
typedef vector<Attack> AttackArray;
#endif
+3 -3
View File
@@ -141,7 +141,7 @@ void CombinedLifeMeterEnemy::Update( float fDelta )
if( CROSSED_SONG_SECONDS(20) || CROSSED_SONG_SECONDS(40) )
{
GameState::Attack a;
Attack a;
a.fSecsRemaining = 10;
a.level = ATTACK_LEVEL_1;
a.sModifier = sPossibleModifiers[a.level][rand()%3];
@@ -153,7 +153,7 @@ void CombinedLifeMeterEnemy::Update( float fDelta )
}
if( CROSSED_SONG_SECONDS(60) || CROSSED_SONG_SECONDS(80) )
{
GameState::Attack a;
Attack a;
a.fSecsRemaining = 10;
a.level = ATTACK_LEVEL_2;
a.sModifier = sPossibleModifiers[a.level][rand()%3];
@@ -165,7 +165,7 @@ void CombinedLifeMeterEnemy::Update( float fDelta )
}
if( CROSSED_SONG_SECONDS(100) )
{
GameState::Attack a;
Attack a;
a.fSecsRemaining = 10;
a.level = ATTACK_LEVEL_3;
a.sModifier = sPossibleModifiers[a.level][rand()%3];
-14
View File
@@ -676,20 +676,6 @@ void GameState::LaunchAttack( PlayerNumber target, Attack a )
a.sModifier.c_str(), target );
}
void GameState::Attack::GetAttackBeats( const Song *song, PlayerNumber pn, float &fStartBeat, float &fEndBeat ) const
{
if( fStartSecond >= 0 )
{
fStartBeat = song->GetBeatFromElapsedTime( fStartSecond );
fEndBeat = song->GetBeatFromElapsedTime( fStartSecond+fSecsRemaining );
} else {
/* We're setting this effect on the fly. If it's an arrow-changing effect
* (transform or note skin), apply it in the future, past what's currently on
* screen, so new arrows will scroll on screen with this effect. */
GAMESTATE->GetUndisplayedBeats( pn, fSecsRemaining, fStartBeat, fEndBeat );
}
}
void GameState::RemoveActiveAttacksForPlayer( PlayerNumber pn, AttackLevel al )
{
for( int s=0; s<MAX_SIMULTANEOUS_ATTACKS; s++ )
+1 -13
View File
@@ -18,6 +18,7 @@
#include "Style.h"
#include "Grade.h"
#include "StageStats.h"
#include "Attack.h"
#include <map>
@@ -168,19 +169,6 @@ public:
StageStats m_CurStageStats; // current stage (not necessarily passed if Extra Stage)
// used in PLAY_MODE_BATTLE and PLAY_MODE_RAVE
struct Attack
{
AttackLevel level;
float fStartSecond; // -1 = now
float fSecsRemaining;
CString sModifier;
void GetAttackBeats( const Song *song, PlayerNumber pn, float &fStartBeat, float &fEndBeat ) const;
bool IsBlank() { return sModifier.empty(); }
void MakeBlank() { sModifier=""; }
Attack() { fStartSecond = -1; }
};
typedef vector<GameState::Attack> AttackArray;
enum { MAX_SIMULTANEOUS_ATTACKS=16 };
Attack m_ActiveAttacks[NUM_PLAYERS][MAX_SIMULTANEOUS_ATTACKS];
+4 -4
View File
@@ -160,7 +160,7 @@ void Inventory::AwardItem( int iItemIndex )
// search for the first open slot
int iOpenSlot = -1;
GameState::Attack* asInventory = GAMESTATE->m_Inventory[m_PlayerNumber]; //[NUM_INVENTORY_SLOTS]
Attack* asInventory = GAMESTATE->m_Inventory[m_PlayerNumber]; //[NUM_INVENTORY_SLOTS]
if( asInventory[NUM_INVENTORY_SLOTS/2].IsBlank() )
iOpenSlot = NUM_INVENTORY_SLOTS/2;
@@ -176,7 +176,7 @@ void Inventory::AwardItem( int iItemIndex )
if( iOpenSlot != -1 )
{
GameState::Attack a;
Attack a;
a.sModifier = g_Items[iItemIndex].sModifier;
a.fSecsRemaining = ITEM_DURATION_SECONDS;
a.level = g_Items[iItemIndex].level;
@@ -188,13 +188,13 @@ void Inventory::AwardItem( int iItemIndex )
void Inventory::UseItem( int iSlot )
{
GameState::Attack* asInventory = GAMESTATE->m_Inventory[m_PlayerNumber]; //[NUM_INVENTORY_SLOTS]
Attack* asInventory = GAMESTATE->m_Inventory[m_PlayerNumber]; //[NUM_INVENTORY_SLOTS]
if( asInventory[iSlot].IsBlank() )
return;
PlayerNumber pnToAttack = OPPOSITE_PLAYER[m_PlayerNumber];
GameState::Attack a = asInventory[iSlot];
Attack a = asInventory[iSlot];
// remove the item
asInventory[iSlot].MakeBlank();
+1 -1
View File
@@ -334,7 +334,7 @@ void PlayerMinus::Update( float fDeltaTime )
// process transforms that are waiting to be applied
for( unsigned j=0; j<GAMESTATE->m_ModsToApply[m_PlayerNumber].size(); j++ )
{
const GameState::Attack &mod = GAMESTATE->m_ModsToApply[m_PlayerNumber][j];
const Attack &mod = GAMESTATE->m_ModsToApply[m_PlayerNumber][j];
PlayerOptions po;
/* Should this default to "" always? need it blank so we know if mod.sModifier
* changes the note skin. */
+1 -1
View File
@@ -53,7 +53,7 @@ void ScoreDisplayBattle::Update( float fDelta )
for( int s=0; s<NUM_INVENTORY_SLOTS; s++ )
{
GameState::Attack attack = GAMESTATE->m_Inventory[m_PlayerNumber][s];
Attack attack = GAMESTATE->m_Inventory[m_PlayerNumber][s];
CString sNewModifier = attack.sModifier;
if( sNewModifier != m_iLastSeenInventory[s] )
+2 -2
View File
@@ -25,7 +25,7 @@
#include "RageLog.h"
ScoreKeeperMAX2::ScoreKeeperMAX2( const vector<Song*>& apSongs, const vector<Steps*>& apNotes_, const vector<GameState::AttackArray> &asModifiers, PlayerNumber pn_ ):
ScoreKeeperMAX2::ScoreKeeperMAX2( const vector<Song*>& apSongs, const vector<Steps*>& apNotes_, const vector<AttackArray> &asModifiers, PlayerNumber pn_ ):
ScoreKeeper(pn_), apNotes(apNotes_)
{
//
@@ -57,7 +57,7 @@ ScoreKeeperMAX2::ScoreKeeperMAX2( const vector<Song*>& apSongs, const vector<Ste
for( unsigned j=0; j < asModifiers[i].size(); j++ )
{
const GameState::Attack &mod = asModifiers[i][j];
const Attack &mod = asModifiers[i][j];
PlayerOptions po;
po.FromString( mod.sModifier );
+1 -1
View File
@@ -39,7 +39,7 @@ class ScoreKeeperMAX2: public ScoreKeeper
int m_ComboBonusFactor[NUM_TAP_NOTE_SCORES];
public:
ScoreKeeperMAX2( const vector<Song*>& apSongs, const vector<Steps*>& apNotes, const vector<GameState::AttackArray> &asModifiers, PlayerNumber pn);
ScoreKeeperMAX2( const vector<Song*>& apSongs, const vector<Steps*>& apNotes, const vector<AttackArray> &asModifiers, PlayerNumber pn);
// before a song plays (called multiple times if course)
void OnNextSong( int iSongInCourseIndex, const Steps* pNotes, const NoteData* pNoteData );
+1 -1
View File
@@ -93,7 +93,7 @@ void ScoreKeeperRave::LaunchAttack( AttackLevel al )
PlayerNumber pnToAttack = OPPOSITE_PLAYER[m_PlayerNumber];
GameState::Attack a;
Attack a;
a.level = al;
a.fSecsRemaining = ATTACK_DURATION_SECONDS;
a.sModifier = sAttackToGive;
+4 -4
View File
@@ -81,9 +81,9 @@ const ScreenMessage SM_GoToScreenAfterFail = ScreenMessage(SM_User+31);
const ScreenMessage SM_StartHereWeGo = ScreenMessage(SM_User+40);
const ScreenMessage SM_StopHereWeGo = ScreenMessage(SM_User+41);
void GetCourseAttackArray( const Course::Info &ci, GameState::AttackArray &out )
void GetCourseAttackArray( const Course::Info &ci, AttackArray &out )
{
GameState::Attack a;
Attack a;
a.fStartSecond = 0;
a.fSecsRemaining = 10000; /* whole song */
a.level = ATTACK_LEVEL_1;
@@ -169,7 +169,7 @@ ScreenGameplay::ScreenGameplay( CString sName, bool bDemonstration ) : Screen("S
for( unsigned c=0; c<ci.size(); ++c )
{
m_apNotesQueue[p].push_back( ci[c].pNotes );
GameState::AttackArray a;
AttackArray a;
GetCourseAttackArray( ci[c], a );
m_asModifiersQueue[p].push_back( a );
}
@@ -184,7 +184,7 @@ ScreenGameplay::ScreenGameplay( CString sName, bool bDemonstration ) : Screen("S
for( int p=0; p<NUM_PLAYERS; p++ )
{
m_apNotesQueue[p].push_back( GAMESTATE->m_pCurNotes[p] );
m_asModifiersQueue[p].push_back( GameState::AttackArray() );
m_asModifiersQueue[p].push_back( AttackArray() );
}
}
+2 -2
View File
@@ -28,7 +28,7 @@ class Inventory;
#include "LyricDisplay.h"
#include "TimingAssist.h"
#include "Character.h"
#include "GameState.h"
#include "Attack.h"
// messages sent by Combo
const ScreenMessage SM_PlayToasty = ScreenMessage(SM_User+104);
@@ -92,7 +92,7 @@ protected:
} m_DancingState;
vector<Song*> m_apSongsQueue; // size may be >1 if playing a course
vector<Steps*> m_apNotesQueue[NUM_PLAYERS]; // size may be >1 if playing a course
vector<GameState::AttackArray> m_asModifiersQueue[NUM_PLAYERS];// size may be >1 if playing a course
vector<AttackArray> m_asModifiersQueue[NUM_PLAYERS];// size may be >1 if playing a course
bool m_bChangedOffsetOrBPM;
float m_fTimeLeftBeforeDancingComment; // this counter is only running while STATE_DANCING
+52 -33
View File
@@ -65,8 +65,8 @@ IntDir=.\../Debug6
TargetDir=\temp\stepmania
TargetName=StepMania-debug
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \
/Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \
/Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -83,24 +83,24 @@ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
XBCP=xbecopy.exe
# ADD BASE XBCP /NOLOGO
# ADD XBCP /NOLOGO
XBE=imagebld.exe
# ADD BASE XBE /nologo /stack:0x10000 /debug
# ADD XBE /nologo /stack:0x10000 /debug /out:"../default.xbe"
LINK32=link.exe
# ADD BASE LINK32 xapilibd.lib d3d8d.lib d3dx8d.lib xgraphicsd.lib dsoundd.lib dmusicd.lib xnetd.lib xboxkrnl.lib /nologo /incremental:no /debug /machine:I386 /subsystem:xbox /fixed:no /TMP
# ADD LINK32 xapilibd.lib d3d8d.lib d3dx8d.lib xgraphicsd.lib dsoundd.lib dmusicd.lib xnetd.lib xboxkrnl.lib /nologo /incremental:no /debug /machine:I386 /nodefaultlib:"libcd" /nodefaultlib:"libcmt" /out:"../StepManiaXbox-debug.exe" /subsystem:xbox /fixed:no /TMP
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_XBOX" /D "_DEBUG" /YX /FD /G6 /Ztmp /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /I "SDL_sound-1.0.0" /D "WIN32" /D "_XBOX" /D "_DEBUG" /D "OGG_ONLY" /YX /FD /G6 /Ztmp /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 xapilibd.lib d3d8d.lib d3dx8d.lib xgraphicsd.lib dsoundd.lib dmusicd.lib xnetd.lib xboxkrnl.lib /nologo /incremental:no /debug /machine:I386 /subsystem:xbox /fixed:no /TMP
# ADD LINK32 xapilibd.lib d3d8d.lib d3dx8d.lib xgraphicsd.lib dsoundd.lib dmusicd.lib xnetd.lib xboxkrnl.lib /nologo /incremental:no /debug /machine:I386 /nodefaultlib:"libcd" /nodefaultlib:"libcmt" /out:"../StepManiaXbox-debug.exe" /subsystem:xbox /fixed:no /TMP
XBE=imagebld.exe
# ADD BASE XBE /nologo /stack:0x10000 /debug
# ADD XBE /nologo /stack:0x10000 /debug /out:"../default.xbe"
XBCP=xbecopy.exe
# ADD BASE XBCP /NOLOGO
# ADD XBCP /NOLOGO
# Begin Special Build Tool
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \
/Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \
/Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool
@@ -140,8 +140,8 @@ IntDir=.\../Release6
TargetDir=\temp\stepmania
TargetName=StepMania
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \
/Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \
/Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -159,27 +159,27 @@ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania
# PROP Intermediate_Dir "StepMania___Xbox_Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
XBCP=xbecopy.exe
# ADD BASE XBCP /NOLOGO
# ADD XBCP /NOLOGO
XBE=imagebld.exe
# ADD BASE XBE /nologo /stack:0x10000 /debug
# ADD XBE /nologo /testid:"123456" /stack:0x10000 /debug /out:"../default.xbe"
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /D "WIN32" /D "_XBOX" /D "_DEBUG" /Fr /YX"global.h" /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /I "SDL_sound-1.0.0" /D "WIN32" /D "_XBOX" /D "NDEBUG" /YX"global.h" /FD /c
# SUBTRACT CPP /Fr
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 $(intdir)\verstub.obj xapilibd.lib d3d8d.lib d3dx8d.lib xgraphicsd.lib dsoundd.lib dmusicd.lib xnetd.lib xboxkrnl.lib /nologo /pdb:"../debug6/StepMania-debug.pdb" /map /debug /machine:IX86 /nodefaultlib:"libcmtd.lib" /out:"../StepMania-debug.exe"
# SUBTRACT BASE LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib
# ADD LINK32 $(intdir)\verstub.obj xapilib.lib d3d8.lib d3dx8.lib xgraphics.lib dsound.lib dmusic.lib xnet.lib xboxkrnl.lib libcmt.lib /nologo /incremental:no /pdb:"../release6xbox/StepMania.pdb" /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"libcmtd" /out:"../StepManiaXbox.exe" /subsystem:xbox /fixed:no /TMP /OPT:REF
# SUBTRACT LINK32 /pdb:none /map /debug
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /D "WIN32" /D "_XBOX" /D "_DEBUG" /Fr /YX"global.h" /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /I "SDL_sound-1.0.0" /D "WIN32" /D "_XBOX" /D "NDEBUG" /YX"global.h" /FD /c
# SUBTRACT CPP /Fr
XBE=imagebld.exe
# ADD BASE XBE /nologo /stack:0x10000 /debug
# ADD XBE /nologo /testid:"123456" /stack:0x10000 /debug /out:"../default.xbe"
XBCP=xbecopy.exe
# ADD BASE XBCP /NOLOGO
# ADD XBCP /NOLOGO
# Begin Special Build Tool
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \
/Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \
/Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool
@@ -939,6 +939,25 @@ SOURCE=.\ArrowBackdrop.h
# End Source File
# Begin Source File
SOURCE=.\Attack.cpp
!IF "$(CFG)" == "StepMania - Win32 Debug"
!ELSEIF "$(CFG)" == "StepMania - Xbox Debug"
!ELSEIF "$(CFG)" == "StepMania - Win32 Release"
!ELSEIF "$(CFG)" == "StepMania - Xbox Release"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\Attack.h
# End Source File
# Begin Source File
SOURCE=.\BannerCache.cpp
!IF "$(CFG)" == "StepMania - Win32 Debug"
+6
View File
@@ -512,6 +512,12 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<Filter
Name="Data Structures"
Filter="">
<File
RelativePath="Attack.cpp">
</File>
<File
RelativePath="Attack.h">
</File>
<File
RelativePath="BannerCache.cpp">
</File>