Added support for client-side VisualThinkers

This commit is contained in:
Boondorl 2025-07-08 14:19:29 -04:00 committed by Ricardo Luís Vaz Silva
commit ca98f33f42
5 changed files with 11 additions and 10 deletions

View file

@ -2714,7 +2714,7 @@ void Net_DoCommand(int cmd, uint8_t **stream, int player)
if (typeinfo && typeinfo->IsDescendantOf("VisualThinker"))
{
DVector3 spawnpos = source->Vec3Angle(source->radius * 4, source->Angles.Yaw, 8.);
auto vt = DVisualThinker::NewVisualThinker(source->Level, typeinfo);
auto vt = DVisualThinker::NewVisualThinker(source->Level, typeinfo, false);
if (vt)
{
vt->PT.Pos = spawnpos;

View file

@ -1033,7 +1033,7 @@ DVisualThinker* DVisualThinker::GetNext() const
return _next;
}
DVisualThinker* DVisualThinker::NewVisualThinker(FLevelLocals* Level, PClass* type)
DVisualThinker* DVisualThinker::NewVisualThinker(FLevelLocals* Level, PClass* type, bool clientSide)
{
if (type == nullptr)
{
@ -1050,7 +1050,7 @@ DVisualThinker* DVisualThinker::NewVisualThinker(FLevelLocals* Level, PClass* ty
return nullptr;
}
auto zs = static_cast<DVisualThinker*>(Level->CreateThinker(type, DVisualThinker::DEFAULT_STAT));
auto zs = static_cast<DVisualThinker*>(clientSide ? Level->CreateClientsideThinker(type, DVisualThinker::DEFAULT_STAT) : Level->CreateThinker(type, DVisualThinker::DEFAULT_STAT));
zs->Construct();
IFOVERRIDENVIRTUALPTRNAME(zs, NAME_VisualThinker, BeginPlay)
@ -1065,9 +1065,9 @@ DVisualThinker* DVisualThinker::NewVisualThinker(FLevelLocals* Level, PClass* ty
return zs;
}
static DVisualThinker* SpawnVisualThinker(FLevelLocals* Level, PClass* type)
static DVisualThinker* SpawnVisualThinker(FLevelLocals* Level, PClass* type, bool clientSide)
{
return DVisualThinker::NewVisualThinker(Level, type);
return DVisualThinker::NewVisualThinker(Level, type, clientSide);
}
void DVisualThinker::UpdateSector(subsector_t * newSubsector)
@ -1101,7 +1101,8 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, SpawnVisualThinker, SpawnVisualThink
{
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
PARAM_CLASS_NOT_NULL(type, DVisualThinker);
DVisualThinker* zs = SpawnVisualThinker(self, type);
PARAM_BOOL(clientSide);
DVisualThinker* zs = SpawnVisualThinker(self, type, clientSide);
ACTION_RETURN_OBJECT(zs);
}

View file

@ -55,7 +55,7 @@ public:
void OnDestroy() override;
DVisualThinker* GetNext() const;
static DVisualThinker* NewVisualThinker(FLevelLocals* Level, PClass* type);
static DVisualThinker* NewVisualThinker(FLevelLocals* Level, PClass* type, bool clientSide);
void SetTranslation(FName trname);
int GetRenderStyle() const;
bool isFrozen();

View file

@ -624,7 +624,7 @@ struct LevelLocals native
native String GetEpisodeName();
native void SpawnParticle(FSpawnParticleParams p);
native VisualThinker SpawnVisualThinker(Class<VisualThinker> type);
native VisualThinker SpawnVisualThinker(Class<VisualThinker> type, bool clientSide = false);
clearscope native static bool WorldPaused();
}

View file

@ -37,11 +37,11 @@ Class VisualThinker : Thinker native
native protected void UpdateSpriteInfo(); // needs to be called every time the texture is updated if the thinker uses SPF_LOCAL_ANIM and is set to a non-ticking statnum (or if Tick is overriden and doesn't call Super.Tick())
static VisualThinker Spawn(Class<VisualThinker> type, TextureID tex, Vector3 pos, Vector3 vel = (0,0,0), double alpha = 1.0, int flags = 0,
double roll = 0.0, Vector2 scale = (1,1), Vector2 offset = (0,0), int style = STYLE_Normal, TranslationID trans = 0, int VisualThinkerFlags = 0)
double roll = 0.0, Vector2 scale = (1,1), Vector2 offset = (0,0), int style = STYLE_Normal, TranslationID trans = 0, int VisualThinkerFlags = 0, bool clientSide = false)
{
if (!Level) return null;
let p = level.SpawnVisualThinker(type);
let p = level.SpawnVisualThinker(type, clientSide);
if (p)
{
p.Texture = tex;