Ejemplo n.º 1
0
ICCItem *CDeviceClass::GetItemProperty (CItemCtx &Ctx, const CString &sName)

//	GetItemProperty
//
//	Returns the item property. Subclasses should call this if they do not
//	understand the property.

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

	//	Get the device

	CInstalledDevice *pDevice = Ctx.GetDevice();

	//	Get the property

	if (strEquals(sName, PROPERTY_CAN_BE_DISABLED))
		return (pDevice ? CC.CreateBool(pDevice->CanBeDisabled(Ctx)) : CC.CreateBool(CanBeDisabled(Ctx)));

	else if (strEquals(sName, PROPERTY_ENABLED))
		return (pDevice ? CC.CreateBool(pDevice->IsEnabled()) : CC.CreateNil());

	else if (strEquals(sName, PROPERTY_POS))
		{
		if (pDevice == NULL)
			return CC.CreateNil();

		//	Create a list

		ICCItem *pResult = CC.CreateLinkedList();
		if (pResult->IsError())
			return pResult;

		CCLinkedList *pList = (CCLinkedList *)pResult;

		//	List contains angle, radius, and optional z

		pList->AppendInteger(CC, pDevice->GetPosAngle());
		pList->AppendInteger(CC, pDevice->GetPosRadius());
		if (pDevice->GetPosZ() != 0)
			pList->AppendInteger(CC, pDevice->GetPosZ());

		//	Done

		return pResult;
		}

	else if (strEquals(sName, PROPERTY_SECONDARY))
		return (pDevice ? CC.CreateBool(pDevice->IsSecondaryWeapon()) : CC.CreateNil());

	else if (m_pItemType)
		return CreateResultFromDataField(CC, m_pItemType->GetDataField(sName));

	else
		return CC.CreateNil();
	}
Ejemplo n.º 2
0
ICCItem *CTopologyNode::GetProperty (const CString &sName)

//	GetProperty
//
//	Get topology node property

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

	if (strEquals(sName, PROPERTY_LEVEL))
		return CC.CreateInteger(GetLevel());
	else if (strEquals(sName, PROPERTY_NAME))
		return CC.CreateString(GetSystemName());
	else if (strEquals(sName, PROPERTY_POS))
		{
		//	If no map, then no position

		if (m_pMap == NULL)
			return CC.CreateNil();

		//	Create a list

		ICCItem *pResult = CC.CreateLinkedList();
		if (pResult->IsError())
			return pResult;

		CCLinkedList *pList = (CCLinkedList *)pResult;

		pList->AppendInteger(CC, m_xPos);
		pList->AppendInteger(CC, m_yPos);

		return pResult;
		}
	else
		return CC.CreateNil();
	}