void cbVike::Detach(cbStyledTextCtrl *p, bool deleteEvtHandler) { if (!p || !IsAttachedTo(p)) return; // this is not attached... LOGIT(wxT("wxKeyBinder::Detach - detaching from [%s] %p"), p->GetName().c_str(),p); // remove the event handler int idx = FindHandlerIdxFor(p); LOGIT(wxT("idx is %d"), idx); VikeEvtBinder *toremove = (VikeEvtBinder*)m_arrHandlers.Item(idx); m_arrHandlers.RemoveAt(idx, 1); // the wxBinderEvtHandler will remove itself from p's event handlers if (deleteEvtHandler) delete toremove; LOGIT(wxT("%d handlers left"), m_arrHandlers.GetCount()); }
// ---------------------------------------------------------------------------- void MouseSap::Attach(wxWindow *p) // ----------------------------------------------------------------------------{ { if (!p || IsAttachedTo(p)) return; // already attached !!! // allow only static windows to be attached by codeblocks // Disappearing frames/windows cause crashes // eg., wxArrayString m_UsableWindows = "sciwindow notebook"; wxString windowName = p->GetName().MakeLower(); if (wxNOT_FOUND == m_UsableWindows.Index(windowName,false)) { #if defined(LOGGING) LOGIT(wxT("MMSap::Attach skipping [%s]"), p->GetName().c_str()); #endif return; } #if defined(LOGGING) LOGIT(wxT("MMSap::Attach - attaching to [%s] %p"), p->GetName().c_str(),p); #endif //add window to our array, attach a mouse event handler m_EditorPtrs.Add(p); if ( not m_pMMSapEvents ) m_pMMSapEvents = new MMSapEvents(p); MMSapEvents* thisEvtHndlr = m_pMMSapEvents; p->Connect(wxEVT_MIDDLE_DOWN, (wxObjectEventFunction)(wxEventFunction) (wxMouseEventFunction)&MMSapEvents::OnMouseEvent, NULL, thisEvtHndlr); p->Connect(wxEVT_MIDDLE_UP, (wxObjectEventFunction)(wxEventFunction) (wxMouseEventFunction)&MMSapEvents::OnMouseEvent, NULL, thisEvtHndlr); p->Connect(wxEVT_KILL_FOCUS , (wxObjectEventFunction)(wxEventFunction) (wxFocusEventFunction)&MMSapEvents::OnKillFocusEvent, NULL, thisEvtHndlr); #if defined(LOGGING) LOGIT(_T("MMSap:Attach Window:%p Handler:%p"), p,thisEvtHndlr); #endif }
void cbVike::Attach(cbStyledTextCtrl *p, cbEditor *editor) { if(!p){ return; } // already attached !!! if(IsAttachedTo(p)){ ReAttach(p, editor); return; } // do not attach ourselves to temporary windows !! if (p->GetExtraStyle() & wxWS_EX_TRANSIENT) return; // create a new event handler for this window wxEvtHandler *h = new VikeEvtBinder(this, p, editor); m_arrHandlers.Add((void*)h); LOGIT(_T("Add wxEvtHandler %p for controller %p in editor %p"), h, p, editor); }
void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { std::vector<cEntityEffect *> EffectsToTick; // Iterate through this entity's applied effects for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();) { // Copies values to prevent pesky wrong accesses and erasures cEntityEffect::eType EffectType = iter->first; cEntityEffect * Effect = iter->second.get(); // Iterates (must be called before any possible erasure) ++iter; // Remove effect if duration has elapsed if (Effect->GetDuration() - Effect->GetTicks() <= 0) { RemoveEntityEffect(EffectType); } // Call OnTick later to make sure the iterator won't be invalid else { EffectsToTick.push_back(Effect); } // TODO: Check for discrepancies between client and server effect values } for (auto * Effect : EffectsToTick) { Effect->OnTick(*this); } // Spectators cannot push entities around if ((!IsPlayer()) || (!static_cast<cPlayer *>(this)->IsGameModeSpectator())) { m_World->ForEachEntityInBox(cBoundingBox(GetPosition(), GetWidth(), GetHeight()), [=](cEntity & a_Entity) { if (a_Entity.GetUniqueID() == GetUniqueID()) { return false; } // we only push other mobs, boats and minecarts if ((a_Entity.GetEntityType() != etMonster) && (a_Entity.GetEntityType() != etMinecart) && (a_Entity.GetEntityType() != etBoat)) { return false; } // do not push a boat / minecart you're sitting in if (IsAttachedTo(&a_Entity)) { return false; } Vector3d v3Delta = a_Entity.GetPosition() - GetPosition(); v3Delta.y = 0.0; // we only push sideways v3Delta *= 1.0 / (v3Delta.Length() + 0.01); // we push harder if we're close // QUESTION: is there an additional multiplier for this? current shoving seems a bit weak a_Entity.AddSpeed(v3Delta); return false; } ); } super::Tick(a_Dt, a_Chunk); if (!IsTicking()) { // The base class tick destroyed us return; } HandleFalling(); }
bool AGameObject::isChildOf( AGameObject* parent ) { return IsAttachedTo( parent ); }