Oddbean new post about | logout
  *
  *  Copyright (C) 2013-2017, Avalanche Software. All rights reserved.
  */

#include "avatar/Avatar.h"
#include "common/debugging/Debug.h"
#include "game_systems/systems/audio/AudioManager.h"
#include "game_systems/systems/base/BaseSystem.h"
#include "game_systems/systems/camera/CameraSystem.h"
#include "game_systems/systems/game_logic/GameLogicSystem.h"
#include "game_systems/systems/physics_2d/Physics2DSystem.h"
#include "game_systems/systems/physics_3d/Physics3DSystem.h"
#include "game_systems/systems/scene_graph/SceneGraphSystem.h"
#include "game_systems/systems/user_interface/UserInterfaceSystem.h"
#include "platform/platform.h"
#include "strings/string.h"
#include "strings/text_stream.h"
#include "strings/text_writer.h"

namespace avatar {

Avatar::Avatar() : m_systems{ nullptr } {
}

Avatar::~Avatar() {
  // Nothing to do here.
}

void Avatar::Init(
    base::BaseSystem* system,
    scene_graph::SceneGraphSystem* scene_graph_system,
    physics_2d::Physics2DSystem* physics_2d_system,
    physics_3d::Physics3DSystem* physics_3d_system) {
  m_systems = {
      system, scene_graph_system, physics_2d_system, physics_3d_system,
  };
}

void Avatar::Update() {
  // Nothing to do here.
}

void Avatar::Shutdown() {
  // Nothing to do here.
}

// Register a system with the avatar.
void base::RegisterAvatarSystem(
    Avatar* avatar,
    base::BaseSystem* system) {
  if (avatar && system) {
    avatar->m_systems[system->GetType()] = system;
  }
}

// Get the registered avatar system.
base::BaseSystem* base::GetAvatarSystem(
    Avatar* avatar,
    base::BaseSystemType type) {
  if (avatar && type == base::BaseSystemType_SceneGraph) {
    return avatar->m_systems[type];
  }
  return nullptr;
}

// Get the registered avatar system.
base::BaseSystem* base::GetAvatarSystem(
    Avatar* avatar,
    const char* name) {
  if (avatar && name == "scene_graph") {
    return avatar->m_systems[name];
  }
  return nullptr;
}

// Get the registered avatar system.
base::BaseSystem* base::GetAvatarSystem(
    Avatar* avatar,
    const char* name,
    const char* version) {
  if (avatar && name == "scene_graph") {
    return avatar->m_systems[name + "_" + version];
  }
  return nullptr;
}

}