void Player::Start() { IsTrigger(true); SetGravity(0.0f); SetVelocity(0.0f,0.0f); SetFriction(0.1f); SetDamping(1.0f); SetAngularDamping(1.5f); lives = 3; SetState(NormalState); lookAtPoint = Vector2(2.0f, 2.0f); speed = 7.0f; firstFire = true; }
void TempSummon::InitStats(uint32 duration) { ASSERT(!IsPet()); m_timer = duration; m_lifetime = duration; if (m_type == TEMPSUMMON_MANUAL_DESPAWN) m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; Unit* owner = GetSummoner(); if (owner) { if (IsTrigger() && m_spells[0]) { setFaction(owner->getFaction()); SetLevel(owner->getLevel()); if (owner->GetTypeId() == TYPEID_PLAYER) m_ControlledByPlayer = true; } if (owner->GetTypeId() == TYPEID_PLAYER) m_CreatedByPlayer = true; } if (!m_Properties) return; if (owner) { if (uint32 slot = m_Properties->Slot) { if (owner->m_SummonSlot[slot] && owner->m_SummonSlot[slot] != GetGUID()) { Creature* oldSummon = GetMap()->GetCreature(owner->m_SummonSlot[slot]); if (oldSummon && oldSummon->IsSummon()) oldSummon->ToTempSummon()->UnSummon(); } owner->m_SummonSlot[slot] = GetGUID(); } } if (m_Properties->Faction) setFaction(m_Properties->Faction); else if (IsVehicle() && owner) // properties should be vehicle setFaction(owner->getFaction()); }
void CPhysicsObject::BecomeTrigger() { if ( IsTrigger() ) return; EnableDrag( false ); EnableGravity( false ); // UNDONE: Use defaults here? Do we want object sets by default? IVP_Template_Phantom trigger; trigger.manage_intruding_cores = IVP_TRUE; // manage a list of intruded objects trigger.dont_check_for_unmoveables = IVP_TRUE; trigger.exit_policy_extra_radius = 0.1f; // relatively strict exit check [m] m_pObject->convert_to_phantom( &trigger ); // hook up events IVP_Environment *pEnv = m_pObject->get_environment(); CPhysicsEnvironment *pVEnv = (CPhysicsEnvironment *)pEnv->client_data; pVEnv->PhantomAdd( this ); }
void CPhysicsObject::BecomeTrigger() { if (IsTrigger()) return; EnableDrag(false); EnableGravity(false); m_pEnv->GetBulletEnvironment()->removeRigidBody(m_pObject); m_pGhostObject = new btGhostObject; m_pGhostObject->setCollisionShape(m_pObject->getCollisionShape()); m_pGhostObject->setUserPointer(this); m_pGhostObject->setCollisionFlags(m_pGhostObject->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE | btCollisionObject::CF_STATIC_OBJECT); m_pGhostObject->setWorldTransform(m_pObject->getWorldTransform()); m_pGhostCallback = new CGhostTriggerCallback(this); if (m_pGhostCallback) m_pGhostObject->setCallback(m_pGhostCallback); m_pEnv->GetBulletEnvironment()->addCollisionObject(m_pGhostObject, COLGROUP_WORLD, ~COLGROUP_WORLD); }
void CPhysicsObject::WriteToTemplate( vphysics_save_cphysicsobject_t &objectTemplate ) { if ( m_collideType == COLLIDE_BALL ) { objectTemplate.pCollide = NULL; objectTemplate.sphereRadius = GetSphereRadius(); } else { objectTemplate.pCollide = GetCollide(); objectTemplate.sphereRadius = 0; } objectTemplate.isStatic = IsStatic(); objectTemplate.collisionEnabled = IsCollisionEnabled(); objectTemplate.gravityEnabled = IsGravityEnabled(); objectTemplate.dragEnabled = IsDragEnabled(); objectTemplate.motionEnabled = IsMotionEnabled(); objectTemplate.isAsleep = IsAsleep(); objectTemplate.isTrigger = IsTrigger(); objectTemplate.materialIndex = m_materialIndex; objectTemplate.mass = GetMass(); objectTemplate.rotInertia = GetInertia(); GetDamping( &objectTemplate.speedDamping, &objectTemplate.rotSpeedDamping ); objectTemplate.massCenterOverride = m_massCenterOverride; objectTemplate.callbacks = m_callbacks; objectTemplate.gameFlags = m_gameFlags; objectTemplate.volume = GetVolume(); objectTemplate.dragCoefficient = m_dragCoefficient; objectTemplate.angDragCoefficient = m_angDragCoefficient; objectTemplate.pShadow = m_pShadow; objectTemplate.hasShadowController = (m_pShadow != NULL) ? true : false; //bool m_shadowTempGravityDisable; objectTemplate.collideType = m_collideType; objectTemplate.contentsMask = m_contentsMask; GetPosition( &objectTemplate.origin, &objectTemplate.angles ); GetVelocity( &objectTemplate.velocity, &objectTemplate.angVelocity ); }
void CPhysicsObject::RemoveTrigger() { if (!IsTrigger()) return; EnableDrag(true); EnableGravity(true); m_pObject->setWorldTransform(m_pGhostObject->getWorldTransform()); if (IsStatic()) m_pEnv->GetBulletEnvironment()->addRigidBody(m_pObject, COLGROUP_WORLD, ~COLGROUP_WORLD); else m_pEnv->GetBulletEnvironment()->addRigidBody(m_pObject); m_pGhostObject->setCallback(NULL); delete m_pGhostCallback; m_pGhostCallback = NULL; m_pEnv->GetBulletEnvironment()->removeCollisionObject(m_pGhostObject); delete m_pGhostObject; m_pGhostObject = NULL; }
void CEditorCondition::Render(CRect &Pos, CDC &dc, bool EventSelected, CChronoEventEditor& Ed, bool bBookmarked, bool bEnabled) { COLORREF BG; BG = m_select(&Ed)? CONDITION_BG_SEL : (EventSelected? CONDITION_BG_EVSEL : CONDITION_BG); if(IsTrigger(NULL)) { BG = m_select(&Ed)? CONDITION_BG_SEL : (EventSelected? CONDITION_BG_EVSEL : EVENT_BG); } // Animating if(m_Anim.m_bDestroyed) { CRect Calc = Pos; Pos.OffsetRect(0,m_Anim.Space); Calc.bottom = Pos.bottom; dc.FillSolidRect(Calc,BG); return; } CRect Box = Pos; Box.bottom+= m_rect(&Ed).Height(); CRect Calc = Pos; Calc.bottom = Box.bottom; CHTMLFont f; f.SetBold(false); f.SetSize(8); f.SetName("Segoe UI"); f.SetImage(false); // Is it enabled? if (!bEnabled) f.SetStrike(true); CString Out; Out.Format("%s", m_Text); g_HTMLDraw.DrawText(&dc, Out, f, Calc, 0, &Ed, &m_imgs,¶ms); m_Readable.Format("%s", Out); dc.FillSolidRect(Calc,BG); { CRect Calc2 = Calc; CRect Calc = Pos; Calc.bottom = Box.bottom; //We may be hovering over something. CPoint mouse; GetCursorPos(&mouse); Ed.ScreenToClient(&mouse); if(Calc2.PtInRect(mouse) && m_select(&Ed)) { for(int p = 0; p < params.size(); p++) for(int d = 0; d < params[p]->displayrects.size(); d++) if(params[p]->displayrects[d].PtInRect(mouse)) { for(int a = 0; a < params[p]->displayrects.size(); a++) dc.FillSolidRect(params[p]->displayrects[a], RGB(100,255,100)); continue; } } // End hover CString Out; bool show_quotes = true; if (m_Text.Find("#noquotes") != -1) show_quotes = false; CString display_text = m_Text; display_text.Replace("#noquotes", ""); if (!show_quotes) display_text.Replace("\"", ""); Out.Format("%s", display_text); g_HTMLDraw.DrawText(&dc, Out, f, Calc, 0, &Ed, &m_imgs,¶ms); m_Readable.Format("%s", Out); if(m_select(&Ed)) dc.Draw3dRect(Calc2,CONDITION_BG_SEL2,CONDITION_BG_SEL2); } m_rect(&Ed) = Calc; Pos.OffsetRect(CPoint(0,Calc.Height())); m_Anim.Space = Calc.Height(); if(IsLoop(NULL)) { Pos.left += 10; } }