C++ Chit::GetItem方法代码示例

本文整理汇总了C++中Chit::GetItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Chit::GetItem方法的具体用法?C++ Chit::GetItem怎么用?C++ Chit::GetItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chit的用法示例。


C++ Chit::GetItem方法代码示例

在下文中一共展示了Chit::GetItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: NewMonsterChit

Chit* LumosChitBag::NewMonsterChit(const Vector3F& pos, const char* name, int team)
{
	const ChitContext* context = Context();
	Chit* chit = NewChit();

	AddItem( name, chit, context->engine, team, 0 );

	chit->Add( new RenderComponent( chit->GetItem()->ResourceName() ));
	chit->Add( new PathMoveComponent());
	chit->Add( new AIComponent());

	chit->SetPosition( pos );

	chit->Add( new HealthComponent());

	IString mob = chit->GetItem()->keyValues.GetIString(ISC::mob);
	if (ReserveBank::Instance()) {
		ReserveBank::Instance()->WithdrawMonster(chit->GetWallet(), mob == ISC::greater);
	}
	if (mob == ISC::greater) {
		// Mark this item as important with a destroyMsg:
		chit->GetItem()->SetSignificant(GetNewsHistory(), ToWorld2F(pos), NewsEvent::GREATER_MOB_CREATED, NewsEvent::GREATER_MOB_KILLED, 0);
	}
	chit->GetItem()->GetTraitsMutable()->Roll(chit->ID());
	chit->GetItem()->FullHeal();

	if (XenoAudio::Instance()) {
		XenoAudio::Instance()->PlayVariation(ISC::rezWAV, random.Rand(), &pos);
	}
	return chit;
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:31,代码来源:lumoschitbag.cpp

示例2: Citizens

int CoreScript::Citizens(CChitArray* arr)
{
	int i=0;

	while (i < citizens.Size()) {
		int id = citizens[i];
		Chit* chit = CitizenFilter(id);
		if (chit) {	// check for team change, throw out of citizens.
			if (arr) arr->Push(chit);
			++i;
		}
		else {
			// Dead and gone.
			citizens.SwapRemove(i);
			// Reset the timer so that there is a little time
			// between a dead citizen and re-spawn
			spawnTick.Reset();
		}
	}
#if 0
	// This is annoying: seeing if cranking down the spawn rate and not
	// destroying the sleep tube achieves success.
	// Also, destroy a sleeptube, so it costs something to replace, and towns can fall.
	if ( sc ) {
		Vector2F pos2 = sc->GetPosition2D();
		Vector2I sector = ToSector( ToWorld2I( pos2 ));
		Chit* bed = scriptContext->chitBag->FindBuilding( ISC::bed, sector, &pos2, LumosChitBag::RANDOM_NEAR, 0, 0 );
		if ( bed && bed->GetItem() ) {
			bed->GetItem()->hp = 0;
			bed->SetTickNeeded();
		}
	}
#endif
	return citizens.Size();
}
开发者ID:csioza,项目名称:alteraorbis,代码行数:35,代码来源:corescript.cpp

示例3: AddFlag

void CoreScript::AddFlag(const Vector2I& _pos)
{
	Vector2I pos = _pos;
	// A little UI fixup: set the flag to a porch
	// if we click on the switch.
	Chit* building = Context()->chitBag->QueryBuilding(IString(), pos, 0);
	if (building && (building->GetItem()->IName() == ISC::switchOn || building->GetItem()->IName() == ISC::switchOff)) {
		MapSpatialComponent* msc = GET_SUB_COMPONENT(building, SpatialComponent, MapSpatialComponent);
		if (msc) {
			pos = msc->PorchPos().min;
		}
	}

	Flag f = { pos, 0 };
	if (flags.Find(f) < 0) {
		Chit* chit = Context()->chitBag->NewChit();
		RenderComponent* rc = new RenderComponent("flag");
		chit->Add(rc);
		ProcRenderInfo info;
		AssignProcedural(ISC::team,
							false,
							ParentChit()->GetItem()->ID(),
							ParentChit()->Team(),
							false,
							0,
							0,
							&info);
		rc->SetProcedural(0, info);
		chit->SetPosition(ToWorld3F(pos));
		f.chitID = chit->ID();
		flags.Push(f);
	}
}
开发者ID:csioza,项目名称:alteraorbis,代码行数:33,代码来源:corescript.cpp

示例4: OnChitMsg

void CoreScript::OnChitMsg(Chit* chit, const ChitMsg& msg)
{
	// Logic split between Sim::OnChitMsg and CoreScript::OnChitMsg
	if (msg.ID() == ChitMsg::CHIT_DESTROYED && (chit == parentChit)) {
		while (!citizens.Empty()) {
			int citizenID = citizens.Pop();
			Chit* citizen = Context()->chitBag->GetChit(citizenID);
			if (citizen && citizen->GetItem()) {
				// Set to rogue team.
				citizen->GetItem()->SetRogue();
			}
		}

		Vector2I pos2i = ToWorld2I(chit->Position());
		Vector2I sector = ToSector(pos2i);

		if (Team::Instance()->IsController(chit->Team())) {
			NewsEvent news(NewsEvent::SUPERTEAM_DELETED, ToWorld2F(pos2i), chit->GetItemID(), 0);
			Context()->chitBag->GetNewsHistory()->Add(news);
		}
		int controllerTeam = 0;
		if (Team::Instance()->IsControlled(chit->Team(), &controllerTeam)) {
			CoreScript* controller = CoreScript::GetCoreFromTeam(controllerTeam);
			GLASSERT(controller);
			if (controller) {
				NewsEvent news(NewsEvent::SUBTEAM_DELETED, ToWorld2F(pos2i), chit->GetItemID(), controller->ParentChit()->GetItemID());
				Context()->chitBag->GetNewsHistory()->Add(news);
			}
		}

		int deleterID = chit->GetItemComponent() ? chit->GetItemComponent()->LastDamageID() : 0;
		Chit* deleter = Context()->chitBag->GetChit(deleterID);
		int superTeam = 0;
		if (deleter
			&& (deleter->Team() == Team::Instance()->SuperTeam(deleter->Team()))
			&& Team::IsDenizen(deleter->Team())
			&& Team::IsDenizen(chit->Team()))
		{
			superTeam = deleter->Team();
		}

		if (chit->Team() != TEAM_NEUTRAL) {
			if (superTeam) {
				LumosChitBag::CreateCoreData data = { sector, true, chit->Team(), deleter ? deleter->Team() : 0 };
				Context()->chitBag->coreCreateList.Push(data);
			}
			else {
				LumosChitBag::CreateCoreData data = { sector, false, chit->Team(), deleter ? deleter->Team() : 0 };
				Context()->chitBag->coreCreateList.Push(data);
			}
		}
		else {
			// Neutral cores are taken over by wandering over them
			// with enough friend units to have critical mass.
			LumosChitBag::CreateCoreData data = { sector, false, 0, 0 };
			Context()->chitBag->coreCreateList.Push(data);
		}
		Team::Instance()->CoreDestroyed(parentChit->Team());
	}
}
开发者ID:csioza,项目名称:alteraorbis,代码行数:60,代码来源:corescript.cpp

示例5: RecruitNeutral

bool CoreScript::RecruitNeutral()
{
	Vector2I sector = ToSector(parentChit->Position());
	Rectangle2I inner = InnerSectorBounds(sector);

	MOBKeyFilter filter;
	filter.value = ISC::denizen;
	CChitArray arr;
	Context()->chitBag->QuerySpatialHash(&arr, ToWorld2F(inner), 0, &filter);

	for (int i = 0; i < arr.Size(); ++i) {
		Chit* chit = arr[i];
		if (Team::Instance()->GetRelationship(chit, parentChit) != ERelate::ENEMY) {
			if (this->IsCitizen(chit)) continue;
			if (!chit->GetItem()) continue;

			if (Team::IsRogue(chit->Team())) {
				// ronin! denizen without a core.
				this->AddCitizen( chit );
				GLASSERT(chit->GetItem()->Significant());

				NewsEvent news(NewsEvent::ROGUE_DENIZEN_JOINS_TEAM, ToWorld2F(chit->Position()), chit->GetItemID(), 0);
				Context()->chitBag->GetNewsHistory()->Add(news);
				return true;
			}
		}
	}
	return false;
}
开发者ID:csioza,项目名称:alteraorbis,代码行数:29,代码来源:corescript.cpp

示例6: PrimeCitizen

Chit* CoreScript::PrimeCitizen()
{
	for (int i = 0; i < citizens.Size(); ++i) {
		int id = citizens[i];
		Chit* chit = CitizenFilter(id);
		if (chit && chit->GetItem()) {
			if (chit->GetItem()->keyValues.Has(ISC::prime)) {
				return chit;
			}
		}
	}
	return 0;
}
开发者ID:csioza,项目名称:alteraorbis,代码行数:13,代码来源:corescript.cpp

示例7: FindBuilding

Chit* LumosChitBag::FindBuilding(	const grinliz::IString&  name, 
									const grinliz::Vector2I& sector, 
									const grinliz::Vector2F* pos, 
									LumosChitBag::EFindMode flags,
									CDynArray<Chit*>* arr,
									IChitAccept* filter )
{
	CDynArray<Chit*>& match = arr ? *arr : findMatch;	// sleazy reference trick to point to either passed in or local.
	match.Clear();
	findWeight.Clear();

	for( MapSpatialComponent* it = mapSpatialHash[sector.y*NUM_SECTORS+sector.x]; it; it = it->nextBuilding ) {
		Chit* chit = it->ParentChit();
		GLASSERT( chit );
		if ( filter && !filter->Accept( chit )) {				// if a filter, check it.
			continue;
		}

		const GameItem* item = chit->GetItem();

		if ( item && ( name.empty() || item->IName() == name )) {	// name, if empty, matches everything
			match.Push( chit );
		}
	}

	// If we found nothing, or we don't care about the position, return early.
	// Else deal with choice / sorting / etc. below.
	if ( match.Empty() )
		return 0;
	if ( !pos )
		return match[0];

	// NEAREST scans and finds the closest one.
	// RANDOM_NEAR chooses one at random, but weighted by the (inverse) of the distance
	if ( flags == EFindMode::NEAREST ) {
		float closest = ( ToWorld2F(match[0]->Position()) - *pos ).LengthSquared();
		int   ci = 0;
		for( int i=1; i<match.Size(); ++i ) {
			float len2 = ( ToWorld2F(match[i]->Position()) - *pos ).LengthSquared();
			if ( len2 < closest ) {
				closest = len2;
				ci = i;
			}
		}
		return match[ci];
	}
	if ( flags == EFindMode::RANDOM_NEAR ) {
		for( int i=0; i<match.Size(); ++i ) {
			float len = ( ToWorld2F(match[i]->Position()) - *pos ).Length();
			if (len < 1) len = 1;
			findWeight.Push( 1.0f/len );
		}
		int index = random.Select( findWeight.Mem(), findWeight.Size() );
		return match[index];
	}

	// Bad flag? Something didn't return?
	GLASSERT( 0 );
	return 0;
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:60,代码来源:lumoschitbag.cpp

示例8: NewGoldChit

Chit* LumosChitBag::NewGoldChit( const grinliz::Vector3F& pos, Wallet* src )
{
	GLASSERT(src);
	if (src->Gold() == 0) return 0;

	const ChitContext* context = Context();

	Vector2F v2 = { pos.x, pos.z };

	ItemNameFilter goldFilter( ISC::gold);
	this->QuerySpatialHash( &chitList, v2, 1.0f, 0, &goldFilter );
	Chit* chit = 0;

	// Evil bug this: adding gold to a wallet just before
	// deletion. I'm a little concerned where else
	// this could be a problem. Would be nice to make
	// deletion immediate.
	for (int i = 0; i < chitList.Size(); ++i) {
		Chit* c = chitList[i];
		if (c && !IsQueuedForDelete(c) && c->GetWallet() && !c->GetWallet()->Closed()) {
			chit = chitList[i];
			break;
		}
	}

	if ( !chit ) {
		chit = this->NewChit();
		AddItem( "gold", chit, context->engine, 0, 0 );
		chit->Add( new RenderComponent( chit->GetItem()->ResourceName() ));
		chit->SetPosition( pos );
		chit->Add(new GameMoveComponent());
	}
	chit->GetWallet()->Deposit(src, src->Gold());
	return chit;
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:35,代码来源:lumoschitbag.cpp

示例9: NewBadGuy

Chit* LumosChitBag::NewBadGuy(const grinliz::Vector2I& pos, 
							  const IString& name, 
							  const grinliz::IString& type, 
							  int team, int level )
{
	const ChitContext* context = Context();
	Chit* chit = NewChit();
	const GameItem& root = ItemDefDB::Instance()->Get(type.safe_str());

	chit->Add( new RenderComponent(root.ResourceName()));
	chit->Add( new PathMoveComponent());
	AddItem(root.Name(), chit, context->engine, team, level, 0, "human");

	ReserveBank::Instance()->WithdrawMonster(chit->GetWallet(), true);
	chit->GetItem()->GetTraitsMutable()->Roll( random.Rand() );
	chit->GetItem()->GetPersonalityMutable()->Roll( random.Rand(), &chit->GetItem()->Traits() );
	chit->GetItem()->FullHeal();

	chit->GetItem()->SetProperName(name);

	AIComponent* ai = new AIComponent();
	chit->Add( ai );

	chit->Add( new HealthComponent());
	chit->SetPosition( (float)pos.x+0.5f, 0, (float)pos.y+0.5f );

	for (int i = 0; i < ForgeScript::NUM_ITEM_TYPES; ++i) {
		ForgeScript::ForgeData forgeData;
		forgeData.type = i;
		forgeData.subType = 0;
		forgeData.tech = 3;
		forgeData.level = level;
		forgeData.team = team;
		int seed = random.Rand();
		ForgeScript::BestSubItem(&forgeData, seed);

		TransactAmt cost;
		TransactAmt freeCreate;
		static const int CRYSTAL[NUM_CRYSTAL_TYPES] = { 3, 2, 1, 1 };
		freeCreate.Set(0, CRYSTAL);

		GameItem* loot = ForgeScript::ForgeRandomItem(forgeData, freeCreate, &cost, seed, ReserveBank::GetWallet());
		if (loot) {
			chit->GetItemComponent()->AddToInventory(loot);
			loot->SetSignificant(chit->Context()->chitBag->GetNewsHistory(), 
								 ToWorld2F(chit->Position()),
								 NewsEvent::FORGED, NewsEvent::UN_FORGED, chit->GetItem());
		}
	}

	chit->GetItem()->SetSignificant(GetNewsHistory(), ToWorld2F(pos), NewsEvent::DENIZEN_CREATED, NewsEvent::DENIZEN_KILLED, 0);

	if (XenoAudio::Instance()) {
		Vector3F pos3 = ToWorld3F(pos);
		XenoAudio::Instance()->PlayVariation(ISC::rezWAV, random.Rand(), &pos3);
	}
	return chit;
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:58,代码来源:lumoschitbag.cpp

示例10: QueryBuilding

Chit* LumosChitBag::QueryBuilding( const IString& name, const grinliz::Rectangle2I& bounds, CChitArray* arr )
{
	GLASSERT( MAX_BUILDING_SIZE == 2 );	// else adjust logic
	Vector2I sector = ToSector( bounds.min );

	for( MapSpatialComponent* it = mapSpatialHash[SectorIndex(sector)]; it; it = it->nextBuilding ) {
		if ( it->Bounds().Intersect( bounds )) {
			Chit* chit = it->ParentChit();
			if (name.empty() || (chit->GetItem() && chit->GetItem()->IName() == name)) {
				if (!arr) {
					return chit;
				}
				if (arr->HasCap()) {
					arr->Push(chit);
				}
			}
		}
	}
	if (arr && !arr->Empty()) {
		return (*arr)[0];
	}
	return 0;
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:23,代码来源:lumoschitbag.cpp

示例11: NewDenizen

Chit* LumosChitBag::NewDenizen( const grinliz::Vector2I& pos, int team )
{
	const ChitContext* context = Context();
	IString itemName;

	switch (Team::Group(team)) {
		case TEAM_HOUSE:	itemName = (random.Bit()) ? ISC::humanFemale : ISC::humanMale;	break;
		case TEAM_GOB:		itemName = ISC::gobman;											break;
		case TEAM_KAMAKIRI:	itemName = ISC::kamakiri;										break;
		default: GLASSERT(0); break;
	}

	Chit* chit = NewChit();
	const GameItem& root = ItemDefDB::Instance()->Get(itemName.safe_str());

	chit->Add( new RenderComponent(root.ResourceName()));
	chit->Add( new PathMoveComponent());

	const char* altName = 0;
	if (Team::Group(team) == TEAM_HOUSE) {
		altName = "human";
	}
	AddItem(root.Name(), chit, context->engine, team, 0, 0, altName);

	ReserveBank::Instance()->WithdrawDenizen(chit->GetWallet());
	chit->GetItem()->GetTraitsMutable()->Roll( random.Rand() );
	chit->GetItem()->GetPersonalityMutable()->Roll( random.Rand(), &chit->GetItem()->Traits() );
	chit->GetItem()->FullHeal();

	IString nameGen = chit->GetItem()->keyValues.GetIString( "nameGen" );
	if ( !nameGen.empty() ) {
		LumosChitBag* chitBag = chit->Context()->chitBag;
		if ( chitBag ) {
			chit->GetItem()->SetProperName(chitBag->NameGen(nameGen.c_str(), chit->ID()));
		}
	}

	AIComponent* ai = new AIComponent();
	chit->Add( ai );

	chit->Add( new HealthComponent());
	chit->SetPosition( (float)pos.x+0.5f, 0, (float)pos.y+0.5f );

	chit->GetItem()->SetSignificant(GetNewsHistory(), ToWorld2F(pos), NewsEvent::DENIZEN_CREATED, NewsEvent::DENIZEN_KILLED, 0);

	if (XenoAudio::Instance()) {
		Vector3F pos3 = ToWorld3F(pos);
		XenoAudio::Instance()->PlayVariation(ISC::rezWAV, random.Rand(), &pos3);
	}

	return chit;
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:52,代码来源:lumoschitbag.cpp

示例12: NewLawnOrnament

Chit* LumosChitBag::NewLawnOrnament(const Vector2I& pos, const char* name, int team)
{
	const ChitContext* context = Context();
	Chit* chit = NewChit();

	GameItem* rootItem = ItemDefDB::Instance()->Get(name).Clone();

	// Hack...how to do this better??
	if (rootItem->IResourceName() == "ruins1.0") {
		CStr<32> str;
		str.Format("ruins1.%d", random.Rand(2));
		rootItem->SetResource(str.c_str());
	}

	int size = 1;
	rootItem->keyValues.Get(ISC::size, &size);

	MapSpatialComponent* msc = new MapSpatialComponent();
	msc->SetBuilding(size, false, 0);
	msc->SetBlocks((rootItem->flags & GameItem::PATH_NON_BLOCKING) ? false : true);
	chit->Add(msc);
	MapSpatialComponent::SetMapPosition(chit, pos.x, pos.y);


	chit->Add(new RenderComponent(rootItem->ResourceName()));
	chit->Add(new HealthComponent());
	AddItem(rootItem, chit, context->engine, team, 0);

	IString proc = rootItem->keyValues.GetIString("procedural");
	if (!proc.empty()) {
		ProcRenderInfo info;
		AssignProcedural(chit->GetItem(), &info);
		chit->GetRenderComponent()->SetProcedural(0, info);
	}
	
	context->engine->particleSystem->EmitPD(ISC::constructiondone, ToWorld3F(pos), V3F_UP, 0);

	if (XenoAudio::Instance()) {
		Vector3F pos3 = ToWorld3F(pos);
		XenoAudio::Instance()->PlayVariation(ISC::rezWAV, random.Rand(), &pos3);
	}

	return chit;
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:44,代码来源:lumoschitbag.cpp

示例13: NewCrystalChit

Chit* LumosChitBag::NewCrystalChit( const grinliz::Vector3F& _pos, Wallet* src, bool fuzz )
{
	Vector3F pos = _pos;
	if ( fuzz ) {
		pos.x = floorf(_pos.x) + random.Uniform();
		pos.z = floorf(_pos.z) + random.Uniform();
	}

	int crystal = -1;
	for (int i = 0; i < NUM_CRYSTAL_TYPES; ++i) {
		if (src->Crystal(i)) {
			crystal = i;
			break;
		}
	}

	if (crystal == -1) return 0;	// done

	const char* name = 0;
	switch ( crystal ) {
	case CRYSTAL_GREEN:		name="crystal_green";	break;
	case CRYSTAL_RED:		name="crystal_red";		break;
	case CRYSTAL_BLUE:		name="crystal_blue";	break;
	case CRYSTAL_VIOLET:	name="crystal_violet";	break;
	}

	const ChitContext* context = Context();

	Chit* chit = this->NewChit();
	AddItem( name, chit, context->engine, 0, 0 );
	chit->Add( new RenderComponent( chit->GetItem()->ResourceName() ));
	chit->Add(new GameMoveComponent());

	chit->SetPosition( pos );
	
	int c[NUM_CRYSTAL_TYPES] = { 0 };
	c[crystal] = 1;

	chit->GetWallet()->Deposit(src, 0, c);

	return chit;
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:42,代码来源:lumoschitbag.cpp

示例14: BuildingCounts

void LumosChitBag::BuildingCounts(const Vector2I& sector, int* counts, int n)
{
	BuildScript buildScript;

	for( MapSpatialComponent* it = mapSpatialHash[sector.y*NUM_SECTORS+sector.x]; it; it = it->nextBuilding ) {
		Chit* chit = it->ParentChit();
		GLASSERT( chit );

		const GameItem* item = chit->GetItem();
		if (!item)
			continue;
		const IString& name = item->IName();

		int id = 0;
		if (!name.empty()) {
			buildScript.GetDataFromStructure(name, &id);
			if (id < n) {
				counts[id] += 1;
			}
		}
	}
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:22,代码来源:lumoschitbag.cpp

示例15: NewBuilding

Chit* LumosChitBag::NewBuilding(const Vector2I& pos, const char* name, int team)
{
	const ChitContext* context = Context();
	Chit* chit = NewChit();

	const GameItem& rootItem = ItemDefDB::Instance()->Get(name);
	GameItem* item = rootItem.Clone();

	// Hack...how to do this better??
	if (item->IResourceName() == "pyramid0") {
		CStr<32> str;
		str.Format("pyramid%d", random.Rand(3));
		item->SetResource(str.c_str());
	}
	if (item->IResourceName() == ISC::kiosk) {
		switch (random.Rand(4)) {
			case 0: item->SetResource("kiosk.n");	break;
			case 1: item->SetResource("kiosk.m");	break;
			case 2: item->SetResource("kiosk.s");	break;
			default:item->SetResource("kiosk.c");	break;
		}
	}

	int size = 1;
	rootItem.keyValues.Get(ISC::size, &size);
	int porch = 0;
	rootItem.keyValues.Get(ISC::porch, &porch);
	const int circuit = 0;

	// Should be pre-cleared. But recover from weird situations by clearing.
	// Note that water is a real problem.
	Rectangle2I r;
	r.Set(pos.x, pos.y, pos.x + size - 1, pos.y + size - 1);
	for (Rectangle2IIterator it(r); !it.Done(); it.Next()) {
		const WorldGrid& wg = context->worldMap->GetWorldGrid(it.Pos());
		GLASSERT(wg.IsLand());
		(void)wg;
		context->worldMap->SetRock(it.Pos().x, it.Pos().y, 0, false, 0);
		context->worldMap->SetPlant(it.Pos().x, it.Pos().y, 0, 0);
	}

	MapSpatialComponent* msc = new MapSpatialComponent();
	msc->SetBuilding(size, porch != 0, circuit);
	msc->SetBlocks((rootItem.flags & GameItem::PATH_NON_BLOCKING) ? false : true);
	chit->Add(msc);
	MapSpatialComponent::SetMapPosition(chit, pos.x, pos.y);

	chit->Add(new RenderComponent(item->ResourceName()));
	chit->Add(new HealthComponent());
	AddItem(item, chit, context->engine, team, 0);

	IString script = rootItem.keyValues.GetIString("script");
	if (!script.empty()) {
		Component* s = ComponentFactory::Factory(script.c_str(), &chitContext);
		GLASSERT(s);
		chit->Add(s);
	}

	IString proc = rootItem.keyValues.GetIString("procedural");
	if (!proc.empty()) {
		ProcRenderInfo info;
		AssignProcedural(chit->GetItem(), &info);
		chit->GetRenderComponent()->SetProcedural(0, info);
	}

	IString consumes = rootItem.keyValues.GetIString(ISC::zone);
	if (!consumes.empty()) {
		Component* s = ComponentFactory::Factory("EvalBuildingScript", &chitContext);
		GLASSERT(s);
		chit->Add(s);
	}

	IString nameGen = rootItem.keyValues.GetIString( "nameGen");
	if ( !nameGen.empty() ) {
		IString p = Context()->chitBag->NameGen(nameGen.c_str(), chit->random.Rand());
		chit->GetItem()->SetProperName( p );
	}

#if 0	// debugging
	SectorPort sp;
	sp.sector.Set( pos.x/SECTOR_SIZE, pos.y/SECTOR_SIZE );
	sp.port = 1;
	worldMap->SetRandomPort( sp );
#endif

	context->engine->particleSystem->EmitPD( ISC::constructiondone, ToWorld3F( pos ), V3F_UP, 0 );

	if (XenoAudio::Instance()) {
		Vector3F pos3 = ToWorld3F(pos);
		XenoAudio::Instance()->PlayVariation(ISC::rezWAV, random.Rand(), &pos3);
	}

	return chit;
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:94,代码来源:lumoschitbag.cpp

本文标签属性:

示例:示例英语

代码:代码编程

上一篇:Python ImageChops类代码示例
下一篇:C# RecordType.ToString方法代码示例

为您推荐