float UInterpToMovementComponent::CalculateNewTime( float TimeNow, float Delta, FHitResult& HitResult, bool InBroadcastEvent, bool& OutStopped )
{
	float NewTime = TimeNow;
	OutStopped = false;
	if (bIsWaiting == false)
	{
		NewTime += ((Delta*TimeMultiplier)*CurrentDirection);
		if (NewTime >= 1.0f)
		{
			if (BehaviourType == EInterpToBehaviourType::OneShot)
			{
				NewTime = 1.0f;
				OutStopped = true;
				if(InBroadcastEvent == true )
				{
					OnInterpToStop.Broadcast(HitResult, NewTime);
				}
			}
			else if(BehaviourType == EInterpToBehaviourType::Loop_Reset)
			{
				NewTime = 0.0f;
				if (InBroadcastEvent == true)
				{
					OnResetDelegate.Broadcast(HitResult, NewTime);
				}
			}
			else
			{
				FHitResult DummyHit;
				NewTime = ReverseDirection(DummyHit,NewTime, InBroadcastEvent);
			}	
		}
		else if (NewTime < 0.0f)
		{
			if (BehaviourType == EInterpToBehaviourType::OneShot_Reverse)
			{
				NewTime = 0.0f;
				bStopped = true;
				if (InBroadcastEvent == true)
				{
					OnInterpToStop.Broadcast(HitResult, NewTime);
				}				
			}
			else if (BehaviourType == EInterpToBehaviourType::PingPong)
			{

				FHitResult DummyHit;
				NewTime = ReverseDirection(DummyHit, NewTime, InBroadcastEvent);
			}			
		}
	}
	return NewTime;
}
Exemplo n.º 2
0
/**--------------------------------------------------------------------------<BR>
C2DLineBaseSet::AddIfCommonEnd
\brief Adds the points of another to this if they have a common end which is either
the first or last point. Returns true if there was a match.
<P>---------------------------------------------------------------------------*/
bool C2DLineBaseSet::AddIfCommonEnd(C2DLineBaseSet& Other)
{
	assert(!IsClosed());
	assert(!Other.IsClosed());

	int nThisCount = size() ;
	if (nThisCount < 1) return false;

	int nOtherCount = Other.size();
	if (nOtherCount < 1) return false;

	if ( GetAt(0)->GetPointFrom() == Other.GetAt(0)->GetPointFrom())
	{
		ReverseDirection();

		*this << Other;

		return true;
	}
	else if( GetAt(0)->GetPointFrom() == Other.GetAt(nOtherCount - 1)->GetPointTo() )
	{
		ReverseDirection();

		Other.ReverseDirection();

		*this << Other;

		return true;
	}
	else if (GetAt(nThisCount - 1)->GetPointTo() == Other.GetAt(0)->GetPointFrom())
	{
		*this << Other;

		return true;
	}	
	else if (GetAt(nThisCount - 1)->GetPointTo() == Other.GetAt(nOtherCount - 1)->GetPointTo() )
	{
		Other.ReverseDirection();	

		*this << Other;

		return true;
	}	

	return false;
}
void UInterpToMovementComponent::HandleImpact(const FHitResult& Hit, float Time, const FVector& MoveDelta)
{
	if( bPauseOnImpact == false )
	{
		switch(BehaviourType )
		{
		case EInterpToBehaviourType::OneShot:
			OnInterpToStop.Broadcast(Hit, Time);
			bStopped = true;
			StopSimulating(Hit);
			return;
		case EInterpToBehaviourType::OneShot_Reverse:
			if( CurrentDirection == -1.0f)
			{
				OnInterpToStop.Broadcast(Hit, Time);
				bStopped = true;
				StopSimulating(Hit);
				return;
			}
			else
			{
				ReverseDirection(Hit, Time, true);
			}
			break;
		case EInterpToBehaviourType::Loop_Reset:
			{
				CurrentTime = 0.0f;
				OnResetDelegate.Broadcast(Hit, CurrentTime);
			}
			break;
		default:
			ReverseDirection(Hit, Time, true);
			break;
		}		
	}
	else
	{
		if( bIsWaiting == false )
		{
			OnWaitBeginDelegate.Broadcast(Hit, Time);
			bIsWaiting = true;
		}
	}
}
Exemplo n.º 4
0
/**--------------------------------------------------------------------------<BR>
C2DPolyBase::Reflect <BR>
\brief Reflect
<P>---------------------------------------------------------------------------*/
void C2DPolyBase::Reflect(const C2DLine& Line)
{
	assert(m_Lines.size() == m_LineRects.size());

	if(m_Lines.size() != m_LineRects.size())
		return;

	for (unsigned int i = 0; i < m_Lines.size(); i++)
	{
		m_Lines[i].Reflect(Line);
	}
	ReverseDirection(); // ALSO MAKES THE LINES AGAIN.

	m_BoundingRect.Reflect(Line);
}
Exemplo n.º 5
0
void
Room::FindChild(void) {
    std::vector<Direction> available;
    SDL_Rect corridor;
    SDL_Rect roomspace;
    SDL_Rect roomspace_plusbuffer;
    int distance;
    Direction d;

    for (int i = NORTH; i < LAST_DIRECTION; ++i) {
        if (!children[i])
            available.push_back((Direction) i);
    }

    d = available[rand() % available.size()];

    //At this point we have one randomly selected available direction
    //And we need to make our corridor
    corridor = FindCorridor(d);
    if( !map->isSpaceAvailable(&corridor) )
        return;

    roomspace = FindRoomSpace(d, &corridor);
    if (roomspace.w == 0 || roomspace.h == 0)
        return;

    roomspace_plusbuffer.x = roomspace.x - 3;
    roomspace_plusbuffer.y = roomspace.y - 3;
    roomspace_plusbuffer.w = roomspace.w + 6;
    roomspace_plusbuffer.h = roomspace.h + 6;
    if( !map->isSpaceAvailable(&roomspace_plusbuffer) )
        return;

    map->ApplyCorridor(corridor);
    corridors[d] = corridor;
    children[d] = new Room(map, this, ReverseDirection(d), roomspace);
}
Exemplo n.º 6
0
/**--------------------------------------------------------------------------<BR>
C2DPolyArc::MakeClockwise <BR>
\brief .
<P>---------------------------------------------------------------------------*/
void C2DPolyBase::MakeClockwise(void)
{
	if (!IsClockwise())
		ReverseDirection();
}