Example #1
0
    bool Workspace::TryInit()
    {
        if (this->m_bInited)
        {
            return true;
        }

        this->m_bInited = true;

		BEHAVIAC_LOGINFO("Version: %s\n", behaviac::GetVersionString());
		Config::LogInfo();

        bool bOk = TryStart();

        if (!bOk)
        {
            return false;
        }

        if (this->GetFileFormat() == EFF_cpp || this->GetFileFormat() == EFF_default)
        {
            GenerationManager::RegisterBehaviors();
        }

        const char* szWorkspaceExportPath = this->GetFilePath();

        if (StringUtils::IsNullOrEmpty(szWorkspaceExportPath))
        {
            LogManager::GetInstance()->Error("No 'WorkspaceExportPath' is specified!");
            BEHAVIAC_ASSERT(false);

            return false;
        }

        BEHAVIAC_LOGINFO("'WorkspaceExportPath' is '%s'\n", szWorkspaceExportPath);

        //BEHAVIAC_ASSERT(!StringUtils::EndsWith(szWorkspaceExportPath, "\\"), "use '/' instead of '\\'");

#if BEHAVIAC_ENABLE_HOTRELOAD
		if (behaviac::Config::IsHotReload())
		{
			behaviac::wstring dir = behaviac::StringUtils::Char2Wide(szWorkspaceExportPath);
			CFileSystem::StartMonitoringDirectory(dir.c_str());
		}
#endif//BEHAVIAC_ENABLE_HOTRELOAD

        //////////////////////////////////////////////////////////
        //this->RegisterStuff();
        AgentProperties::RegisterCustomizedTypes();

        AgentProperties::Load();

#if !BEHAVIAC_RELEASE
        LogWorkspaceInfo();
#endif

        return true;
    }
Example #2
0
void CScriptSystem::Log(const char* message)
{
#ifdef _DEBUG

    if (message)
    {
        // add the "S>" prefix to understand that this message
        // has been called from a script function
        char sLogMessage[1024];

        if (message[0] <= 5)
        {
            sLogMessage[0] = message[0];
            strcpy(sLogMessage + 1, SCRIPT_LOG_SHORT_PREFIX);
            strncat(sLogMessage, message + 1, sizeof(sLogMessage) - sizeof(SCRIPT_LOG_SHORT_PREFIX));
        }
        else
        {
            strcpy(sLogMessage, SCRIPT_LOG_FULL_PREFIX);
            strncat(sLogMessage, message, sizeof(sLogMessage) - sizeof(SCRIPT_LOG_FULL_PREFIX));
        }

        sLogMessage[sizeof(sLogMessage) - 1] = '\0';	// strncat fail safe
        BEHAVIAC_LOGINFO(sLogMessage);
    }

#endif
}
Example #3
0
void CScriptSystem::UnloadScript(const char* sFileName)
{
    if (strlen(sFileName) <= 0)
    {
        return;
    }

    CPathID sTemp(sFileName);
    ScriptFileListItor itor = this->findFile(sTemp);

    if (itor != m_dqLoadedFiles.end())
    {
#ifdef DEBUG_RESID
        BEHAVIAC_LOGINFO("ERASE :%s\n", sTemp.GetFileName());
#endif
        m_dqLoadedFiles.erase(itor);
    }
}
    bool Workspace::TryInit()
    {
        if (this->m_bInited)
        {
            return true;
        }

        this->m_bInited = true;

        bool bOk = TryStart();

        if (!bOk)
        {
            return false;
        }

        if (this->GetFileFormat() == EFF_cpp || this->GetFileFormat() == EFF_default)
        {
            GenerationManager::RegisterBehaviors();
        }

        const char* szWorkspaceExportPath = this->GetFilePath();

        if (StringUtils::IsNullOrEmpty(szWorkspaceExportPath))
        {
            LogManager::GetInstance()->Error("No 'WorkspaceExportPath' is specified!");
            BEHAVIAC_ASSERT(false);

            return false;
        }

        BEHAVIAC_LOGINFO("'WorkspaceExportPath' is '%s'\n", szWorkspaceExportPath);

        //BEHAVIAC_ASSERT(!StringUtils::EndsWith(szWorkspaceExportPath, "\\"), "use '/' instead of '\\'");

        LoadWorkspaceAbsolutePath();

		m_deltaTime = 0.0167f;
        m_deltaFrames = 1;

#if BEHAVIAC_ENABLE_HOTRELOAD
        behaviac::wstring dir = behaviac::StringUtils::Char2Wide(szWorkspaceExportPath);
        CFileSystem::StartMonitoringDirectory(dir.c_str());
#endif//BEHAVIAC_ENABLE_HOTRELOAD

        //////////////////////////////////////////////////////////
        //this->RegisterStuff();
        AgentProperties::RegisterCustomizedTypes();

        AgentProperties::Load();

#if !BEHAVIAC_RELEASE
#if BEHAVIAC_HOTRELOAD

        // set the file watcher
        if (Config.IsDesktop)
        {
            if (this->GetFileFormat() != EFF_cs)
            {
                if (m_DirectoryMonitor == null)
                {
                    m_DirectoryMonitor = new DirectoryMonitor();
                    m_DirectoryMonitor.Changed += new DirectoryMonitor.FileSystemEvent(OnFileChanged);
                }

                string filter = "*.*";

                if (this->GetFileFormat() == EFF_xml)
                {
                    filter = "*.xml";

                }
                else if (this->GetFileFormat() == EFF_bson)
                {
                    filter = "*.bson.bytes";
                }

                m_DirectoryMonitor.Start(this->WorkspaceExportPath, filter);
            }
        }
    void Workspace::SetFilePath(const char* szExportPath)
    {
        string_ncpy(this->m_szWorkspaceExportPath, szExportPath, kMaxPath);
		BEHAVIAC_LOGINFO(m_szWorkspaceExportPath);
    }
Example #6
0
void CScriptSystem::Trace(const char* message)
{
    BEHAVIAC_LOGINFO(message);
}
 void PostLoad()
 {
     BEHAVIAC_LOGINFO("PostLoad\n");
 }
 static int TestFunction(const char* str)
 {
     BEHAVIAC_LOGINFO(str);
     return 0;
 }
 void PostSave()
 {
     BEHAVIAC_LOGINFO("PostSave\n");
 }
Example #10
0
 void PreSave()
 {
     BEHAVIAC_LOGINFO("PreSave\n");
 }