示例#1
0
bool ZVehicle::CanBeRepaired()
{
	if(IsDestroyed()) return false;
	if(health >= max_health) return false;

	return true;
}
示例#2
0
bool ZMannedObject::CanBeEntered() {
	if (owner != NULL_TEAM || IsDestroyed()) {
		return false;
	}

	return true;
}
void*
PluginWidgetProxy::GetNativeData(uint32_t aDataType)
{
  if (!mActor) {
    return nullptr;
  }
  auto tab = static_cast<mozilla::dom::TabChild*>(mActor->Manager());
  if (tab && tab->IsDestroyed()) {
    return nullptr;
  }
  switch (aDataType) {
    case NS_NATIVE_PLUGIN_PORT:
    case NS_NATIVE_WINDOW:
    case NS_NATIVE_SHAREABLE_WINDOW:
      break;
    default:
      NS_WARNING("PluginWidgetProxy::GetNativeData received request for unsupported data type.");
      return nullptr;
  }
  // The parent side window handle or xid never changes so we can
  // cache this for our lifetime.
  if (mCachedPluginPort) {
    return (void*)mCachedPluginPort;
  }
  mActor->SendGetNativePluginPort(&mCachedPluginPort);
  PWLOG("PluginWidgetProxy::GetNativeData %p\n", (void*)mCachedPluginPort);
  return (void*)mCachedPluginPort;
}
示例#4
0
/**
 * @param aCOMProxy COM Proxy to the document in the content process.
 */
void
DocAccessibleParent::SendParentCOMProxy()
{
  // Make sure that we're not racing with a tab shutdown
  auto tab = static_cast<dom::TabParent*>(Manager());
  MOZ_ASSERT(tab);
  if (tab->IsDestroyed()) {
    return;
  }

  Accessible* outerDoc = OuterDocOfRemoteBrowser();
  if (!outerDoc) {
    return;
  }

  IAccessible* rawNative = nullptr;
  outerDoc->GetNativeInterface((void**) &rawNative);
  MOZ_ASSERT(rawNative);

  IAccessibleHolder::COMPtrType ptr(rawNative);
  IAccessibleHolder holder(Move(ptr));
  if (!PDocAccessibleParent::SendParentCOMProxy(holder)) {
    return;
  }

#if defined(MOZ_CONTENT_SANDBOX)
  mParentProxyStream = Move(holder.GetPreservedStream());
#endif // defined(MOZ_CONTENT_SANDBOX)
}
示例#5
0
void cPickup::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
	super::Tick(a_Dt, a_Chunk);
	BroadcastMovementUpdate();  // Notify clients of position

	m_Timer += a_Dt;
	
	if (!m_bCollected)
	{
		int BlockY = POSY_TOINT;
		int BlockX = POSX_TOINT;
		int BlockZ = POSZ_TOINT;

		if ((BlockY >= 0) && (BlockY < cChunkDef::Height))  // Don't do anything except for falling when outside the world
		{
			// Position might have changed due to physics. So we have to make sure we have the correct chunk.
			GET_AND_VERIFY_CURRENT_CHUNK(CurrentChunk, BlockX, BlockZ)
			
			int RelBlockX = BlockX - (CurrentChunk->GetPosX() * cChunkDef::Width);
			int RelBlockZ = BlockZ - (CurrentChunk->GetPosZ() * cChunkDef::Width);
				
			// If the pickup is on the bottommost block position, make it think the void is made of air: (#131)
			BLOCKTYPE BlockBelow = (BlockY > 0) ? CurrentChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR;
			BLOCKTYPE BlockIn = CurrentChunk->GetBlock(RelBlockX, BlockY, RelBlockZ);

			if (
				IsBlockLava(BlockBelow) || (BlockBelow == E_BLOCK_FIRE) ||
				IsBlockLava(BlockIn) || (BlockIn == E_BLOCK_FIRE)
			)
			{
				m_bCollected = true;
				m_Timer = std::chrono::milliseconds(0);  // We have to reset the timer.
				m_Timer += a_Dt;  // In case we have to destroy the pickup in the same tick.
				if (m_Timer > std::chrono::milliseconds(500))
				{
					Destroy(true);
					return;
				}
			}

			// Try to combine the pickup with adjacent same-item pickups:
			if (!IsDestroyed() && (m_Item.m_ItemCount < m_Item.GetMaxStackSize()))  // Don't combine if already full
			{
				// By using a_Chunk's ForEachEntity() instead of cWorld's, pickups don't combine across chunk boundaries.
				// That is a small price to pay for not having to traverse the entire world for each entity.
				// The speedup in the tick thread is quite considerable.
				cPickupCombiningCallback PickupCombiningCallback(GetPosition(), this);
				a_Chunk.ForEachEntity(PickupCombiningCallback);
				if (PickupCombiningCallback.FoundMatchingPickup())
				{
					m_World->BroadcastEntityMetadata(*this);
				}
			}
		}
示例#6
0
void BaseEntity::BaseEntity_Impl::Update(BaseEntity* ent, const UpdateContext& updateContext)
{
    if (IsDestroyed())
        return;

    for (auto component : _components)
    {
        component->Update(updateContext);
    }

    ent->OnUpdate(updateContext);
}
// Called by the proxy widget when it is destroyed by layout. Only gets
// called once.
void
PluginWidgetChild::ProxyShutdown()
{
  PWLOG("PluginWidgetChild::ProxyShutdown()\n");
  if (mWidget) {
    mWidget = nullptr;
    auto tab = static_cast<mozilla::dom::TabChild*>(Manager());
    if (!tab->IsDestroyed()) {
      Unused << Send__delete__(this);
    }
  }
}
示例#8
0
void Enemy::Damage( int damage, bool magic, Player* source ) {
    _hp -= std::max( damage, 0 );
    if ( damage > 0 )
        PlaySoundRandom( Lib::SOUND_ENEMY_HIT );

    if ( _hp <= 0 && !IsDestroyed() ) {
        PlaySoundRandom( _destroySound );
        if ( source && GetScore() > 0 )
            source->AddScore( GetScore() );
        if ( _explodeOnDestroy )
            Explosion();
        else
            Explosion( 0, 4, true, Vec2f( GetPosition() ) );
        OnDestroy( damage >= Player::BOMB_DAMAGE );
        Destroy();
    } else if ( !IsDestroyed() ) {
        if ( damage > 0 )
            PlaySoundRandom( Lib::SOUND_ENEMY_HIT );
        _damaged = damage >= Player::BOMB_DAMAGE ? 25 : 1;
    }
}
示例#9
0
// WARNING: recursive
void
SceneNode::CheckNodeCollision(
    SceneNode& node,
    std::set<Pair>& collisionPairs
) {
    // TODO: put this complex condition into function
    if ( this != &node && Collision( *this, node ) && !IsDestroyed() && !node.IsDestroyed() ) {
        collisionPairs.insert( std::minmax( this, &node ) );
    }
    for( Ptr& child : mChildren ) {
        child->CheckNodeCollision( node, collisionPairs );
    }
}
示例#10
0
void
LayerManagerD3D10::Destroy()
{
  if (!IsDestroyed()) {
    if (mRoot) {
      static_cast<LayerD3D10*>(mRoot->ImplData())->LayerManagerDestroyed();
    }
    mRootForShadowTree = nsnull;
    // XXX need to be careful here about surface destruction
    // racing with share-to-chrome message
  }
  LayerManager::Destroy();
}
示例#11
0
文件: Pickup.cpp 项目: Dam63/MCServer
void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
{
	super::Tick(a_Dt, a_Chunk);
	BroadcastMovementUpdate(); //Notify clients of position

	m_Timer += a_Dt;
	
	if (!m_bCollected)
	{
		int BlockY = POSY_TOINT;
		int BlockX = POSX_TOINT;
		int BlockZ = POSZ_TOINT;

		if ((BlockY >= 0) && (BlockY < cChunkDef::Height))  // Don't do anything except for falling when outside the world
		{
			// Position might have changed due to physics. So we have to make sure we have the correct chunk.
			GET_AND_VERIFY_CURRENT_CHUNK(CurrentChunk, BlockX, BlockZ)
			
			int RelBlockX = BlockX - (CurrentChunk->GetPosX() * cChunkDef::Width);
			int RelBlockZ = BlockZ - (CurrentChunk->GetPosZ() * cChunkDef::Width);
				
			// If the pickup is on the bottommost block position, make it think the void is made of air: (#131)
			BLOCKTYPE BlockBelow = (BlockY > 0) ? CurrentChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR;
			BLOCKTYPE BlockIn = CurrentChunk->GetBlock(RelBlockX, BlockY, RelBlockZ);

			if (
				IsBlockLava(BlockBelow) || (BlockBelow == E_BLOCK_FIRE) ||
				IsBlockLava(BlockIn) || (BlockIn == E_BLOCK_FIRE)
			)
			{
				m_bCollected = true;
				m_Timer = 0;  // We have to reset the timer.
				m_Timer += a_Dt;  // In case we have to destroy the pickup in the same tick.
				if (m_Timer > 500.f)  
				{
					Destroy(true);
					return;
				}
			}

			if (!IsDestroyed()) // Don't try to combine if someone has tried to combine me
			{
				cPickupCombiningCallback PickupCombiningCallback(GetPosition(), this);
				m_World->ForEachEntity(PickupCombiningCallback); // Not ForEachEntityInChunk, otherwise pickups don't combine across chunk boundaries
				if (PickupCombiningCallback.FoundMatchingPickup())
				{
					m_World->BroadcastEntityMetadata(*this);
				}
			}
		}
mozilla::ipc::IPCResult
DocAccessibleParent::RecvShutdown()
{
  Destroy();

  auto mgr = static_cast<dom::TabParent*>(Manager());
  if (!mgr->IsDestroyed()) {
    if (!PDocAccessibleParent::Send__delete__(this)) {
      return IPC_FAIL_NO_REASON(mgr);
    }
  }

  return IPC_OK();
}
void
LayerManagerD3D9::Destroy()
{
  if (!IsDestroyed()) {
    if (mRoot) {
      static_cast<LayerD3D9*>(mRoot->ImplData())->LayerManagerDestroyed();
    }
    /* Important to release this first since it also holds a reference to the
     * device manager
     */
    mSwapChain = nullptr;
    mDeviceManager = nullptr;
  }
  LayerManager::Destroy();
}
示例#14
0
void BaseEntity::BaseEntity_Impl::Render(BaseEntity* ent, const UpdateContext& updateContext)
{
    if (IsDestroyed())
        return;

    for (auto component : _components)
        component->PreRender(updateContext);

    for (auto component : _components)
        component->Render(updateContext);

    for (auto component : _components)
        component->PostRender(updateContext);

    ent->OnRender(updateContext);
};
示例#15
0
void CGunTurret::FullSerialize(TSerialize ser)
{
	CWeapon::FullSerialize(ser);

	ser.BeginGroup("GunTurret");
	ser.Value("target", m_targetId);
	ser.EndGroup();

	if(ser.IsReading())
	{
		if(!IsDestroyed())
		{
			if(IGameObject *pGameObject = GetGameObject())
				PostInit(pGameObject);
		}
	}
}
示例#16
0
文件: task.cpp 项目: andreev3344/samp
void CTask::Destroy()
{
	if (!IsDestroyed())
	{
		BYTE *pTaskType = m_pTaskType;
		if (m_bSelfCreated)
		{
			__asm
			{
				push ecx;
				mov ecx, pTaskType;
				mov eax, [ecx];
				push 0;		// remove from pool?
				call [eax+0];
				pop ecx;
			}
		}
		else
		{
示例#17
0
void
PluginWidgetProxy::SetNativeData(uint32_t aDataType, uintptr_t aVal)
{
  if (!mActor) {
    return;
  }

  auto tab = static_cast<mozilla::dom::TabChild*>(mActor->Manager());
  if (tab && tab->IsDestroyed()) {
    return;
  }

  switch (aDataType) {
    case NS_NATIVE_CHILD_WINDOW:
      mActor->SendSetNativeChildWindow(aVal);
      break;
    default:
      NS_ERROR("SetNativeData called with unsupported data type.");
  }
}
示例#18
0
/// <summary>
///	ProcessDestroyed is a "delayed" destruction of entities
///	This allows for us to mark entities for deletion and
///	delete them in one pass.
///
///	More importantly, it allows us to safely traverse
///	the entity pool when do Updates, Render, and Tick.
///	A common scenario is when one entity (A) is destroyed while we're
///	traversing the entity pool, but another entity (B) in the pool is
///	still referencing that entity (A). This solves that problem.
///
///	Users should never need to explicitly delete entities themselves.
/// </summary>
void EntityManager::EntityManager_Impl::ProcessDestroyed()
{
    const int entity_pool_count = _entity_pool.size();
    auto entity_pool_begin = _entity_pool.begin();

    for (int i = entity_pool_count - 1; i >= 0; --i)
    {
        auto entity = _entity_pool.at(i);

        if (entity)
        {
            if (entity->IsDestroyed())
            {
                entity->OnDestroying();
                delete entity;
                entity = NULL;
                _entity_pool.erase(entity_pool_begin + i);
            }
        }
    }
}
/**
 * @param aCOMProxy COM Proxy to the document in the content process.
 */
void
DocAccessibleParent::SendParentCOMProxy()
{
  // Make sure that we're not racing with a tab shutdown
  auto tab = static_cast<dom::TabParent*>(Manager());
  MOZ_ASSERT(tab);
  if (tab->IsDestroyed()) {
    return;
  }

  Accessible* outerDoc = OuterDocOfRemoteBrowser();
  if (!outerDoc) {
    return;
  }

  IAccessible* rawNative = nullptr;
  outerDoc->GetNativeInterface((void**) &rawNative);
  MOZ_ASSERT(rawNative);

  IAccessibleHolder::COMPtrType ptr(rawNative);
  IAccessibleHolder holder(Move(ptr));
  Unused << PDocAccessibleParent::SendParentCOMProxy(holder);
}
示例#20
0
void*
PluginWidgetProxy::GetNativeData(uint32_t aDataType)
{
  if (!mActor) {
    return nullptr;
  }
  auto tab = static_cast<mozilla::dom::TabChild*>(mActor->Manager());
  if (tab && tab->IsDestroyed()) {
    return nullptr;
  }
  switch (aDataType) {
    case NS_NATIVE_PLUGIN_PORT:
    case NS_NATIVE_WINDOW:
    case NS_NATIVE_SHAREABLE_WINDOW:
      break;
    default:
      NS_WARNING("PluginWidgetProxy::GetNativeData received request for unsupported data type.");
      return nullptr;
  }
  uintptr_t value = 0;
  mActor->SendGetNativePluginPort(&value);
  PWLOG("PluginWidgetProxy::GetNativeData %p\n", (void*)value);
  return (void*)value;
}
bool GLWindow::Create()
{
    assert ( !IsDestroyed() );
    assert ( IsDisposed() );

    XVisualInfo *vi;
    Colormap cmap;
    int dpyWidth, dpyHeight;
    int i;
    int glxMajorVersion, glxMinorVersion;
    int vidModeMajorVersion, vidModeMinorVersion;
    XF86VidModeModeInfo **modes;
    int modeNum;
    int bestMode;
    Atom wmDelete;
    Window winDummy;
    unsigned int borderDummy;

    /* set best mode to current */
    bestMode = 0;
    /* get a connection */
    hDC = XOpenDisplay(0);
    screen = DefaultScreen(hDC);
    XF86VidModeQueryVersion(hDC, &vidModeMajorVersion, &vidModeMinorVersion);
    printf("XF86VidModeExtension-Version %d.%d\n", vidModeMajorVersion,
        vidModeMinorVersion);
    XF86VidModeGetAllModeLines(hDC, screen, &modeNum, &modes);
    /* save desktop-resolution before switching modes */
    deskMode = *modes[0];
    /* look for mode with requested resolution */
    for (i = 0; i < modeNum; i++)
        if ((modes[i]->hdisplay == Width) && (modes[i]->vdisplay == Height))
            bestMode = i;
    /* get an appropriate visual */
    vi = glXChooseVisual(hDC, screen, attrListDbl);
    if (vi == NULL)
    {
        vi = glXChooseVisual(hDC, screen, attrListSgl);
        printf("Only Singlebuffered Visual!\n");
    }
    else
        printf("Got Doublebuffered Visual!\n");
    glXQueryVersion(hDC, &glxMajorVersion, &glxMinorVersion);
    printf("glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion);
    /* create a GLX context */
    glctx = glXCreateContext(hDC, vi, 0, GL_TRUE);
    /* create a color map */
    cmap = XCreateColormap(hDC, RootWindow(hDC, vi->screen),
        vi->visual, AllocNone);
    attr.colormap = cmap;
    attr.border_pixel = 0;

    if (FL_fullscreen)
    {
        XF86VidModeSwitchToMode(hDC, screen, modes[bestMode]);
        XF86VidModeSetViewPort(hDC, screen, 0, 0);
        dpyWidth = modes[bestMode]->hdisplay;
        dpyHeight = modes[bestMode]->vdisplay;
        printf("Resolution %dx%d\n", dpyWidth, dpyHeight);
        XFree(modes);

        /* create a fullscreen window */
        attr.override_redirect = True;
        attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
            FocusChangeMask | EnterWindowMask | StructureNotifyMask;
        win = XCreateWindow(hDC, RootWindow(hDC, vi->screen),
            0, 0, dpyWidth, dpyHeight, 0, vi->depth, InputOutput, vi->visual,
            CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect,
            &attr);
        XWarpPointer(hDC, None, win, 0, 0, 0, 0, 0, 0);
        XMapRaised(hDC, win);
        XGrabKeyboard(hDC, win, True, GrabModeAsync,
            GrabModeAsync, CurrentTime);
        XGrabPointer(hDC, win, True, ButtonPressMask,
            GrabModeAsync, GrabModeAsync, win, None, CurrentTime);
    }
    else
    {
        /* create a window in window mode*/
        attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
            PointerMotionMask | FocusChangeMask | StructureNotifyMask;
        win = XCreateWindow(hDC, RootWindow(hDC, vi->screen),
            0, 0, Width, Height, 0, vi->depth, InputOutput, vi->visual,
            CWBorderPixel | CWColormap | CWEventMask, &attr);
        /* only set window title and handle wm_delete_events if in windowed mode */
        wmDelete = XInternAtom(hDC, "WM_DELETE_WINDOW", True);
        XSetWMProtocols(hDC, win, &wmDelete, 1);
        XSetStandardProperties(hDC, win, Title,
            Title, None, NULL, 0, NULL);
        XMapRaised(hDC, win);
    }
    /* connect the glx-context to the window */
    glXMakeCurrent(hDC, win, glctx);
    XGetGeometry(hDC, win, &winDummy, &x, &y,
        &Width, &Height, &borderDummy, &depth);
    printf("Depth %d\n", depth);
    if (glXIsDirect(hDC, glctx))
        printf("Congrats, you have Direct Rendering!\n");
    else
        printf("Sorry, no Direct Rendering possible!\n");

    OnCreate();
    this->Resize(Width, Height);

    return true;
}
示例#22
0
//------------------------------------------------------------------------
bool CGunTurret::NetSerialize(TSerialize ser, EEntityAspects aspect, uint8 profile, int flags)
{
	// call base class
	if(!CWeapon::NetSerialize(ser, aspect, profile, flags))
		return false;

	if(aspect == ASPECT_STATEBITS)
	{
		bool was_destroyed = IsDestroyed();
		bool destr=was_destroyed;
		ser.Value("destroyed",destr,'bool');

		if(ser.IsReading() && destr != was_destroyed)
		{
			if(destr)
				OnDestroyed();
			else
			{
				OnRepaired();
			}
		}

		bool enabled = m_turretparams.enabled;
		ser.Value("enabled",m_turretparams.enabled,'bool');

		if(ser.IsReading() && enabled != m_turretparams.enabled)
			Activate(m_turretparams.enabled);

		ser.Value("health", m_stats.health, 'iii');

		if(ser.IsReading())
			UpdateDamageLevel();
	}

	if(aspect == ASPECT_GOALORIENTATION)
	{
		//adjust the range
		if(ser.IsReading())
		{
			float yaw = 0.f;
			ser.Value("target_yaw",yaw, 'frad');
			m_goalYaw = yaw<0.0f?yaw + gf_PI2:yaw;
		}
		else
		{
			float yaw = m_goalYaw>gf_PI?m_goalYaw - gf_PI2:m_goalYaw;
			ser.Value("target_yaw",yaw, 'frad');
		}

		ser.Value("target_pitch",m_goalPitch, 'frad');

		EntityId old_id = m_targetId;
		ser.Value("target", m_targetId, 'eid');

		if(old_id != m_targetId)
		{
			OnTargetLocked(m_targetId ? gEnv->pEntitySystem->GetEntity(m_targetId) : 0);
		}

		if(m_fireparams.deviation_amount != 0.f)
			ser.Value("deviation", m_deviationPos);
	}

	return true;
}
示例#23
0
//------------------------------------------------------------------------
void CGunTurret::Activate(bool active)
{
	if(!IsDestroyed())
		PlayAction(active ? g_pItemStrings->activate : g_pItemStrings->deactivate);
}
示例#24
0
bool
SceneNode::IsMarkedForRemoval() const {
    return IsDestroyed();
}
示例#25
0
void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
{
	super::Tick(a_Dt, a_Chunk);
	BroadcastMovementUpdate(); //Notify clients of position

	m_Timer += a_Dt;
	
	if (!m_bCollected)
	{
		int BlockY = (int) floor(GetPosY());
		if ((BlockY >= 0) && (BlockY < cChunkDef::Height))  // Don't do anything except for falling when outside the world
		{
			int BlockX = (int) floor(GetPosX());
			int BlockZ = (int) floor(GetPosZ());
			// Position might have changed due to physics. So we have to make sure we have the correct chunk.
			cChunk * CurrentChunk = a_Chunk.GetNeighborChunk(BlockX, BlockZ);
			if (CurrentChunk != NULL)  // Make sure the chunk is loaded
			{
				int RelBlockX = BlockX - (CurrentChunk->GetPosX() * cChunkDef::Width);
				int RelBlockZ = BlockZ - (CurrentChunk->GetPosZ() * cChunkDef::Width);
				
				// If the pickup is on the bottommost block position, make it think the void is made of air: (#131)
				BLOCKTYPE BlockBelow = (BlockY > 0) ? CurrentChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR;
				BLOCKTYPE BlockIn = CurrentChunk->GetBlock(RelBlockX, BlockY, RelBlockZ);

				if (
					IsBlockLava(BlockBelow) || (BlockBelow == E_BLOCK_FIRE) ||
					IsBlockLava(BlockIn) || (BlockIn == E_BLOCK_FIRE)
				)
				{
					m_bCollected = true;
					m_Timer = 0;  // We have to reset the timer.
					m_Timer += a_Dt;  // In case we have to destroy the pickup in the same tick.
					if (m_Timer > 500.f)  
					{
						Destroy(true);
						return;
					}
				}

				if (!IsDestroyed()) // Don't try to combine if someone has tried to combine me
				{
					cPickupCombiningCallback PickupCombiningCallback(GetPosition(), this);
					m_World->ForEachEntity(PickupCombiningCallback); // Not ForEachEntityInChunk, otherwise pickups don't combine across chunk boundaries
					if (PickupCombiningCallback.FoundMatchingPickup())
					{
						m_World->BroadcastEntityMetadata(*this);
					}
				}
			}
		}
	}
	else
	{
		if (m_Timer > 500.f)  // 0.5 second
		{
			Destroy(true);
			return;
		}
	}

	if (m_Timer > 1000 * 60 * 5)  // 5 minutes
	{
		Destroy(true);
		return;
	}

	if (GetPosY() < -8) // Out of this world and no more visible!
	{
		Destroy(true);
		return;
	}
}
示例#26
0
void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
{
    if (IsDestroyed())  // Mainly to stop detector rails triggering again after minecart is dead
    {
        return;
    }

    int PosY = POSY_TOINT;
    if ((PosY <= 0) || (PosY >= cChunkDef::Height))
    {
        // Outside the world, just process normal falling physics
        super::HandlePhysics(a_Dt, a_Chunk);
        BroadcastMovementUpdate();
        return;
    }

    int RelPosX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width;
    int RelPosZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width;
    cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ);
    if (Chunk == NULL)
    {
        // Inside an unloaded chunk, bail out all processing
        return;
    }

    BLOCKTYPE InsideType;
    NIBBLETYPE InsideMeta;
    Chunk->GetBlockTypeMeta(RelPosX, PosY, RelPosZ, InsideType, InsideMeta);

    if (!IsBlockRail(InsideType))
    {
        Chunk->GetBlockTypeMeta(RelPosX, PosY + 1, RelPosZ, InsideType, InsideMeta);  // When an descending minecart hits a flat rail, it goes through the ground; check for this
        if (IsBlockRail(InsideType)) AddPosY(1);  // Push cart upwards
    }

    bool WasDetectorRail = false;
    if (IsBlockRail(InsideType))
    {
        if (InsideType == E_BLOCK_RAIL)
        {
            SnapToRail(InsideMeta);
        }
        else
        {
            SnapToRail(InsideMeta & 0x07);
        }

        switch (InsideType)
        {
        case E_BLOCK_RAIL:
            HandleRailPhysics(InsideMeta, a_Dt);
            break;
        case E_BLOCK_ACTIVATOR_RAIL:
            break;
        case E_BLOCK_POWERED_RAIL:
            HandlePoweredRailPhysics(InsideMeta);
            break;
        case E_BLOCK_DETECTOR_RAIL:
        {
            HandleDetectorRailPhysics(InsideMeta, a_Dt);
            WasDetectorRail = true;
            break;
        }
        default:
            VERIFY(!"Unhandled rail type despite checking if block was rail!");
            break;
        }

        AddPosition(GetSpeed() * (a_Dt / 1000));  // Commit changes; as we use our own engine when on rails, this needs to be done, whereas it is normally in Entity.cpp
    }
    else
    {
        // Not on rail, default physics
        SetPosY(floor(GetPosY()) + 0.35);  // HandlePhysics overrides this if minecart can fall, else, it is to stop ground clipping minecart bottom when off-rail
        super::HandlePhysics(a_Dt, *Chunk);
    }

    if (m_bIsOnDetectorRail && !Vector3i(POSX_TOINT, POSY_TOINT, POSZ_TOINT).Equals(m_DetectorRailPosition))
    {
        m_World->SetBlock(m_DetectorRailPosition.x, m_DetectorRailPosition.y, m_DetectorRailPosition.z, E_BLOCK_DETECTOR_RAIL, m_World->GetBlockMeta(m_DetectorRailPosition) & 0x07);
        m_bIsOnDetectorRail = false;
    }
    else if (WasDetectorRail)
    {
        m_bIsOnDetectorRail = true;
        m_DetectorRailPosition = Vector3i(POSX_TOINT, POSY_TOINT, POSZ_TOINT);
    }

    // Broadcast positioning changes to client
    BroadcastMovementUpdate();
}
示例#27
0
//------------------------------------------------------------------------
bool CGunTurret::IsOperational()
{
	return !IsDestroyed() && m_turretparams.enabled && g_pGameCVars->i_auto_turret_target!=0 && !(gEnv->IsEditor() && g_pGame->GetIGameFramework()->IsEditing());
}