raze/source/games/sw/src/swactor.h

67 lines
1.2 KiB
C
Raw Normal View History

#pragma once
// included by game.h
BEGIN_SW_NS
class DSWActor : public DCoreActor
{
DSWActor* base();
public:
2021-11-19 23:18:23 +00:00
bool hasUser;
USER user;
2021-11-24 19:11:50 +00:00
walltype* tempwall; // transient, to replace a hack using a 16 bit sprite field.
2021-11-19 23:18:23 +00:00
DSWActor()
{
index = (int(this - base()));
}
DSWActor& operator=(const DSWActor& other) = default;
void Clear()
{
clearUser();
}
2021-11-19 23:18:23 +00:00
bool hasU() { return hasUser; }
2021-11-19 23:18:23 +00:00
USER* u() { return &user; }
USER* allocUser()
{
2021-11-19 23:18:23 +00:00
hasUser = true;
return u();
}
2021-11-01 22:26:13 +00:00
void clearUser()
{
2021-11-19 23:18:23 +00:00
hasUser = false;
user.Clear();
2021-11-01 22:26:13 +00:00
}
};
extern DSWActor swActors[MAXSPRITES];
inline DSWActor* DSWActor::base() { return swActors; }
// subclassed to add a game specific actor() method
// Iterator wrappers that return an actor pointer, not an index.
using SWStatIterator = TStatIterator<DSWActor>;
using SWSectIterator = TSectIterator<DSWActor>;
using SWSpriteIterator = TSpriteIterator<DSWActor>;
inline FSerializer& Serialize(FSerializer& arc, const char* keyname, DSWActor*& w, DSWActor** def)
{
int index = w? int(w - swActors) : -1;
Serialize(arc, keyname, index, nullptr);
if (arc.isReading()) w = index == -1? nullptr : &swActors[index];
return arc;
}
2021-11-04 23:00:47 +00:00
END_SW_NS