Beispiel #1
0
/**
 * フロントバッファへサーフェイスを転送する。
 * DeviceLockを得ている必要がある。
 */
jcboolean Device::postFrontBuffer() {
    if (hasFlags(DeviceFlag_RequestDestroy)) {
        return jcfalse;
    }

    return egl->postFrontBuffer(surface);
}
//-------------------------------------------------------------------------------------
float EntityCoordinateNode::xx() const
{
	if (pEntity_ == NULL || hasFlags((COORDINATE_NODE_FLAG_REMOVED | COORDINATE_NODE_FLAG_REMOVEING)))
		return -FLT_MAX;

	return pEntity_->position().x;
}
Beispiel #3
0
/**
 * EGLの関連付けを設定し直す。
 */
jcboolean Device::makeCurrent(EGLMakeCurrent_e type) {
    switch (type) {
        case EGLMakeCurrent_Bind:
            // 廃棄フラグが設定されているなら、カレントに設定できない
            if (hasFlags(DeviceFlag_RequestDestroy)) {
                jclog("has destroy flag");
                return jcfalse;
            }

            // 既に廃棄済みでもカレントにできない
            if (context.get() == NULL || surface.get() == NULL) {
                jclogf("error context(%x) || surface(%x)", context.get(), surface.get());
                return jcfalse;
            }
            egl->current(context, surface);

            // 現在のスレッドIDに割り当てる
            threadId.reset(new ThreadID());
            return jctrue;
        case EGLMakeCurrent_Unbind:
            egl->current(EGL_NULL_CONTEXT, EGL_NULL_SURFACE);

            // スレッドIDを廃棄する
            threadId.reset();
            return jctrue;
    }
    return jcfalse;
}
//-------------------------------------------------------------------------------------
void EntityCoordinateNode::clearDelWatcherNodes()
{
	if (hasFlags((COORDINATE_NODE_FLAG_ENTITY_NODE_UPDATING | COORDINATE_NODE_FLAG_REMOVED | COORDINATE_NODE_FLAG_REMOVEING)))
		return;

	if (delWatcherNodeNum_ > 0)
	{
		std::vector<CoordinateNode*>::iterator iter = watcherNodes_.begin();
		for (; iter != watcherNodes_.end();)
		{
			if (!(*iter))
			{
				iter = watcherNodes_.erase(iter);
				--delWatcherNodeNum_;

				if (delWatcherNodeNum_ <= 0)
					return;
			}
			else
			{
				++iter;
			}
		}
	}
}
Beispiel #5
0
//-------------------------------------------------------------------------------------
float RangeTriggerNode::zz() const 
{
	if (hasFlags(COORDINATE_NODE_FLAG_REMOVED | COORDINATE_NODE_FLAG_REMOVING) || pRangeTrigger_ == NULL)
		return -FLT_MAX;

	return pRangeTrigger_->origin()->zz() + range_xz_; 
}
//-------------------------------------------------------------------------------------
float RangeTriggerNode::yy() const 
{
	if (hasFlags(COORDINATE_NODE_FLAG_REMOVED) || pRangeTrigger_ == NULL)
		return -FLT_MAX;

	return pRangeTrigger_->origin()->yy() + range_y_; 
}
Beispiel #7
0
//-------------------------------------------------------------------------------------
PyObject* Proxy::pyClientAddr()
{ 
	if (!hasFlags(ENTITY_FLAGS_DESTROYING) && isDestroyed())
	{
		PyErr_Format(PyExc_AssertionError, "%s: %d is destroyed!\n",		
			scriptName(), id());		
		PyErr_PrintEx(0);
		return 0;																				
	}

	PyObject* pyobj = PyTuple_New(2);

	if(clientMailbox() == NULL || clientMailbox()->getChannel() == NULL || 
		clientMailbox()->getChannel()->pEndPoint() == NULL)
	{
		PyTuple_SetItem(pyobj, 0, PyLong_FromLong(0));
		PyTuple_SetItem(pyobj, 1, PyLong_FromLong(0));
	}
	else
	{
		const Network::Address& addr = clientMailbox()->getChannel()->pEndPoint()->addr();
		PyTuple_SetItem(pyobj, 0, PyLong_FromUnsignedLong(addr.ip));
		PyTuple_SetItem(pyobj, 1, PyLong_FromUnsignedLong(addr.port));
	}

	return pyobj;
}
Beispiel #8
0
//-------------------------------------------------------------------------------------
PyObject* Proxy::pyGetTimeSinceHeardFromClient()
{ 
	if (!hasFlags(ENTITY_FLAGS_DESTROYING) && isDestroyed())
	{
		PyErr_Format(PyExc_AssertionError, "%s: %d is destroyed!\n",		
			scriptName(), id());		
		PyErr_PrintEx(0);
		return 0;																					
	}
	
	return PyFloat_FromDouble(this->getTimeSinceHeardFromClient()); 
}
Beispiel #9
0
//-------------------------------------------------------------------------------------
PyObject* Proxy::pyGetEntitiesEnabled()
{ 
	if (!hasFlags(ENTITY_FLAGS_DESTROYING) && isDestroyed())
	{
		PyErr_Format(PyExc_AssertionError, "%s: %d is destroyed!\n",		
			scriptName(), id());		
		PyErr_PrintEx(0);
		return 0;																				
	}

	if(this->entitiesEnabled())
	{
		Py_RETURN_TRUE;
	}

	Py_RETURN_FALSE;
}
//-------------------------------------------------------------------------------------
bool EntityCoordinateNode::delWatcherNode(CoordinateNode* pNode)
{
	std::vector<CoordinateNode*>::iterator iter = std::find(watcherNodes_.begin(), watcherNodes_.end(), pNode);
	if(iter == watcherNodes_.end())
		return false;

	if (hasFlags((COORDINATE_NODE_FLAG_ENTITY_NODE_UPDATING | COORDINATE_NODE_FLAG_REMOVED | COORDINATE_NODE_FLAG_REMOVEING)))
	{
		(*iter) = NULL;
		++delWatcherNodeNum_;
	}
	else
	{
		watcherNodes_.erase(iter);
	}

	return true;
}
Beispiel #11
0
bool Hurtable::hurt(int d)
{
    if (hasFlags(EntityFlags::INVUNERABLE) || hurtFlash > 0.f)
        return false;

    if (tmd->isAnimated() && tmd->hasAnimation("hurt"))
    {
        anim.play("hurt", [&]()
        {
            anim.play("idle");
        });
    }
    else
    {
        hurtFlash = 0.14f;
    }

    setHealth(getHealth() - d);
    onHurt(d);

    return true;
}
bool UserActionElementSet::hasFlags(const Node* node, unsigned flags) const
{
    DCHECK(node->isUserActionElement() && node->isElementNode());
    return hasFlags(toElement(node), flags);
}
//-------------------------------------------------------------------------------------
void RangeTriggerNode::onNodePassZ(CoordinateNode* pNode, bool isfront)
{
	if (!hasFlags(COORDINATE_NODE_FLAG_REMOVED) && pRangeTrigger_)
		pRangeTrigger_->onNodePassZ(this, pNode, isfront);
}