HRESULT CchaffIGC::Initialize(ImissionIGC* pMission, Time now, const void* data, unsigned int dataSize) { TmodelIGC<IchaffIGC>::Initialize(pMission, now, data, dataSize); ZRetailAssert (data && (dataSize == sizeof(DataChaffIGC))); DataChaffIGC* dataChaff = (DataChaffIGC*)data; m_pChaffTypeData = (DataChaffTypeIGC*)(dataChaff->pchafftype->GetData()); LoadDecal(m_pChaffTypeData->textureName, NULL, Color(1.0f, 1.0f, 1.0f, 1.0f), false, 1.0f, c_mtNotPickable | c_mtPredictable); Time time0 = pMission->GetIgcSite()->ClientTimeFromServerTime(dataChaff->time0); SetRadius(1.0f); SetPosition(dataChaff->p0 + Seconds(now - time0).count() * dataChaff->v0); SetVelocity(dataChaff->v0); { Rotation r(Vector(0.0f, 0.0f, 1.0f), 2.75f); SetRotation(r); } SetMass(0.0f); m_timeExpire = time0 + Seconds(m_pChaffTypeData->lifespan); SetCluster(dataChaff->pcluster); return S_OK; }
HRESULT CbuoyIGC::Initialize(ImissionIGC* pMission, Time now, const void* data, unsigned int dataSize) { TmodelIGC<IbuoyIGC>::Initialize(pMission, now, data, dataSize); ZRetailAssert (data && (dataSize == sizeof(DataBuoyIGC))); DataBuoyIGC* dataBuoy = (DataBuoyIGC*)data; LoadDecal("buoy", "buoyicon", Color(1.0f, 1.0f, 1.0f, 1.0f), false, 1.0f, c_mtStatic | c_mtPredictable); SetRadius(20.0f); SetPosition(dataBuoy->position); { Rotation r(Vector(0.0f, 0.0f, 1.0f), 0.5f); SetRotation(r); } m_type = dataBuoy->type; m_buoyID = (dataBuoy->buoyID == NA) ? pMission->GenerateNewBuoyID() : dataBuoy->buoyID; IclusterIGC* pcluster = pMission->GetCluster(dataBuoy->clusterID); if (dataBuoy->type == c_buoyCluster) SetSecondaryName(pcluster->GetName()); else SetSecondaryName("waypoint"); SetMass(0.0f); pMission->AddBuoy(this); SetCluster(pcluster); return S_OK; }
HRESULT CprojectileIGC::Initialize(ImissionIGC* pMission, Time now, const void* data, int dataSize) { TmodelIGC<IprojectileIGC>::Initialize(pMission, now, data, dataSize); ZRetailAssert (data && (dataSize == sizeof(DataProjectileIGC))); { DataProjectileIGC* dataProjectile = (DataProjectileIGC*)data; m_projectileType = pMission->GetProjectileType(dataProjectile->projectileTypeID); if (m_projectileType) { m_projectileType->AddRef(); DataProjectileTypeIGC* dataProjectileType = (DataProjectileTypeIGC*)m_projectileType->GetData(); assert (dataProjectileType); //Load the model for the projectile if (iswalpha(dataProjectileType->modelName[0])) { HRESULT hr = Load(0, dataProjectileType->modelName, dataProjectileType->textureName, NULL, c_mtCastRay | c_mtNotPickable); assert (SUCCEEDED(hr)); SetRadius(dataProjectileType->radius); } else { HRESULT hr = LoadDecal(dataProjectileType->textureName, NULL, Color((float)dataProjectileType->color.r, (float)dataProjectileType->color.g, (float)dataProjectileType->color.b, (float)dataProjectileType->color.a), dataProjectileType->bDirectional, dataProjectileType->width, c_mtCastRay | c_mtNotPickable); assert (SUCCEEDED(hr)); GetHitTest()->SetRadius(0.0f); GetThingSite()->SetRadius(dataProjectileType->radius); } //position set after being initialized SetVelocity(dataProjectile->velocity); { Orientation o(dataProjectile->forward); SetOrientation(o); } { Rotation r(dataProjectile->forward, dataProjectileType->rotation); SetRotation(r); } { HitTest* ht = GetHitTest(); //lifespan == 0 => immortal projectile that can hit until it gets terminated on the next update; this is bad assert (dataProjectile->lifespan > 0.0f); ht->SetTimeStart(now); ht->SetTimeStop(m_timeExpire = now + dataProjectile->lifespan); //intentional assignment assert (m_timeExpire != now); } SetMass(0.0f); } } return S_OK; }