Refactor body-related classes and add new interoceptor functionality

This commit is contained in:
2024-11-22 13:11:33 +11:00
parent 30da26f0e4
commit f12f0c1231
11 changed files with 350 additions and 20 deletions
+6 -5
View File
@@ -9,16 +9,17 @@ class AttentionGrabber
{
public:
AttentionGrabber(AttentionTrigger cause, Chronomenon chron)
: isNull(false)
{}
: isNull(false)
{
}
void setNull(void) { isNull = true; }
int operator!(void) { return isNull; }
public:
AttentionTrigger cause;
Chronomenon chron;
bool isNull;
AttentionTrigger cause;
Chronomenon chron;
bool isNull;
};
#endif
+17
View File
@@ -0,0 +1,17 @@
#ifndef _BODY_MAP_H
#define _BODY_MAP_H
#include <set>
#include <cstdint>
#include <body/limb.h>
class BodyMap {
public:
BodyMap() = default;
~BodyMap() = default;
std::set<uint32_t, BodyLimb> limbs;
};
#endif // _BODY_MAP_H
+64
View File
@@ -0,0 +1,64 @@
#ifndef BODY_MESSAGE_H
#define BODY_MESSAGE_H
#include <vector>
#include <cstdint>
#include <body/limb.h>
#include <body/bodyPart.h>
class BodyMessage
{
public:
BodyMessage() = default;
~BodyMessage() = default;
};
class BodySpotImpactEntry
{
public:
enum class ReportType
{
PRESSURE,
PAIN,
PLEASURE,
HEAT,
COLD
};
BodySpotImpactEntry(uint32_t _spot, ReportType _type, uint32_t _value)
: spot(_spot), type(_type), value(_value)
{}
~BodySpotImpactEntry() = default;
public:
uint32_t spot;
ReportType type;
uint32_t value;
};
class BodySpotImpactInd
: public BodyMessage
{
public:
BodySpotImpactInd(BodyPart &_part) : part(_part) {}
~BodySpotImpactInd() = default;
public:
BodyPart &part;
std::vector<BodySpotImpactEntry> entries;
};
class BodyPartMsg
: public BodyMessage
{
public:
BodyPartMsg(const BodyPart& _part)
:part(_part)
{}
public:
const BodyPart& part;
};
#endif // BODY_MESSAGE_H
+42
View File
@@ -0,0 +1,42 @@
#ifndef BODYPART_H
#define BODYPART_H
#include <cstdint>
#include <string>
#include <set>
#include <sensors/interoceptor.h>
class BodySpot
{
public:
BodySpot(uint32_t _id, std::string _description)
: id(_id), description(_description)
{}
~BodySpot() = default;
public:
uint32_t id;
std::string description;
std::set<uint32_t, Interoceptor> interoceptors;
};
class BodyPart
{
public:
BodyPart(uint32_t _partId, std::string _partName,
std::string _partDesc, std::string _partLoc)
: id(_partId), name(_partName),
description(_partDesc), location(_partLoc)
{}
~BodyPart() = default;
public:
const uint32_t id;
std::string name, description, location;
std::set<uint32_t, BodySpot> spots;
};
#endif // BODYPART_H
+28
View File
@@ -0,0 +1,28 @@
#ifndef BODY_LIMB_H
#define BODY_LIMB_H
#include <string>
#include <set>
#include <cstdint>
#include <body/bodyPart.h>
class BodyLimb
{
public:
BodyLimb(uint32_t _id) : id(_id) {}
BodyLimb(uint32_t _id,
const std::string& _name, const std::string& _desc,
const std::string& _loc)
: id(_id), name(_name), description(_desc), location(_loc)
{}
~BodyLimb() = default;
public:
uint32_t id;
std::string name, description, location;
std::set<uint32_t, BodyPart> parts;
};
#endif // BODY_LIMB_H
-12
View File
@@ -1,12 +0,0 @@
#ifndef _BODY_LOCUS_H
#define _BODY_LOCUS_H
#include <cstdint>
class BodyCoords
{
uint32_t segment;
uint32_t coord;
};
#endif
+92
View File
@@ -0,0 +1,92 @@
#ifndef _INTEROCEPTOR_H
#define _INTEROCEPTOR_H
#include <cstdint>
class Interoceptor {
public:
Interoceptor(uint32_t _id, uint32_t _value = 0)
: id(_id), value(_value)
{}
~Interoceptor() = default;
public:
uint32_t id, value;
};
class NeutralInteroceptor
: public Interoceptor {
public:
NeutralInteroceptor(uint32_t _id, uint32_t _value = 0)
: Interoceptor(_id, _value)
{}
};
class IntrinInteroceptor
: public Interoceptor {
public:
static constexpr uint32_t DEFAULT_INDICATION_THRESHOLD = 1;
static constexpr uint32_t DEFAULT_ALERT_THRESHOLD = 5;
static constexpr uint32_t DEFAULT_OVERLOAD_THRESHOLD = 9;
IntrinInteroceptor(
uint32_t _id,
uint32_t _value = 0,
uint32_t _indicationThreshold = DEFAULT_INDICATION_THRESHOLD,
uint32_t _alertThreshold = DEFAULT_ALERT_THRESHOLD,
uint32_t _overloadThreshold = DEFAULT_OVERLOAD_THRESHOLD)
: Interoceptor(_id, _value),
indicationThreshold(_indicationThreshold),
alertThreshold(_alertThreshold),
overloadThreshold(_overloadThreshold)
{}
~IntrinInteroceptor() = default;
public:
uint32_t indicationThreshold;
uint32_t alertThreshold;
uint32_t overloadThreshold;
};
/**
* Pain and pleasure interoceptors are specialized intrinsic interoceptors that, unlike
* neutral interoceptors, have activation thresholds for different response levels
* (indication, alert, and overload). These thresholds allow them to trigger graduated
* responses based on stimulus intensity.
*
* While neutral interoceptors simply record a binary state or basic value, pain and
* pleasure interoceptors can model complex sensory responses with multiple activation
* levels, similar to biological pain/pleasure responses. Each threshold represents a
* different level of urgency or intensity in the sensory input.
*
* @see IntrinInteroceptor for the threshold values and implementation details
*****************************************************************************************/
class PainInteroceptor
: public IntrinInteroceptor {
public:
PainInteroceptor(
uint32_t _id,
uint32_t _value = 0,
uint32_t _indicationThreshold = DEFAULT_INDICATION_THRESHOLD,
uint32_t _alertThreshold = DEFAULT_ALERT_THRESHOLD,
uint32_t _overloadThreshold = DEFAULT_OVERLOAD_THRESHOLD)
: IntrinInteroceptor(_id, _value, _indicationThreshold, _alertThreshold, _overloadThreshold)
{}
};
class PleasureInteroceptor
: public IntrinInteroceptor {
public:
PleasureInteroceptor(
uint32_t _id,
uint32_t _value = 0,
uint32_t _indicationThreshold = DEFAULT_INDICATION_THRESHOLD,
uint32_t _alertThreshold = DEFAULT_ALERT_THRESHOLD,
uint32_t _overloadThreshold = DEFAULT_OVERLOAD_THRESHOLD)
: IntrinInteroceptor(_id, _value, _indicationThreshold, _alertThreshold, _overloadThreshold)
{}
};
#endif // _INTEROCEPTOR_H
+30
View File
@@ -0,0 +1,30 @@
#ifndef STUPEFIER_H
#define STUPEFIER_H
#include <cstdint>
class Stupefier {
public:
Stupefier();
~Stupefier();
void up(uint32_t);
void down(uint32_t);
public:
uint32_t focus;
};
class SoftStupefier : public Stupefier {
public:
SoftStupefier();
~SoftStupefier();
};
class HardStupefier : public Stupefier {
public:
HardStupefier();
~HardStupefier();
};
#endif // STUPEFIER_H