当前位置: 首页>>代码示例>>C++>>正文


C++ CItemCtx::GetDevice方法代码示例

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


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

示例1: AccumulateAttributes

void CDeviceClass::AccumulateAttributes (CItemCtx &ItemCtx, int iVariant, TArray<SDisplayAttribute> *retList)

//	AccumulateAttributes
//
//	Add display attributes to the list.

	{
	//	Add general device attributes. If we have a variant, then it means 
	//	we're interested in the attributes for a missile/ammo of the device 
	//	(not the device itself).

	if (iVariant == -1)
		{
		CInstalledDevice *pDevice = ItemCtx.GetDevice();

		//	Linked-fire

		DWORD dwOptions = GetLinkedFireOptions(ItemCtx);
		if (dwOptions != 0)
			retList->Insert(SDisplayAttribute(attribPositive, CONSTLIT("linked-fire")));
		}

	//	Let our subclasses add their own attributes

	OnAccumulateAttributes(ItemCtx, iVariant, retList);
	}
开发者ID:bmer,项目名称:Mammoth,代码行数:26,代码来源:Devices.cpp

示例2: AccumulateEnhancements

bool CDeviceClass::AccumulateEnhancements (CItemCtx &Device, CInstalledDevice *pTarget, TArray<CString> &EnhancementIDs, CItemEnhancementStack *pEnhancements)

//	AccumulateEnhancements
//
//	If this device can enhance pTarget, then we add to the list of enhancements.

	{
	int i;
	bool bEnhanced = false;

	CInstalledDevice *pDevice = Device.GetDevice();
	CSpaceObject *pSource = Device.GetSource();

	//	See if we can enhance the target device

	if (pDevice == NULL 
			|| (pDevice->IsEnabled() && !pDevice->IsDamaged()))
		{
		for (i = 0; i < m_Enhancements.GetCount(); i++)
			{
			//	If this type of enhancement has already been applied, skip it

			if (!m_Enhancements[i].sType.IsBlank()
					&& EnhancementIDs.Find(m_Enhancements[i].sType))
				continue;

			//	If we don't match the criteria, skip it.

			if (pSource 
					&& pTarget
					&& !pSource->GetItemForDevice(pTarget).MatchesCriteria(m_Enhancements[i].Criteria))
				continue;

			//	Add the enhancement

			pEnhancements->Insert(m_Enhancements[i].Enhancement);
			bEnhanced = true;

			//	Remember that we added this enhancement class

			if (!m_Enhancements[i].sType.IsBlank())
				EnhancementIDs.Insert(m_Enhancements[i].sType);
			}
		}

	//	Let sub-classes add their own

	if (OnAccumulateEnhancements(Device, pTarget, EnhancementIDs, pEnhancements))
		bEnhanced = true;

	//	Done

	return bEnhanced;
	}
开发者ID:bmer,项目名称:Mammoth,代码行数:54,代码来源:Devices.cpp

示例3: GetReference

CString CDeviceClass::GetReference (CItemCtx &Ctx, int iVariant, DWORD dwFlags)

//	GetReference
//
//	Returns reference string

	{
	CString sReference;
	
	//	For a device we always add power and other properties.
	//	(If iVariant != -1 then it means that we're looking for reference on a
	//	missile or someting).
	
	if (iVariant == -1)
		{
		CInstalledDevice *pDevice = Ctx.GetDevice();

		//	Start with power requirements

		AppendReferenceString(&sReference, GetReferencePower(Ctx));

		//	Non-standard slots

		if (GetSlotsRequired() != 1)
			AppendReferenceString(&sReference, strPatternSubst(CONSTLIT("%d Slots"), GetSlotsRequired()));

		//	External devices

		if (IsExternal() || (pDevice && pDevice->IsExternal()))
			AppendReferenceString(&sReference, CONSTLIT("External"));
		}

	//	Combine with our subclass

	AppendReferenceString(&sReference, OnGetReference(Ctx, iVariant, dwFlags));
	return sReference;
	}
开发者ID:bmer,项目名称:Mammoth,代码行数:37,代码来源:Devices.cpp

示例4: CalcActivateDelay

int CItemEnhancementStack::CalcActivateDelay (CItemCtx &DeviceCtx) const

//	CalcActivateDelay
//
//	Calculates the activation delay (in ticks) for the given device if we apply
//	this enhancement stack.

	{
	int i;

	CInstalledDevice *pDevice = DeviceCtx.GetDevice();
	if (pDevice == NULL)
		return 0;

	Metric rDelay = -1.0;
	for (i = 0; i < m_Stack.GetCount(); i++)
		{
		int iMin, iMax;
		int iAdj = m_Stack[i].GetActivateRateAdj(&iMin, &iMax);
		if (iAdj != 100)
			{
			if (rDelay < 0.0)
				{
				pDevice->SetActivateDelayAdj(100);
				rDelay = pDevice->GetActivateDelay(DeviceCtx.GetSource());
				}

			rDelay = iAdj * rDelay / 100.0;
			if (rDelay < (Metric)iMin)
				rDelay = (Metric)iMin;
			else if (iMax > 0 && rDelay > (Metric)iMax)
				rDelay = (Metric)iMax;
			}
		}

	return (rDelay < 0.0 ? 100 : (int)(rDelay + 0.5));
	}
开发者ID:dogguts,项目名称:Transcendence,代码行数:37,代码来源:CItemEnhancementStack.cpp

示例5: CalcActivateDelay

int CItemEnhancementStack::CalcActivateDelay (CItemCtx &DeviceCtx) const

//	CalcActivateDelay
//
//	Calculates the activation delay (in ticks) for the given device if we apply
//	this enhancement stack.

	{
	int i;

	CInstalledDevice *pDevice = DeviceCtx.GetDevice();
	if (pDevice == NULL)
		return 0;

	//	Get the raw activation delay. NOTE: This DOES NOT include
	//	any enhancements on the item.

	Metric rDelay = pDevice->GetClass()->GetActivateDelay(pDevice, DeviceCtx.GetSource());

	//	Apply enhancements (including on the item itself)

	for (i = 0; i < m_Stack.GetCount(); i++)
		{
		int iMin, iMax;
		int iAdj = m_Stack[i].GetActivateRateAdj(&iMin, &iMax);
		if (iAdj != 100)
			{
			rDelay = iAdj * rDelay / 100.0;
			if (rDelay < (Metric)iMin)
				rDelay = (Metric)iMin;
			else if (iMax > 0 && rDelay > (Metric)iMax)
				rDelay = (Metric)iMax;
			}
		}

	return (int)(rDelay + 0.5);
	}
开发者ID:bmer,项目名称:Mammoth,代码行数:37,代码来源:CItemEnhancementStack.cpp

示例6: SetItemProperty

bool CDeviceClass::SetItemProperty (CItemCtx &Ctx, const CString &sName, ICCItem *pValue, CString *retsError)

//	SetItemProperty
//
//	Sets a device property. Subclasses should call this if they do not 
//	understand the property.

	{
	CCodeChain &CC = g_pUniverse->GetCC();

	//	Get the installed device. We need this to set anything.

	CInstalledDevice *pDevice = Ctx.GetDevice();
	if (pDevice == NULL)
		{
		*retsError = CONSTLIT("Item is not an installed device on object.");
		return false;
		}

	//	Figure out what to set

	if (strEquals(sName, PROPERTY_FIRE_ARC))
		{
		//	A value of nil means no fire arc (and no omni)

		if (pValue == NULL || pValue->IsNil())
			{
			pDevice->SetOmniDirectional(false);
			pDevice->SetFireArc(0, 0);
			}

		//	A value of "omnidirectional" counts

		else if (strEquals(pValue->GetStringValue(), PROPERTY_OMNIDIRECTIONAL))
			{
			pDevice->SetOmniDirectional(true);
			pDevice->SetFireArc(0, 0);
			}

		//	A single value means that we just point in a direction

		else if (pValue->GetCount() == 1)
			{
			int iMinFireArc = AngleMod(pValue->GetElement(0)->GetIntegerValue());
			pDevice->SetOmniDirectional(false);
			pDevice->SetFireArc(iMinFireArc, iMinFireArc);
			}

		//	Otherwise we expect a list with two elements

		else if (pValue->GetCount() >= 2)
			{
			int iMinFireArc = AngleMod(pValue->GetElement(0)->GetIntegerValue());
			int iMaxFireArc = AngleMod(pValue->GetElement(1)->GetIntegerValue());
			pDevice->SetOmniDirectional(false);
			pDevice->SetFireArc(iMinFireArc, iMaxFireArc);
			}

		//	Invalid

		else
			{
			*retsError = CONSTLIT("Invalid fireArc parameter.");
			return false;
			}
		}

	else if (strEquals(sName, PROPERTY_LINKED_FIRE_OPTIONS))
		{
		//	Parse the options

		DWORD dwOptions;
		if (!::GetLinkedFireOptions(pValue, &dwOptions, retsError))
			return false;

		//	Set

		pDevice->SetLinkedFireOptions(dwOptions);
		}

	else if (strEquals(sName, PROPERTY_POS))
		{
		//	Get the parameters. We accept a single list parameter with angle/radius/z.
		//	(The latter is compatible with the return of objGetDevicePos.)

		int iPosAngle;
		int iPosRadius;
		int iZ;
		if (pValue == NULL || pValue->IsNil())
			{
			iPosAngle = 0;
			iPosRadius = 0;
			iZ = 0;
			}
		else if (pValue->GetCount() >= 2)
			{
			iPosAngle = pValue->GetElement(0)->GetIntegerValue();
			iPosRadius = pValue->GetElement(1)->GetIntegerValue();

			if (pValue->GetCount() >= 3)
//.........这里部分代码省略.........
开发者ID:bmer,项目名称:Mammoth,代码行数:101,代码来源:Devices.cpp


注:本文中的CItemCtx::GetDevice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。