|
|
|
|
|
|
|
|
|
|
|
const string COMP_NAME_NONE = "None"; |
|
const int COMP_TYPE_UNDEFINED = -1; |
|
const int COMP_TYPE_ETITY_DEBUG = 0; |
|
const int COMP_TYPE_ENERGY_MANAGER = 1; |
|
const int COMP_TYPE_BODY_STAGING = 2; |
|
const int COMP_TYPE_ANIMAL_BLEEDING = 3; |
|
const int COMP_TYPE_COUNT = 4; |
|
|
|
|
|
class Component |
|
{ |
|
|
|
|
|
|
|
private static string m_CompNames[COMP_TYPE_COUNT]; |
|
|
|
|
|
|
|
protected EntityAI m_ThisEntityAI; |
|
|
|
|
|
|
|
void Event_OnFrame(IEntity other, float timeSlice); |
|
Shape DebugBBoxDraw(); |
|
void DebugBBoxSetColor(int color); |
|
void DebugBBoxDelete(); |
|
Shape DebugDirectionDraw(float distance = 1); |
|
void DebugDirectionSetColor(int color); |
|
void DebugDirectionDelete(); |
|
|
|
|
|
static void Init() |
|
{ |
|
m_CompNames[COMP_TYPE_ETITY_DEBUG] = "ComponentEntityDebug"; |
|
m_CompNames[COMP_TYPE_ENERGY_MANAGER] = "ComponentEnergyManager"; |
|
m_CompNames[COMP_TYPE_BODY_STAGING] = "ComponentBodyStaging"; |
|
m_CompNames[COMP_TYPE_ANIMAL_BLEEDING] = "ComponentAnimalBleeding"; |
|
} |
|
|
|
|
|
|
|
|
|
static string GetNameByType(int comp_type) |
|
{ |
|
if ( IsTypeExist(comp_type) == false ) |
|
{ |
|
LogErrorBadCompType(comp_type, "Component->GetNameByType()"); |
|
return "None"; |
|
} |
|
|
|
return m_CompNames[comp_type]; |
|
} |
|
|
|
|
|
|
|
|
|
static bool IsTypeExist(int comp_type) |
|
{ |
|
if ( comp_type < 0 || comp_type >= COMP_TYPE_COUNT ) |
|
{ |
|
return false; |
|
} |
|
|
|
return true; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void LogErrorBadCompType(int comp_type, string fnc_name) |
|
{ |
|
string msg = "Bad parameter comp_type='"+comp_type.ToString()+"'. Parameter must be 0-"+(COMP_TYPE_COUNT - 1).ToString()+". Returning component name 'None'."; |
|
Debug.LogError(msg, "Component", "n/a", fnc_name); |
|
} |
|
|
|
|
|
|
|
|
|
static void LogWarningAlredyExist(int comp_type, string fnc_name) |
|
{ |
|
string msg = "Component '"+Component.GetNameByType(comp_type)+"' already exists!"; |
|
Debug.LogError(msg, "Component", "n/a", fnc_name); |
|
} |
|
|
|
|
|
|
|
|
|
void SetParentEntityAI(EntityAI e) |
|
{ |
|
m_ThisEntityAI = e; |
|
} |
|
|
|
|
|
|
|
|
|
void Event_OnAwake() |
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Event_OnInit() |
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
void LogThis(string msg, string fnc_name = "n/a") |
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
void LogThisWarning(string msg, string fnc_name = "n/a") |
|
{ |
|
Debug.LogWarning(msg, GetCompName(), "n/a", fnc_name, m_ThisEntityAI.ToString()); |
|
} |
|
|
|
|
|
|
|
|
|
void LogThisError(string msg, string fnc_name = "n/a") |
|
{ |
|
Debug.LogError(msg, GetCompName(), "n/a", fnc_name, m_ThisEntityAI.ToString()); |
|
} |
|
|
|
|
|
|
|
|
|
string GetCompName() |
|
{ |
|
return Component.GetNameByType(this.GetCompType()); |
|
} |
|
|
|
|
|
|
|
|
|
int GetCompType() |
|
{ |
|
return COMP_TYPE_UNDEFINED; |
|
} |
|
|
|
|
|
|
|
|
|
void Event_OnItemAttached(EntityAI item, string slot_name) |
|
{ |
|
LogThis("" + item + " -> " + slot_name,"Event_OnItemAttached"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Event_OnItemDetached(EntityAI item, string slot_name) |
|
{ |
|
LogThis("" + item + " <- " + slot_name,"Event_OnItemDetached"); |
|
|
|
} |
|
} |