mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 21:11:39 +00:00
- consolidated the sector action classes.
This can be done with a lot less overhead by using one of the object's properties to store the activation flag, so that all the nearly redundant trigger methods can be folded into one.
This commit is contained in:
parent
85a84b5e94
commit
cf39af0642
4 changed files with 80 additions and 220 deletions
|
@ -108,10 +108,12 @@ bool ASectorAction::TriggerAction(AActor *triggerer, int activationType)
|
|||
|
||||
bool ASectorAction::DoTriggerAction (AActor *triggerer, int activationType)
|
||||
{
|
||||
bool didit = (activationType & health) ? CheckTrigger(triggerer) : false;
|
||||
|
||||
if (tracer != NULL)
|
||||
return barrier_cast<ASectorAction *>(tracer)->DoTriggerAction (triggerer, activationType);
|
||||
return didit | barrier_cast<ASectorAction *>(tracer)->DoTriggerAction (triggerer, activationType);
|
||||
else
|
||||
return false;
|
||||
return didit;
|
||||
}
|
||||
|
||||
bool ASectorAction::CanTrigger (AActor *triggerer) const
|
||||
|
@ -133,205 +135,3 @@ bool ASectorAction::CheckTrigger (AActor *triggerer) const
|
|||
return false;
|
||||
}
|
||||
|
||||
// Triggered when entering sector -------------------------------------------
|
||||
|
||||
class ASecActEnter : public ASectorAction
|
||||
{
|
||||
DECLARE_CLASS (ASecActEnter, ASectorAction)
|
||||
public:
|
||||
bool DoTriggerAction (AActor *triggerer, int activationType);
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS(ASecActEnter, false, false)
|
||||
|
||||
|
||||
bool ASecActEnter::DoTriggerAction (AActor *triggerer, int activationType)
|
||||
{
|
||||
bool didit = (activationType & SECSPAC_Enter) ? CheckTrigger (triggerer) : false;
|
||||
return didit | Super::DoTriggerAction (triggerer, activationType);
|
||||
}
|
||||
|
||||
// Triggered when leaving sector --------------------------------------------
|
||||
|
||||
class ASecActExit : public ASectorAction
|
||||
{
|
||||
DECLARE_CLASS (ASecActExit, ASectorAction)
|
||||
public:
|
||||
bool DoTriggerAction (AActor *triggerer, int activationType);
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS(ASecActExit, false, false)
|
||||
|
||||
|
||||
bool ASecActExit::DoTriggerAction (AActor *triggerer, int activationType)
|
||||
{
|
||||
bool didit = (activationType & SECSPAC_Exit) ? CheckTrigger (triggerer) : false;
|
||||
return didit | Super::DoTriggerAction (triggerer, activationType);
|
||||
}
|
||||
|
||||
// Triggered when hitting sector's floor ------------------------------------
|
||||
|
||||
class ASecActHitFloor : public ASectorAction
|
||||
{
|
||||
DECLARE_CLASS (ASecActHitFloor, ASectorAction)
|
||||
public:
|
||||
bool DoTriggerAction (AActor *triggerer, int activationType);
|
||||
};
|
||||
|
||||
// Skull Tag uses 9999 for a special that is triggered whenever
|
||||
// the player is on the sector's floor. I think this is more useful.
|
||||
|
||||
IMPLEMENT_CLASS(ASecActHitFloor, false, false)
|
||||
|
||||
|
||||
bool ASecActHitFloor::DoTriggerAction (AActor *triggerer, int activationType)
|
||||
{
|
||||
bool didit = (activationType & SECSPAC_HitFloor) ? CheckTrigger (triggerer) : false;
|
||||
return didit | Super::DoTriggerAction (triggerer, activationType);
|
||||
}
|
||||
|
||||
// Triggered when hitting sector's ceiling ----------------------------------
|
||||
|
||||
class ASecActHitCeil : public ASectorAction
|
||||
{
|
||||
DECLARE_CLASS (ASecActHitCeil, ASectorAction)
|
||||
public:
|
||||
bool DoTriggerAction (AActor *triggerer, int activationType);
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS(ASecActHitCeil, false, false)
|
||||
|
||||
|
||||
bool ASecActHitCeil::DoTriggerAction (AActor *triggerer, int activationType)
|
||||
{
|
||||
bool didit = (activationType & SECSPAC_HitCeiling) ? CheckTrigger (triggerer) : false;
|
||||
return didit | Super::DoTriggerAction (triggerer, activationType);
|
||||
}
|
||||
|
||||
// Triggered when using inside sector ---------------------------------------
|
||||
|
||||
class ASecActUse : public ASectorAction
|
||||
{
|
||||
DECLARE_CLASS (ASecActUse, ASectorAction)
|
||||
public:
|
||||
ASecActUse() : ASectorAction (true) {}
|
||||
bool DoTriggerAction (AActor *triggerer, int activationType);
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS(ASecActUse, false, false)
|
||||
|
||||
|
||||
bool ASecActUse::DoTriggerAction (AActor *triggerer, int activationType)
|
||||
{
|
||||
bool didit = (activationType & SECSPAC_Use) ? CheckTrigger (triggerer) : false;
|
||||
return didit | Super::DoTriggerAction (triggerer, activationType);
|
||||
}
|
||||
|
||||
// Triggered when using a sector's wall -------------------------------------
|
||||
|
||||
class ASecActUseWall : public ASectorAction
|
||||
{
|
||||
DECLARE_CLASS (ASecActUseWall, ASectorAction)
|
||||
public:
|
||||
ASecActUseWall() : ASectorAction (true) {}
|
||||
bool DoTriggerAction (AActor *triggerer, int activationType);
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS(ASecActUseWall, false, false)
|
||||
|
||||
|
||||
bool ASecActUseWall::DoTriggerAction (AActor *triggerer, int activationType)
|
||||
{
|
||||
bool didit = (activationType & SECSPAC_UseWall) ? CheckTrigger (triggerer) : false;
|
||||
return didit | Super::DoTriggerAction (triggerer, activationType);
|
||||
}
|
||||
|
||||
// Triggered when eyes go below fake floor ----------------------------------
|
||||
|
||||
class ASecActEyesDive : public ASectorAction
|
||||
{
|
||||
DECLARE_CLASS (ASecActEyesDive, ASectorAction)
|
||||
public:
|
||||
bool DoTriggerAction (AActor *triggerer, int activationType);
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS(ASecActEyesDive, false, false)
|
||||
|
||||
|
||||
bool ASecActEyesDive::DoTriggerAction (AActor *triggerer, int activationType)
|
||||
{
|
||||
bool didit = (activationType & SECSPAC_EyesDive) ? CheckTrigger (triggerer) : false;
|
||||
return didit | Super::DoTriggerAction (triggerer, activationType);
|
||||
}
|
||||
|
||||
// Triggered when eyes go above fake floor ----------------------------------
|
||||
|
||||
class ASecActEyesSurface : public ASectorAction
|
||||
{
|
||||
DECLARE_CLASS (ASecActEyesSurface, ASectorAction)
|
||||
public:
|
||||
bool DoTriggerAction (AActor *triggerer, int activationType);
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS(ASecActEyesSurface, false, false)
|
||||
|
||||
|
||||
bool ASecActEyesSurface::DoTriggerAction (AActor *triggerer, int activationType)
|
||||
{
|
||||
bool didit = (activationType & SECSPAC_EyesSurface) ? CheckTrigger (triggerer) : false;
|
||||
return didit | Super::DoTriggerAction (triggerer, activationType);
|
||||
}
|
||||
|
||||
// Triggered when eyes go below fake floor ----------------------------------
|
||||
|
||||
class ASecActEyesBelowC : public ASectorAction
|
||||
{
|
||||
DECLARE_CLASS (ASecActEyesBelowC, ASectorAction)
|
||||
public:
|
||||
bool DoTriggerAction (AActor *triggerer, int activationType);
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS(ASecActEyesBelowC, false, false)
|
||||
|
||||
|
||||
bool ASecActEyesBelowC::DoTriggerAction (AActor *triggerer, int activationType)
|
||||
{
|
||||
bool didit = (activationType & SECSPAC_EyesBelowC) ? CheckTrigger (triggerer) : false;
|
||||
return didit | Super::DoTriggerAction (triggerer, activationType);
|
||||
}
|
||||
|
||||
// Triggered when eyes go above fake floor ----------------------------------
|
||||
|
||||
class ASecActEyesAboveC : public ASectorAction
|
||||
{
|
||||
DECLARE_CLASS (ASecActEyesAboveC, ASectorAction)
|
||||
public:
|
||||
bool DoTriggerAction (AActor *triggerer, int activationType);
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS(ASecActEyesAboveC, false, false)
|
||||
|
||||
|
||||
bool ASecActEyesAboveC::DoTriggerAction (AActor *triggerer, int activationType)
|
||||
{
|
||||
bool didit = (activationType & SECSPAC_EyesAboveC) ? CheckTrigger (triggerer) : false;
|
||||
return didit | Super::DoTriggerAction (triggerer, activationType);
|
||||
}
|
||||
|
||||
// Triggered when eyes go below fake floor ----------------------------------
|
||||
|
||||
class ASecActHitFakeFloor : public ASectorAction
|
||||
{
|
||||
DECLARE_CLASS (ASecActHitFakeFloor, ASectorAction)
|
||||
public:
|
||||
bool DoTriggerAction (AActor *triggerer, int activationType);
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS(ASecActHitFakeFloor, false, false)
|
||||
|
||||
|
||||
bool ASecActHitFakeFloor::DoTriggerAction (AActor *triggerer, int activationType)
|
||||
{
|
||||
bool didit = (activationType & SECSPAC_HitFakeFloor) ? CheckTrigger (triggerer) : false;
|
||||
return didit | Super::DoTriggerAction (triggerer, activationType);
|
||||
}
|
||||
|
|
|
@ -290,8 +290,8 @@ public:
|
|||
bool TriggerAction(AActor *triggerer, int activationType);
|
||||
bool CanTrigger (AActor *triggerer) const;
|
||||
bool IsActivatedByUse() const;
|
||||
protected:
|
||||
virtual bool DoTriggerAction(AActor *triggerer, int activationType);
|
||||
protected:
|
||||
bool CheckTrigger(AActor *triggerer) const;
|
||||
private:
|
||||
bool ActivatedByUse;
|
||||
|
|
|
@ -2483,7 +2483,7 @@ bool AMusicChanger::DoTriggerAction (AActor *triggerer, int activationType)
|
|||
triggerer->player->MUSINFOtics = 30;
|
||||
}
|
||||
}
|
||||
return Super::DoTriggerAction (triggerer, activationType);
|
||||
return tracer == nullptr? false : barrier_cast<ASectorAction *>(tracer)->DoTriggerAction(triggerer, activationType);
|
||||
}
|
||||
|
||||
void AMusicChanger::PostBeginPlay()
|
||||
|
|
|
@ -1,6 +1,22 @@
|
|||
|
||||
class SectorAction : Actor native
|
||||
{
|
||||
// this class uses health to define the activation type.
|
||||
enum EActivation
|
||||
{
|
||||
SECSPAC_Enter = 1,
|
||||
SECSPAC_Exit = 2,
|
||||
SECSPAC_HitFloor = 4,
|
||||
SECSPAC_HitCeiling = 8,
|
||||
SECSPAC_Use = 16,
|
||||
SECSPAC_UseWall = 32,
|
||||
SECSPAC_EyesDive = 64,
|
||||
SECSPAC_EyesSurface = 128,
|
||||
SECSPAC_EyesBelowC = 256,
|
||||
SECSPAC_EyesAboveC = 512,
|
||||
SECSPAC_HitFakeFloor= 1024,
|
||||
};
|
||||
|
||||
default
|
||||
{
|
||||
+NOBLOCKMAP
|
||||
|
@ -12,68 +28,112 @@ class SectorAction : Actor native
|
|||
|
||||
// Triggered when entering sector -------------------------------------------
|
||||
|
||||
class SecActEnter : SectorAction native
|
||||
class SecActEnter : SectorAction
|
||||
{
|
||||
Default
|
||||
{
|
||||
Health SECSPAC_Enter;
|
||||
}
|
||||
}
|
||||
|
||||
// Triggered when leaving sector --------------------------------------------
|
||||
|
||||
class SecActExit : SectorAction native
|
||||
class SecActExit : SectorAction
|
||||
{
|
||||
Default
|
||||
{
|
||||
Health SECSPAC_Exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Triggered when hitting sector's floor ------------------------------------
|
||||
|
||||
class SecActHitFloor : SectorAction native
|
||||
class SecActHitFloor : SectorAction
|
||||
{
|
||||
Default
|
||||
{
|
||||
Health SECSPAC_HitFloor;
|
||||
}
|
||||
}
|
||||
|
||||
// Triggered when hitting sector's ceiling ----------------------------------
|
||||
|
||||
class SecActHitCeil : SectorAction native
|
||||
class SecActHitCeil : SectorAction
|
||||
{
|
||||
Default
|
||||
{
|
||||
Health SECSPAC_HitCeiling;
|
||||
}
|
||||
}
|
||||
|
||||
// Triggered when using inside sector ---------------------------------------
|
||||
|
||||
class SecActUse : SectorAction native
|
||||
class SecActUse : SectorAction
|
||||
{
|
||||
Default
|
||||
{
|
||||
Health SECSPAC_Use;
|
||||
}
|
||||
}
|
||||
|
||||
// Triggered when using a sector's wall -------------------------------------
|
||||
|
||||
class SecActUseWall : SectorAction native
|
||||
class SecActUseWall : SectorAction
|
||||
{
|
||||
Default
|
||||
{
|
||||
Health SECSPAC_UseWall;
|
||||
}
|
||||
}
|
||||
|
||||
// Triggered when eyes go below fake floor ----------------------------------
|
||||
|
||||
class SecActEyesDive : SectorAction native
|
||||
class SecActEyesDive : SectorAction
|
||||
{
|
||||
Default
|
||||
{
|
||||
Health SECSPAC_EyesDive;
|
||||
}
|
||||
}
|
||||
|
||||
// Triggered when eyes go above fake floor ----------------------------------
|
||||
|
||||
class SecActEyesSurface : SectorAction native
|
||||
class SecActEyesSurface : SectorAction
|
||||
{
|
||||
Default
|
||||
{
|
||||
Health SECSPAC_EyesSurface;
|
||||
}
|
||||
}
|
||||
|
||||
// Triggered when eyes go below fake floor ----------------------------------
|
||||
// Triggered when eyes go below fake ceiling ----------------------------------
|
||||
|
||||
class SecActEyesBelowC : SectorAction native
|
||||
class SecActEyesBelowC : SectorAction
|
||||
{
|
||||
Default
|
||||
{
|
||||
Health SECSPAC_EyesBelowC;
|
||||
}
|
||||
}
|
||||
|
||||
// Triggered when eyes go above fake floor ----------------------------------
|
||||
// Triggered when eyes go above fake ceiling ----------------------------------
|
||||
|
||||
class SecActEyesAboveC : SectorAction native
|
||||
class SecActEyesAboveC : SectorAction
|
||||
{
|
||||
Default
|
||||
{
|
||||
Health SECSPAC_EyesAboveC;
|
||||
}
|
||||
}
|
||||
|
||||
// Triggered when eyes go below fake floor ----------------------------------
|
||||
// Triggered when hitting fake floor ----------------------------------
|
||||
|
||||
class SecActHitFakeFloor : SectorAction native
|
||||
class SecActHitFakeFloor : SectorAction
|
||||
{
|
||||
Default
|
||||
{
|
||||
Health SECSPAC_HitFakeFloor;
|
||||
}
|
||||
}
|
||||
|
||||
// Music changer ----------------------------------
|
||||
|
|
Loading…
Reference in a new issue