Пример #1
0
void UFlareFleet::AddShip(UFlareSimulatedSpacecraft* Ship)
{
	if (IsTraveling())
	{
		FLOGV("Fleet Disband fail: '%s' is travelling", *GetFleetName().ToString());
		return;
	}

	if (GetCurrentSector() != Ship->GetCurrentSector())
	{
		FLOGV("Fleet Merge fail: '%s' is the sector '%s' but '%s' is the sector '%s'",
			  *GetFleetName().ToString(),
			  *GetCurrentSector()->GetSectorName().ToString(),
			  *Ship->GetImmatriculation().ToString(),
			  *Ship->GetCurrentSector()->GetSectorName().ToString());
		return;
	}

	UFlareFleet* OldFleet = Ship->GetCurrentFleet();
	if (OldFleet)
	{
		OldFleet->RemoveShip(Ship);
	}

	FleetData.ShipImmatriculations.Add(Ship->GetImmatriculation());
	FleetShips.AddUnique(Ship);
	Ship->SetCurrentFleet(this);
}
Пример #2
0
	//-----------------------------------------------------------------------
	bool iEntity3D::IsInSector(cSector *apSector)
	{
		//Log("-- %s --\n",msName.c_str());
		//bool bShouldReturnTrue = false;

		if(apSector == GetCurrentSector())
		{
			//Log("Should return true\n");
			//bShouldReturnTrue = true;
			return true;
		}

		tRenderContainerDataList *pDataList = GetRenderContainerDataList();
		tRenderContainerDataListIt it = pDataList->begin();
		for(; it != pDataList->end(); ++it)
		{
			iRenderContainerData *pRenderContainerData = *it;
			cSector *pSector = static_cast<cSector*>(pRenderContainerData);
			
			//Log("%s (%d) vs %s (%d)\n",pSector->GetId().c_str(),pSector, apSector->GetId().c_str(),apSector);
			if(pSector == apSector)
			{
				//Log("return true!\n");
				return true;
			}
		}
		
		//if(bShouldReturnTrue)Log(" %s should have returned true. Sectors: %d\n",msName.c_str(),		mlstRenderContainerData.size());
		//Log("return false!\n");
		return false;
	}
Пример #3
0
bool UFlareFleet::CanMerge(UFlareFleet* Fleet, FText& OutInfo)
{
	if (GetShipCount() + Fleet->GetShipCount() > GetMaxShipCount())
	{
		OutInfo = LOCTEXT("MergeFleetMaxShips", "Can't add, max ships reached");
		return false;
	}

	if (IsTraveling())
	{
		OutInfo = LOCTEXT("MergeFleetTravel", "Can't add during travel");
		return false;
	}

	if (Fleet->IsTraveling())
	{
		OutInfo = LOCTEXT("MergeOtherFleetTravel", "Can't add travelling ships");
		return false;
	}

	if (GetCurrentSector() != Fleet->GetCurrentSector())
	{
		OutInfo = LOCTEXT("MergeFleetDifferenSector", "Can't add from a different sector");
		return false;
	}

	return true;
}
Пример #4
0
FText UFlareFleet::GetStatusInfo() const
{
	if (IsTraveling())
	{
		int64 RemainingDuration = CurrentTravel->GetRemainingTravelDuration();
		return FText::Format(LOCTEXT("TravelTextFormat", "Travelling to {0} ({1} left)"),
			CurrentTravel->GetDestinationSector()->GetSectorName(),
			FText::FromString(*UFlareGameTools::FormatDate(RemainingDuration, 1))); //FString needed here
	}
	else
	{
		return FText::Format(LOCTEXT("TravelIdle", "Idle in {0}"), GetCurrentSector()->GetSectorName());
	}

	return FText();
}
Пример #5
0
/** Remove all ship from the fleet and delete it. Not possible during travel */
void UFlareFleet::Disband()
{
	if (IsTraveling())
	{
		FLOGV("Fleet Disband fail: '%s' is travelling", *GetFleetName().ToString());
		return;
	}

	for (int ShipIndex = 0; ShipIndex < FleetShips.Num(); ShipIndex++)
	{
		FleetShips[ShipIndex]->SetCurrentFleet(NULL);
	}

	if (GetCurrentTradeRoute())
	{
		GetCurrentTradeRoute()->RemoveFleet(this);
	}
	GetCurrentSector()->DisbandFleet(this);
	FleetCompany->RemoveFleet(this);
}
Пример #6
0
	void iLight3D::AddShadowCaster(iRenderable* apObject, cFrustum* apFrustum, bool abStatic,cRenderList *apRenderList)
	{
		//Log("Testing: %s\n",apObject->GetName().c_str());
		/////////////////////////////////////////////////////
		// Check if the object should be added
		eRenderableType renderType = apObject->GetRenderType();

		//Is it affected by the light.
		if(GetOnlyAffectInSector() && apObject->IsInSector(GetCurrentSector())==false) return;

		//Is it visible
		if(apObject->GetForceShadow()==false)
		{
			if(apObject->IsVisible()==false) return;
			//Does the object cast shadows?
			if(apObject->IsShadowCaster()==false) return;

			//Can be material cast shadows?
			iMaterial *pMaterial = apObject->GetMaterial();
			if(pMaterial){
				if(pMaterial->IsTransperant() || pMaterial->HasAlpha()) return;
			}

			//Check so that the object is the right type
			if(renderType != eRenderableType_Mesh && renderType != eRenderableType_Normal) {
				return;
			}
		}

		//Log("Right type!\n");

		//Check if the object has all ready been added
		if(abStatic)
		{
			if(m_setStaticCasters.find(apObject) != m_setStaticCasters.end()) return;
		}
		else
		{
			if(m_setDynamicCasters.find(apObject) != m_setDynamicCasters.end()) return;
		}

		//Log("Not in list!\n");

		//Check if the object touches the light.
		//if(CollidesWithBV(apObject->GetBoundingVolume())==false){
		//	return;
		//}

		if(CheckObjectIntersection(apObject)==false) return;

		//Log("Collides!\n");

		//Log("Shadow is in frustum!\n");

		////////////////////////////////////////////////////
		// All checks passed, add the object!
		if(renderType == eRenderableType_Mesh)
		{
			cMeshEntity* pMesh = static_cast<cMeshEntity*>(apObject);

			///Need to add shadow casted objects else shadows might get choppy.
			if(abStatic == false){
				pMesh->SetGlobalRenderCount(cRenderList::GetGlobalRenderCount());
			}

			for(int i=0;i<pMesh->GetSubMeshEntityNum();i++)
			{
				cSubMeshEntity *pSub = pMesh->GetSubMeshEntity(i);

				if(pSub->IsVisible()==false) continue;
				if(apObject->GetForceShadow()==false)
				{
					iMaterial *pMaterial = pSub->GetMaterial();
					if(pMaterial){
						if(pMaterial->IsTransperant() || pMaterial->HasAlpha()) continue;
					}
				}

				if(abStatic)
				{
					m_setStaticCasters.insert(pSub);
				}
				else
				{
					m_setDynamicCasters.insert(pSub);
					///Need to add shadow casted objects else shadows might get choppy.
					pSub->SetGlobalRenderCount(cRenderList::GetGlobalRenderCount());
				}
			}
		}
		else
		{
			if(abStatic)
			{
				m_setStaticCasters.insert(apObject);
			}
			else
			{
				m_setDynamicCasters.insert(apObject);
				apObject->SetGlobalRenderCount(cRenderList::GetGlobalRenderCount());

			}
		}

	}