void Bomb::OnBeforeUpdate() { World& world = World::GetInstance(); Actor collisionFire; if(world.GetFireManager()->IsColliding(*this, &collisionFire)) { SetLifeSpan(0); } if(CanDelete() && CanTriggerExplosion()) { std::shared_ptr<BombExplodedEvent> bombExplosionEvent(new BombExplodedEvent(GetId(), m_position)); world.GetEventManager()->QueueEvent(bombExplosionEvent); m_bCanTriggerExplosion = false; } if(CanRenderNextFrame()) { m_animation.NextFrame(); m_nextFrameWait = BOMB_NEXTFRAME_WAIT; } else { m_nextFrameWait = std::max<uint32_t>(0, m_nextFrameWait - 1); } }
void ezQtPropertyPointerWidget::SetSelection(const ezHybridArray<ezPropertySelection, 8>& items) { ezQtScopedUpdatesDisabled _(this); ezQtPropertyWidget::SetSelection(items); if (m_pTypeWidget) { m_pGroupLayout->removeWidget(m_pTypeWidget); delete m_pTypeWidget; m_pTypeWidget = nullptr; } ezHybridArray<ezPropertySelection, 8> emptyItems; ezHybridArray<ezPropertySelection, 8> subItems; for (const auto& item : m_Items) { ezUuid ObjectGuid = m_pObjectAccessor->Get<ezUuid>(item.m_pObject, m_pProp, item.m_Index); if (!ObjectGuid.IsValid()) { emptyItems.PushBack(item); } else { ezPropertySelection sel; sel.m_pObject = m_pObjectAccessor->GetObject(ObjectGuid); subItems.PushBack(sel); } } auto pAttr = m_pProp->GetAttributeByType<ezContainerAttribute>(); if (!pAttr || pAttr->CanAdd()) m_pAddButton->setVisible(!emptyItems.IsEmpty()); if (!pAttr || pAttr->CanDelete()) m_pDeleteButton->setVisible(!subItems.IsEmpty()); if (!emptyItems.IsEmpty()) { m_pAddButton->SetSelection(emptyItems); } if (!subItems.IsEmpty()) { const ezRTTI* pCommonType = ezQtPropertyWidget::GetCommonBaseType(subItems); m_pTypeWidget = new ezQtTypeWidget(m_pGroup->GetContent(), m_pGrid, m_pObjectAccessor, pCommonType, nullptr, nullptr); m_pTypeWidget->SetSelection(subItems); m_pGroupLayout->addWidget(m_pTypeWidget); } }
ezQtPropertyContainerWidget::Element& ezQtPropertyContainerWidget::AddElement(ezUInt32 index) { ezQtGroupBoxBase* pSubGroup = CreateElement(m_pGroup); pSubGroup->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu); connect(pSubGroup, &ezQtGroupBoxBase::CollapseStateChanged, m_pGrid, &ezQtPropertyGridWidget::OnCollapseStateChanged); connect(pSubGroup, &QWidget::customContextMenuRequested, this, &ezQtPropertyContainerWidget::OnCustomElementContextMenu); QVBoxLayout* pSubLayout = new QVBoxLayout(nullptr); pSubLayout->setContentsMargins(5, 0, 0, 0); pSubLayout->setSpacing(1); pSubGroup->GetContent()->setLayout(pSubLayout); m_pGroupLayout->insertWidget((int)index, pSubGroup); ezQtPropertyWidget* pNewWidget = CreateWidget(index); pNewWidget->setParent(pSubGroup); pSubLayout->addWidget(pNewWidget); pNewWidget->Init(m_pGrid, m_pObjectAccessor, m_pType, m_pProp); { // Add Buttons auto pAttr = m_pProp->GetAttributeByType<ezContainerAttribute>(); if ((!pAttr || pAttr->CanMove()) && m_pProp->GetCategory() != ezPropertyCategory::Map) { // Do we need move buttons at all if we have drag&drop? // ezQtElementGroupButton* pUpButton = new ezQtElementGroupButton(pSubGroup->GetHeader(), // ezQtElementGroupButton::ElementAction::MoveElementUp, pNewWidget); pSubGroup->GetHeader()->layout()->addWidget(pUpButton); // connect(pUpButton, &QToolButton::clicked, this, &ezQtPropertyContainerWidget::OnElementButtonClicked); // ezQtElementGroupButton* pDownButton = new ezQtElementGroupButton(pSubGroup->GetHeader(), // ezQtElementGroupButton::ElementAction::MoveElementDown, pNewWidget); pSubGroup->GetHeader()->layout()->addWidget(pDownButton); // connect(pDownButton, &QToolButton::clicked, this, &ezQtPropertyContainerWidget::OnElementButtonClicked); pSubGroup->SetDraggable(true); connect(pSubGroup, &ezQtGroupBoxBase::DragStarted, this, &ezQtPropertyContainerWidget::OnDragStarted); } if (!pAttr || pAttr->CanDelete()) { ezQtElementGroupButton* pDeleteButton = new ezQtElementGroupButton(pSubGroup->GetHeader(), ezQtElementGroupButton::ElementAction::DeleteElement, pNewWidget); pSubGroup->GetHeader()->layout()->addWidget(pDeleteButton); connect(pDeleteButton, &QToolButton::clicked, this, &ezQtPropertyContainerWidget::OnElementButtonClicked); } } m_Elements.Insert(Element(pSubGroup, pNewWidget), index); return m_Elements[index]; }
void ezQtPropertyPointerWidget::OnInit() { m_pGroup->SetTitle(ezTranslate(m_pProp->GetPropertyName())); m_pGrid->SetCollapseState(m_pGroup); connect(m_pGroup, &ezQtGroupBoxBase::CollapseStateChanged, m_pGrid, &ezQtPropertyGridWidget::OnCollapseStateChanged); // Add Buttons auto pAttr = m_pProp->GetAttributeByType<ezContainerAttribute>(); m_pAddButton->setVisible(!pAttr || pAttr->CanAdd()); m_pDeleteButton->setVisible(!pAttr || pAttr->CanDelete()); m_pAddButton->Init(m_pGrid, m_pObjectAccessor, m_pType, m_pProp); m_pGrid->GetDocument()->GetObjectManager()->m_StructureEvents.AddEventHandler( ezMakeDelegate(&ezQtPropertyPointerWidget::StructureEventHandler, this)); }
bool FAssetDeleteModel::DoDelete() { if ( !CanDelete() ) { return false; } TArray<UObject*> ObjectsToDelete; for ( TSharedPtr< FPendingDelete >& PendingDelete : PendingDeletes ) { ObjectsToDelete.Add( PendingDelete->GetObject() ); } ObjectsDeleted = ObjectTools::DeleteObjectsUnchecked(ObjectsToDelete); return true; }
void Fire::OnBeforeUpdate() { World& world = World::GetInstance(); if(CanDelete() && CanTriggerFireExtinguished()) { ActorId fireId = GetId(); std::shared_ptr<FireExtinguishedEvent> fireExtinguishedEvent = std::make_shared<FireExtinguishedEvent>(fireId, m_position); world.GetEventManager()->QueueEvent(fireExtinguishedEvent); m_bCanTriggerFireExtinguished = false; } if(CanRenderNextFrame()) { m_animation.NextFrame(); m_nextFrameWait = FIRE_NEXTFRAME_WAIT; } else { m_nextFrameWait = std::max<uint32_t>(0, m_nextFrameWait - 1); } }
bool wxGxOpenFileGDB::CanMove(const CPLString &szDestPath) { return CanCopy(szDestPath) & CanDelete(); }