Ejemplo n.º 1
0
bool DropPoolConfig::Generate(uint id, List<DropPoolItem>& outItems, void* userData/*=nullptr*/) const
{
	const DropPool* dropPool = Find(id);
	Log::AssertNotNullFormat(dropPool, "Cannot find drop pool id:{}", id);
	RETURN_FALSE_IF_NULL(dropPool);
	return dropPool->Generate(*this, outItems, userData);
}
Ejemplo n.º 2
0
bool IBrainBody::Behave(void* sender, float dt)
{
	RETURN_FALSE_IF_NULL(mBrain);

	if (mCurrentBehavior != nullptr)
	{
		RETURN_TRUE_IF_TRUE(mCurrentBehavior->Update(*this, sender, dt));
		mCurrentBehavior->Exit(*this, sender);
		mCurrentBehavior = nullptr;
	}

	const IBehavior* newBehavior = mBrain->Behave(*this, sender);
	if (mCurrentBehavior != newBehavior)
	{
		mCurrentBehavior = newBehavior;
		if (mCurrentBehavior != nullptr)
		{
			RETURN_TRUE_IF_TRUE(mCurrentBehavior->Update(*this, sender, dt));
			mCurrentBehavior->Exit(*this, sender);
			mCurrentBehavior = nullptr;
		}
	}


	return true;
}
Ejemplo n.º 3
0
bool TiledImage::LoadTiledTexture(Size2I tileSize)
{
	auto textureAtlas=TextureAtlasFactory::Instance().CreateTiledAtlas(mSource, mSize, tileSize);
	RETURN_FALSE_IF_NULL(textureAtlas);
	mTexturePage = textureAtlas->FindPage(0);
	mTextureAtlas = textureAtlas;
	return true;
}
Ejemplo n.º 4
0
bool FileStorage::RemoveFile(FileEntry* file)
{
	RETURN_FALSE_IF_NULL(file);
	RETURN_FALSE_IF_NULL(file->Parent());

#ifdef MEDUSA_SAFE_CHECK
	if (file->Storage() != this)
	{
		Log::AssertFailed("Invalid operate file on different storage.");
		return false;
	}
#endif

	RETURN_FALSE_IF_FALSE(OnRemoveFile(*file));

	auto* parent = file->Parent();
	return parent->RemoveFile(file);
}
Ejemplo n.º 5
0
bool FileStorage::SaveFile(FileEntry& fileEntry, const IStream& sourceStream)
{
	IStream* stream = WriteFileHelper(fileEntry, FileOpenMode::DestoryWriteOrCreate, FileDataType::Binary);
	RETURN_FALSE_IF_NULL(stream);
	sourceStream.CopyTo(*stream);
	SAFE_RELEASE(stream);

	return true;
}
Ejemplo n.º 6
0
 static bool SetSharedMemoryPool(SharedMemoryPool* pool)
 {
     RETURN_FALSE_IF_NULL(pool);
     if (NULL != m_raw)
     {
         return false;
     }
     m_raw = pool;
     return true;
 }
Ejemplo n.º 7
0
	bool str_todouble(const char* str, double& value)
	{
		RETURN_FALSE_IF_NULL(str);
		char *endptr = NULL;
		double val = strtod(str, &endptr);
		if (NULL == endptr || 0 != *endptr)
		{
			return false;
		}
		value = val;
		return true;
	}
Ejemplo n.º 8
0
	bool str_tofloat(const char* str, float& value)
	{
		RETURN_FALSE_IF_NULL(str);
		char *endptr = NULL;
		float val = strtof(str, &endptr);
		if (NULL == endptr || 0 != *endptr)
		{
			return false;
		}
		value = val;
		return true;
	}
Ejemplo n.º 9
0
	bool str_toint64(const char* str, int64& value)
	{
		RETURN_FALSE_IF_NULL(str);
		char *endptr = NULL;
		long long int val = strtoll(str, &endptr, 10);
		if (NULL == endptr || 0 != *endptr)
		{
			return false;
		}
		value = val;
		return true;
	}
Ejemplo n.º 10
0
bool ShaderConstantInitializer::UpdateWorldMatrix( ShaderConstant& uniform )
{
	BaseProgramRenderPass* effect= RenderingContext::Instance().ProgramRenderPass();
	RETURN_FALSE_IF_NULL(effect);

	IRenderBatch* batch=RenderingContext::Instance().Batch();
	const Matrix& modelMatrix=batch->GetModelMatrix();
	uniform.Invalidate();
	uniform.SetMatrix(modelMatrix);

	return true;
}
Ejemplo n.º 11
0
bool ShaderConstantInitializer::Update(RenderingStep step, ShaderConstant& uniform)
{
	InitializerType* tempInitializer= mInitializerDict.TryGetValueWithFailed(step,nullptr);
	RETURN_FALSE_IF_NULL(tempInitializer);

	FuncType* func=(tempInitializer)->TryGetValue(uniform.Name());
	if (func==nullptr)
	{
		return false;
	}
	
	return (*func)(uniform);
}
Ejemplo n.º 12
0
bool ScriptModule::NewObjects(StringRef className, size_t count, List<ScriptObject*>& outObjects)
{
	outObjects.Clear();
	asIObjectType* scriptObjectType = mScriptModule->GetObjectTypeByName(className.c_str());
	RETURN_FALSE_IF_NULL(scriptObjectType);

	HeapString factoryName = className;
	factoryName += "@ ";
	factoryName += className;
	factoryName += "()";
	asIScriptFunction* factory = scriptObjectType->GetFactoryByDecl(factoryName.c_str());
	RETURN_FALSE_IF_NULL(factory);
	asIScriptContext* context = ScriptEngine::Instance().GetScriptContext();

	List<ScriptObject*> result;
	FOR_EACH_SIZE(i, count)
	{
		context->Prepare(factory);
		context->Execute();
		asIScriptObject* scriptObject = *(asIScriptObject**)context->GetAddressOfReturnValue();
		ScriptObject* temp = new ScriptObject(scriptObject);
		outObjects.Add(temp);
	}
Ejemplo n.º 13
0
bool PODLighTimeline::Start()
{
	RETURN_FALSE_IF_FALSE((ITimeline::Start()));

	auto ani = mModel.CastPtr<PODLightTimelineModel>();
	StringRef lightName=ani->LightName();
	StringRef targetName=ani->TargetNodeName();

	mLight=LightFactory::Instance().Find(lightName);
	RETURN_FALSE_IF_NULL(mLight);


	return true;
}
Ejemplo n.º 14
0
bool IBrainBody::ReceiveEvent(void* sender, IEventArg& e)
{
	RETURN_FALSE_IF_NULL(mBrain);
	const IBehavior* newBehavior = mBrain->ReceiveEvent(*this, sender, e);
	if (newBehavior != nullptr)
	{
		if (mCurrentBehavior != nullptr)
		{
			mCurrentBehavior->Exit(*this, sender);
		}
		mCurrentBehavior = newBehavior;
	}

	return true;

}
Ejemplo n.º 15
0
bool JPSPlusPathFinder::AddNeighbors(const Cell* currentCell, const Cell* nextCell, const Cell* goalCell, Direction direction)
{
	RETURN_FALSE_IF_NULL(nextCell);
	bool outIsCompleted = false;
	Direction outMarkedDirection;
	const Cell* nextNextCell = Jump(nextCell, goalCell, direction, outIsCompleted, outMarkedDirection);
	if (outIsCompleted)
	{
		LinkCell(currentCell, nextNextCell, (direction));
		LinkCell(nextNextCell, goalCell, outMarkedDirection);
		return true;
	}
	if (nextNextCell)
	{
		AddToOpenList(currentCell, nextNextCell, goalCell, direction);
	}
	return false;
}
Ejemplo n.º 16
0
bool ShaderConstantInitializer::UpdateViewProjectMatrix( ShaderConstant& uniform)
{
	BaseProgramRenderPass* effect= RenderingContext::Instance().ProgramRenderPass();
	RETURN_FALSE_IF_NULL(effect);

	//IRenderBatch* batch=RenderingContext::Instance().GetBatch();
	Camera* camera= RenderingContext::Instance().GetCamera();
	if (camera!=nullptr)
	{
		const Matrix& projectionMatrix= camera->ViewProjectionMatrix();
		uniform.SetMatrix(projectionMatrix);
	}
	else
	{
		Log::Error("No camera for ViewProjectMatrix");
	}

	return true;
}
Ejemplo n.º 17
0
	bool ChannelPipeline::SendUpstream(ChannelHandlerContext* ctx,
			MessageEvent<T>& e)
	{
		RETURN_FALSE_IF_NULL(ctx);

		ChannelHandler* base = ctx->GetHandler();
		ChannelUpstreamHandler<T> * handler = dynamic_cast<ChannelUpstreamHandler<T>*>(base);
		//ChannelUpstreamHandler<T> * handler = NULL;
		//if (ChannelHandlerHelper<T>::CanHandleUpMessageEvent(base))
		//{
		//	handler = static_cast<ChannelUpstreamHandler<T>*>(base);
		//}
		if (NULL == handler)
		{
			return ctx->SendUpstream(e);
		} else
		{
			return handler->HandleStreamEvent(*ctx, e);
		}
	}
Ejemplo n.º 18
0
bool INode::RemoveChild(INode* node)
{
	RETURN_FALSE_IF_NULL(node);
	if (mNodes.RemoveFirst(node))
	{
		node->SetParent(nullptr);
		mNodeDict.RemoveKey(node->Name());

		if (node->IsManaged())
		{
			mManagedNodes.RemoveFirst(node);
		}

		OnLayoutChanged(*node, NodeLayoutChangedFlags::ChildRemoved);

		OnRenderQueueChanged();
		OnVisitQueueChanged();
		return true;
	}
	return false;

}
Ejemplo n.º 19
0
bool ShaderConstantInitializer::UpdateWorldViewProjectMatrix( ShaderConstant& uniform)
{
	BaseProgramRenderPass* effect= RenderingContext::Instance().ProgramRenderPass();
	RETURN_FALSE_IF_NULL(effect);

	IRenderBatch* batch=RenderingContext::Instance().Batch();
	const Matrix& modelMatrix=batch->GetModelMatrix();
	Camera* camera= RenderingContext::Instance().GetCamera();
	if (camera!=nullptr)
	{
		const Matrix& projectionMatrix= camera->ViewProjectionMatrix();
		Matrix pmvMatrix=modelMatrix*projectionMatrix;
		uniform.Invalidate();
		uniform.SetMatrix(pmvMatrix);
	}
	else
	{
		uniform.Invalidate();
		uniform.SetMatrix(modelMatrix);
	}

	return true;
}
Ejemplo n.º 20
0
bool FileStorage::SearchFilesToExtract(const StringRef& searchPath, bool isRecursively /*= true*/, const StringRef& outDir /*= StringRef::Empty*/)
{
	if (Path::IsDirectory(searchPath))
	{
		return ExtractDirectory(searchPath, nullptr, isRecursively, outDir);
	}
	else
	{
		if (Path::HasSearchPattern(searchPath))
		{
			List<HeapString> outFiles;
			FileInfo fileInfo(searchPath);
			auto dir = fileInfo.Directory();
			auto* dirEntry = FindDirectory(dir);
			RETURN_FALSE_IF_NULL(dirEntry);
			return dirEntry->SearchFilesToExtract(fileInfo.FullName(), isRecursively, outDir);
		}
		else
		{
			return ExtractFile(searchPath, nullptr, outDir);
		}
	}
}
Ejemplo n.º 21
0
bool FileStorage::SearchFilesToRemove(const StringRef& searchPath, bool isRecursively /*= true*/)
{
	if (Path::IsDirectory(searchPath))
	{
		return RemoveDirectory(searchPath);
	}
	else
	{
		if (Path::HasSearchPattern(searchPath))
		{
			List<HeapString> outFiles;
			FileInfo fileInfo(searchPath);
			auto dir = fileInfo.Directory();
			auto* dirEntry = FindDirectory(dir);
			RETURN_FALSE_IF_NULL(dirEntry);
			return dirEntry->SearchFilesToRemove(fileInfo.FullName(), isRecursively);
		}
		else
		{
			return RemoveFile(searchPath);
		}
	}
}
Ejemplo n.º 22
0
bool FileStorage::RemoveDirectory(DirectoryEntry* dir)
{
	RETURN_FALSE_IF_NULL(dir);
#ifdef MEDUSA_SAFE_CHECK
	if (dir->Storage() != this)
	{
		Log::AssertFailed("Invalid operate dir on different storage.");
		return false;
	}
	if (dir == &mRootDir)
	{
		Log::AssertFailed("Cannot remove root dir.");
		return false;
	}
#endif
	RETURN_FALSE_IF_FALSE(RemoveAllFiles(*dir));
	RETURN_FALSE_IF_FALSE(RemoveAllDirectories(*dir));

	RETURN_FALSE_IF_FALSE(OnRemoveDirectory(*dir));

	auto* parent = dir->Parent();
	parent->RemoveDirectory(dir);
	return true;
}
Ejemplo n.º 23
0
bool StringTable::Contains(const FileIdRef& fileId) const
{
	const StringNameItem* nameItem = mItems.TryGetValue(fileId.Name);
	RETURN_FALSE_IF_NULL(nameItem);
	return nameItem->Contains((uint)fileId.Order);
}
Ejemplo n.º 24
0
bool INode::RemoveChild(const StringRef& name)
{
	INode* node = FindChild(name);
	RETURN_FALSE_IF_NULL(node);
	return RemoveChild(node);
}
Ejemplo n.º 25
0
	bool ChannelPipeline::SendUpstream(T& event)
	{
		ChannelHandlerContext* ctx = GetActualUpstreamContext(m_head);
		RETURN_FALSE_IF_NULL(ctx);
		return SendUpstream(ctx, event);
	}
Ejemplo n.º 26
0
	bool ChannelPipeline::SendDownstream(ChannelHandlerContext* ctx, T& e)
	{
		RETURN_FALSE_IF_NULL(ctx);
		ChannelHandler* handler = ctx->GetHandler();
		return handler->HandleStreamEvent(*ctx, e);
	}
Ejemplo n.º 27
0
bool FileStorage::RemoveAllFiles(const StringRef& path)
{
	auto* parent = FindDirectory(path);
	RETURN_FALSE_IF_NULL(parent);
	return RemoveAllFiles(*parent);
}
Ejemplo n.º 28
0
bool FileMapTagItem::ContainsOrderItem(const FileIdRef& fileId) const
{
	const FileMapNameItem* nameItem = mItems.GetOptional(fileId.Name, nullptr);
	RETURN_FALSE_IF_NULL(nameItem);
	return nameItem->Contains((uint)fileId.Order);
}
Ejemplo n.º 29
0
bool FileStorage::ExtractFile(const StringRef& path, DirectoryEntry* parent /*= nullptr*/, const StringRef& outDir /*= StringRef::Empty*/) const
{
	auto* fileEntry = FindFile(path, parent);
	RETURN_FALSE_IF_NULL(fileEntry);
	return fileEntry->Extract(outDir);
}
Ejemplo n.º 30
0
bool FileStorage::RemoveAll(const StringRef& path, DirectoryEntry* parent /*= nullptr*/)
{
	parent = FindDirectory(path, parent);
	RETURN_FALSE_IF_NULL(parent);
	return RemoveAll(*parent);
}