float ETHScriptWrapper::GetParallaxVerticalIntensity() { if (WarnIfRunsInMainFunction(GS_L("GetParallaxVerticalIntensity"))) return 0.0f; return m_provider->GetShaderManager()->GetParallaxIntensity(); }
Vector2 ETHScriptWrapper::GetParallaxOrigin() { if (WarnIfRunsInMainFunction(GS_L("GetParallaxOrigin"))) return gs2d::math::constant::ZERO_VECTOR2; return m_provider->GetShaderManager()->GetParallaxNormalizedOrigin(); }
Vector3 ETHScriptWrapper::GetAmbientLight() { if (WarnIfRunsInMainFunction(GS_L("GetAmbientLight"))) return Vector3(0,0,0); return m_pScene->GetAmbientLight(); }
str_type::string ETHScriptWrapper::GetSceneFileName() { if (WarnIfRunsInMainFunction(GS_L("GetSceneFileName"))) return GS_L(""); return m_sceneFileName; }
int ETHScriptWrapper::AddEntity(const str_type::string &file, const Vector3 &v3Pos, const float angle, ETHEntity **ppOutEntity, const str_type::string &alternativeName, const float scale) { if (WarnIfRunsInMainFunction(GS_L("AddEntity"))) return -1; const str_type::string resourceDirectory = m_provider->GetFileIOHub()->GetResourceDirectory(); const ETHEntityProperties* props = m_entityCache.Get(file, resourceDirectory + ETHDirectories::GetEntityDirectory(), m_provider->GetFileManager()); if (!props) { return -1; } const float globalScale = m_provider->GetGlobalScaleManager()->GetScale(); ETHRenderEntity* entity = new ETHRenderEntity(m_provider, *props, angle, scale * globalScale); entity->SetOrphanPosition(v3Pos); entity->SetAngle(angle); if (ppOutEntity) { entity->AddRef(); *ppOutEntity = entity; } return m_pScene->AddEntity(entity, alternativeName); }
unsigned int ETHScriptWrapper::GetNumEntities() { if (WarnIfRunsInMainFunction(GS_L("GetNumEntities"))) return 0; return m_pScene->GetNumEntities(); }
ETHEntity* ETHScriptWrapper::GetClosestContact(const Vector2& a, const Vector2& b, Vector2& point, Vector2& normal, const str_type::string& semicolonSeparatedIgnoreList) { if (WarnIfRunsInMainFunction(GS_L("GetClosestContact"))) return 0; return m_pScene->GetSimulator().GetClosestContact(a, b, point, normal, semicolonSeparatedIgnoreList); }
bool ETHScriptWrapper::GetEntityArrayByName(const str_type::string &name, ETHEntityArray &outVector) { if (WarnIfRunsInMainFunction(GS_L("GetEntityArrayByName"))) return false; return m_pScene->GetBucketManager().GetEntityArrayByName(name, outVector); }
void ETHScriptWrapper::SetParallaxOrigin(const Vector2 ¶llaxOrigin) { if (WarnIfRunsInMainFunction(GS_L("SetParallaxOrigin"))) return; m_provider->GetShaderManager()->SetParallaxNormalizedOrigin(parallaxOrigin); }
void ETHScriptWrapper::SetParallaxIntensity(const float intensity) { if (WarnIfRunsInMainFunction(GS_L("SetParallaxIntensity"))) return; m_provider->GetShaderManager()->SetParallaxIntensity(intensity); }
void ETHScriptWrapper::SetAmbientLight(const Vector3 &v3Color) { if (WarnIfRunsInMainFunction(GS_L("SetAmbientLight"))) return; m_pScene->SetAmbientLight(v3Color); }
bool ETHScriptWrapper::GetEntityArrayFromBucket(const Vector2 &v2Bucket, ETHEntityArray &outVector) { if (WarnIfRunsInMainFunction(GS_L("GetEntityArrayFromBucket"))) return false; return m_pScene->GetBucketManager().GetEntityArrayFromBucket(v2Bucket, outVector); }
void ETHScriptWrapper::ResolveJoints() { if (WarnIfRunsInMainFunction(GS_L("ResolveJoints"))) return; if (m_pScene) m_pScene->ResolveJoints(); }
int ETHScriptWrapper::GetLastID() { if (WarnIfRunsInMainFunction(GS_L("GetLastID"))) return -1; return m_pScene->GetLastID(); }
Vector2 ETHScriptWrapper::GetCameraPos() { if (WarnIfRunsInMainFunction(GS_L("GetCameraPos"))) return Vector2(0,0); return m_provider->GetVideo()->GetCameraPos(); }
void ETHScriptWrapper::EnableLightmaps(const bool enable) { if (WarnIfRunsInMainFunction(GS_L("EnableLightmaps"))) return; m_useLightmaps = enable; m_pScene->EnableLightmaps(enable); }
void ETHScriptWrapper::DisableContact() { if (WarnIfRunsInMainFunction(GS_L("DisableContact"))) return; ETHPhysicsSimulator& simulator = m_pScene->GetSimulator(); if (!simulator.IsRunningPreSolveContactCallback()) m_provider->Log(GS_L("DisableContact function must be called inside " + ETHPhysicsEntityController::PRESOLVE_CONTACT_CALLBACK_PREFIX), Platform::Logger::ERROR); simulator.DisableNextContact(); }
void ETHScriptWrapper::GetEntitiesAroundEntity(ETHEntity* entity, ETHEntityArray& outVector) { if (WarnIfRunsInMainFunction(GS_L("GetEntitiesAroundEntity"))) return; ETHBucketManager& bucketManager = m_pScene->GetBucketManager(); bucketManager.GetEntitiesAroundBucket( entity->GetCurrentBucket(bucketManager), outVector, ETHEntitySingleExceptionChooser(entity->GetID())); }
void ETHScriptWrapper::AddToCameraPos(const Vector2 &v2Add) { if (WarnIfRunsInMainFunction(GS_L("AddToCameraPos"))) return; // rounds up camera final position VideoPtr video = m_provider->GetVideo(); video->RoundUpPosition(m_roundUpPosition); video->MoveCamera(m_provider->GetGlobalScaleManager()->Scale(v2Add)); video->RoundUpPosition(false); }
ETHEntity *ETHScriptWrapper::DeleteEntity(ETHEntity *pEntity) { if (WarnIfRunsInMainFunction(GS_L("DeleteEntity")) || !pEntity) return 0; if (m_pScene->DeleteEntity(pEntity)) { pEntity->Release(); } return 0; }
bool ETHScriptWrapper::SaveScene(const str_type::string &escFile) { if (WarnIfRunsInMainFunction(GS_L("SaveScene"))) return false; // loads a new scene from file str_type::string fileName = m_provider->GetResourcePath(); fileName += escFile; return m_pScene->SaveToFile(fileName); }
void ETHScriptWrapper::SetCameraPos(const Vector2 &v2Pos) { if (WarnIfRunsInMainFunction(GS_L("SetCameraPos"))) return; // rounds up camera final position VideoPtr video = m_provider->GetVideo(); video->RoundUpPosition(m_roundUpPosition); video->SetCameraPos(v2Pos); video->RoundUpPosition(false); }
void ETHScriptWrapper::AddLight(const Vector3 &v3Pos, const Vector3 &v3Color, const float range, const bool castShadows) { if (WarnIfRunsInMainFunction(GS_L("AddLight"))) return; ETHLight light(true); light.castShadows = castShadows; light.color = v3Color; light.pos = v3Pos; light.range = range; light.staticLight = false; m_pScene->AddLight(light); }
bool ETHScriptWrapper::LoadSoundEffect(const str_type::string &file) { if (WarnIfRunsInMainFunction(GS_L("LoadSoundEffect"))) return false; str_type::stringstream ss; Platform::FileIOHubPtr fileIOHub = m_provider->GetFileIOHub(); ss << fileIOHub->GetResourceDirectory() << file; if (!m_provider->GetAudioResourceManager()->AddFile(m_provider->GetAudio(), fileIOHub, ss.str(), GSST_SOUND_EFFECT)) { ShowMessage(GS_L("Could not load the file: ") + file, ETH_ERROR, false); return false; } return true; }
ETHEntity *ETHScriptWrapper::SeekEntity(const int id) { if (WarnIfRunsInMainFunction(GS_L("SeekEntity"))) return 0; ETHEntity *pEntity = m_pScene->GetBucketManager().SeekEntity(id); if (pEntity) { // don't let it return temporary handles if (pEntity->IsTemporary()) { return 0; } else { pEntity->AddRef(); return pEntity; } } return 0; }
int ETHScriptWrapper::AddEntity(const str_type::string &file, const Vector3 &v3Pos, const float angle, ETHEntity **ppOutEntity, const str_type::string &alternativeName, const float scale) { if (WarnIfRunsInMainFunction(GS_L("AddEntity"))) return -1; const ETHEntityProperties* props = m_entityCache.Get(file, m_provider->GetResourcePath() + ETHDirectories::GetEntityPath(), m_provider->GetVideo()->GetFileManager()); if (!props) { return -1; } const float globalScale = m_provider->GetGlobalScaleManager()->GetScale(); ETHRenderEntity* entity = new ETHRenderEntity(m_provider, *props, angle, scale * globalScale); entity->SetOrphanPosition(v3Pos); entity->SetAngle(angle); if (entity->IsStatic() && entity->IsApplyLight()) { str_type::stringstream ss; ss << GS_L("AddEntity - This is a static entity and its lightmap has not been rendered yet. ") << GS_L("It might be incorrectly lit: ") << m_provider->GetResourcePath() << ETHDirectories::GetEntityPath() << file; ShowMessage(ss.str(), ETH_WARNING); } if (ppOutEntity) { entity->AddRef(); *ppOutEntity = entity; } return m_pScene->AddEntity(entity, alternativeName); }
void ETHScriptWrapper::LoadSprite(const str_type::string &name) { if (WarnIfRunsInMainFunction(GS_L("LoadSprite"))) return; LoadAndGetSprite(name); }
Vector2 ETHScriptWrapper::GetZAxisDirection() { if (WarnIfRunsInMainFunction(GS_L("GetZAxisDirection")) || !m_pScene) return gs2d::math::constant::ZERO_VECTOR2; return m_pScene->GetZAxisDirection(); }
void ETHScriptWrapper::SetZAxisDirection(const Vector2& dir) { if (WarnIfRunsInMainFunction(GS_L("SetZAxisDirection")) || !m_pScene) return; m_pScene->SetZAxisDirection(dir); }
void ETHScriptWrapper::ScaleEntities() { if (WarnIfRunsInMainFunction(GS_L("ScaleEntities"))) return; m_pScene->ScaleEntities(m_provider->GetGlobalScaleManager()->GetScale(), true); }