vht/vhtzs/fn.zsc

76 lines
1.5 KiB
Plaintext
Raw Normal View History

class VhtFnBool abstract {
virtual bool vhtRun() {return false;}
}
class VhtFnBoolFuse : VhtFnBool {
bool m_result;
VhtFnBool m_fInner;
VhtFnBoolFuse vhtInit(VhtFnBool fInner) {
m_fInner = fInner;
return self;
}
override bool vhtRun() {
if(!m_result) {
m_result = m_fInner.vhtRun();
}
return m_result;
}
}
class VhtFnPlayer : VhtFnBool abstract {
int m_player;
virtual bool vhtCall(PlayerInfo p) {return false;}
override bool vhtRun() {
for(int i = 0; i < MAXPLAYERS; ++i) {
if(playerInGame[i] && vhtCall(players[i])) {
m_player = i;
return true;
}
}
return false;
}
}
class VhtFnPlayerInSector : VhtFnPlayer {
int m_idx;
VhtFnPlayer vhtInit(int idx) {
m_idx = idx;
return self;
}
override bool vhtCall(PlayerInfo p) {
return p.mo.curSector.index() == m_idx;
}
}
class VhtFnPlayerInv : VhtFnPlayer abstract {
class<Inventory> m_which;
Inventory m_result;
override bool vhtCall(PlayerInfo p) {
let inv = p.mo.findInventory(m_which);
if(inv) {
m_result = inv;
return true;
}
return false;
}
}
class VhtFnPlayerInvExist : VhtFnPlayerInv {
VhtFnPlayerInv vhtInit(class<Inventory> which) {
m_which = which;
return self;
}
}
class VhtFnPlayerInvAmount : VhtFnPlayerInv {
int m_amount;
VhtFnPlayerInv vhtInit(class<Inventory> which, int amount) {
m_which = which;
m_amount = amount;
return self;
}
override bool vhtCall(PlayerInfo p) {
return super.vhtCall(p) && m_result.amount >= m_amount;
}
}