Skip to content

Instantly share code, notes, and snippets.

@PcChip
Created February 13, 2020 02:57
Show Gist options
  • Save PcChip/c7e43c424595ee3c395d13818b3ae367 to your computer and use it in GitHub Desktop.
Save PcChip/c7e43c424595ee3c395d13818b3ae367 to your computer and use it in GitHub Desktop.
Derived class - question for EnTT component
class Weapon
{
public:
glm::vec3 currentFiringLocation; //updated every frame with new barrel exit location
float cooldownRemaining = 0.0f; //updated every tick to see when it can fire again
bool fixed = false; //fixed weapon, or turret?
virtual void fire(int targetGlobalID) = 0;
//the parameter below is because this weapon needs to know its owner's world location to draw the laser sprite
virtual void update(double dt, entityInstanceData& parent) = 0;
private:
glm::mat4 defaultRootPose; //orientation it should have on load by default
glm::vec3 defaultFiringLocation; //location of the barrel in the base/bind pose
};
class LaserWeapon :private Weapon
{
public:
float damagePerTick = 0.0f; //how much damage does it apply to target per tick?
float burstLength = 0.0f; //in seconds
float totalDamage = 0.0f; //total damage if the burst is fully applied
virtual void fire(int targetGlobalID);
virtual void update(double dt, entityInstanceData& parent);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment