mirror of
https://github.com/Theaninova/BeatLanguageMapper.git
synced 2026-04-20 03:18:54 +00:00
Initial Commit!
いきますよ!
This commit is contained in:
@@ -0,0 +1,429 @@
|
||||
/*
|
||||
By TK-Master
|
||||
*/
|
||||
#include "VictoryBPLibraryPrivatePCH.h"
|
||||
|
||||
#include "TKMathFunctionLibrary.h"
|
||||
|
||||
#include "StaticMeshResources.h"
|
||||
|
||||
//UTKMathFunctionLibrary
|
||||
|
||||
float UTKMathFunctionLibrary::GetConsoleVariableFloat(FString VariableName)
|
||||
{
|
||||
const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataFloat(*VariableName);
|
||||
|
||||
if (CVar)
|
||||
{
|
||||
return CVar->GetValueOnGameThread();
|
||||
//return CVar->GetValueOnAnyThread();
|
||||
}
|
||||
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
int32 UTKMathFunctionLibrary::GetConsoleVariableInt(FString VariableName)
|
||||
{
|
||||
const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(*VariableName);
|
||||
|
||||
if (CVar)
|
||||
{
|
||||
return CVar->GetValueOnGameThread();
|
||||
//return CVar->GetValueOnAnyThread();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float UTKMathFunctionLibrary::NegateFloat(float A)
|
||||
{
|
||||
return -A;
|
||||
}
|
||||
|
||||
int32 UTKMathFunctionLibrary::NegateInt(int32 A)
|
||||
{
|
||||
return -A;
|
||||
}
|
||||
|
||||
FVector2D UTKMathFunctionLibrary::NegateVector2D(FVector2D A)
|
||||
{
|
||||
return -A;
|
||||
}
|
||||
|
||||
FVector UTKMathFunctionLibrary::SetVectorLength(FVector A, float size)
|
||||
{
|
||||
return A.GetSafeNormal() * size;
|
||||
}
|
||||
|
||||
FVector UTKMathFunctionLibrary::VectorRadiansToDegrees(FVector RadVector)
|
||||
{
|
||||
return FVector::RadiansToDegrees(RadVector);
|
||||
}
|
||||
|
||||
FVector UTKMathFunctionLibrary::VectorDegreesToRadians(FVector DegVector)
|
||||
{
|
||||
return FVector::DegreesToRadians(DegVector);
|
||||
}
|
||||
|
||||
int32 UTKMathFunctionLibrary::RoundToLowerMultiple(int32 A, int32 Multiple, bool skipSelf)
|
||||
{
|
||||
int32 result = (A / Multiple) * Multiple;
|
||||
if (skipSelf && result == A && result != 0)
|
||||
{
|
||||
return ((A-1) / Multiple) * Multiple;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32 UTKMathFunctionLibrary::RoundToUpperMultiple(int32 A, int32 Multiple, bool skipSelf)
|
||||
{
|
||||
if (skipSelf || FMath::Fmod(A, Multiple) != 0)
|
||||
{
|
||||
A = ((A + Multiple) / Multiple) * Multiple;
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
int32 UTKMathFunctionLibrary::RoundToNearestMultiple(int32 A, int32 Multiple)
|
||||
{
|
||||
return ((A + Multiple / 2) / Multiple) * Multiple;
|
||||
}
|
||||
|
||||
bool UTKMathFunctionLibrary::IsPowerOfTwo(int32 x)
|
||||
{
|
||||
//return x && ((x&-x) == x);
|
||||
return FMath::IsPowerOfTwo(x);
|
||||
}
|
||||
|
||||
bool UTKMathFunctionLibrary::IsMultipleOf(int32 A, int32 Multiple)
|
||||
{
|
||||
return FMath::Fmod(A, Multiple) == 0;
|
||||
}
|
||||
|
||||
bool UTKMathFunctionLibrary::IsEvenNumber(float A)
|
||||
{
|
||||
return FMath::Fmod(A, 2) == 0;
|
||||
}
|
||||
|
||||
FVector UTKMathFunctionLibrary::ClosestPointOnSphereToLine(FVector SphereOrigin, float SphereRadius, FVector LineOrigin, FVector LineDir)
|
||||
{
|
||||
static FVector OutClosestPoint;
|
||||
FMath::SphereDistToLine(SphereOrigin, SphereRadius, LineOrigin, LineDir.GetSafeNormal(), OutClosestPoint);
|
||||
return OutClosestPoint;
|
||||
}
|
||||
|
||||
FVector UTKMathFunctionLibrary::ClosestPointOnLineSeqment(FVector Point, FVector LineStart, FVector LineEnd)
|
||||
{
|
||||
return FMath::ClosestPointOnLine(LineStart, LineEnd, Point);
|
||||
}
|
||||
|
||||
bool UTKMathFunctionLibrary::IsPointInsideBox(FVector Point, FVector BoxOrigin, FVector BoxExtent)
|
||||
{
|
||||
FBox Box = FBox::BuildAABB(BoxOrigin, BoxExtent);
|
||||
return FMath::PointBoxIntersection(Point, Box);
|
||||
}
|
||||
|
||||
bool UTKMathFunctionLibrary::SphereBoxIntersection(FVector SphereOrigin, float SphereRadius, FVector BoxOrigin, FVector BoxExtent)
|
||||
{
|
||||
FBox Box = FBox::BuildAABB(BoxOrigin, BoxExtent);
|
||||
return FMath::SphereAABBIntersection(SphereOrigin, FMath::Square(SphereRadius), Box);
|
||||
}
|
||||
|
||||
bool UTKMathFunctionLibrary::IsLineInsideSphere(FVector LineStart, FVector LineDir, float LineLength, FVector SphereOrigin, float SphereRadius)
|
||||
{
|
||||
return FMath::LineSphereIntersection(LineStart, LineDir, LineLength, SphereOrigin, SphereRadius);
|
||||
}
|
||||
|
||||
bool UTKMathFunctionLibrary::LineExtentBoxIntersection(FBox inBox, FVector Start, FVector End, FVector Extent, FVector& HitLocation, FVector& HitNormal, float& HitTime)
|
||||
{
|
||||
return FMath::LineExtentBoxIntersection(inBox, Start, End, Extent, HitLocation, HitNormal, HitTime);
|
||||
}
|
||||
|
||||
float UTKMathFunctionLibrary::SignedDistancePlanePoint(FVector planeNormal, FVector planePoint, FVector point)
|
||||
{
|
||||
return FVector::DotProduct(planeNormal, (point - planePoint));
|
||||
}
|
||||
|
||||
FVector UTKMathFunctionLibrary::ProjectPointOnLine(FVector LineOrigin, FVector LineDirection, FVector Point)
|
||||
{
|
||||
//FVector linePointToPoint = point - linePoint;
|
||||
//float t = FVector::DotProduct(linePointToPoint, lineDir);
|
||||
//return linePoint + lineDir * t;
|
||||
|
||||
//FVector closestPoint;
|
||||
//OutDistance = FMath::PointDistToLine(point, lineDir, linePoint, closestPoint);
|
||||
//return closestPoint;
|
||||
|
||||
FVector SafeDir = LineDirection.GetSafeNormal();
|
||||
return LineOrigin + (SafeDir * ((Point - LineOrigin) | SafeDir));
|
||||
}
|
||||
|
||||
void UTKMathFunctionLibrary::ClosestPointsOfLineSegments(FVector Line1Start, FVector Line1End, FVector Line2Start, FVector Line2End, FVector& LinePoint1, FVector& LinePoint2)
|
||||
{
|
||||
FMath::SegmentDistToSegmentSafe(Line1Start, Line1End, Line2Start, Line2End, LinePoint1, LinePoint2);
|
||||
}
|
||||
|
||||
bool UTKMathFunctionLibrary::LineToLineIntersection(FVector& IntersectionPoint, FVector LinePoint1, FVector LineDir1, FVector LinePoint2, FVector LineDir2)
|
||||
{
|
||||
//Are lines coplanar?
|
||||
if (!FVector::Coplanar(LinePoint1, LineDir1, LinePoint2, LineDir2, DELTA))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
FVector LineDir3 = LinePoint2 - LinePoint1;
|
||||
FVector CrossDir1And2 = FVector::CrossProduct(LineDir1, LineDir2);
|
||||
FVector CrossDir3And2 = FVector::CrossProduct(LineDir3, LineDir2);
|
||||
|
||||
float s = FVector::DotProduct(CrossDir3And2, CrossDir1And2) / CrossDir1And2.SizeSquared();
|
||||
|
||||
if (s > 1.0f || s < 0.0f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
IntersectionPoint = LinePoint1 + (LineDir1 * s);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool UTKMathFunctionLibrary::ClosestPointsOnTwoLines(FVector& closestPointLine1, FVector& closestPointLine2, FVector linePoint1, FVector lineVec1, FVector linePoint2, FVector lineVec2)
|
||||
{
|
||||
float a = FVector::DotProduct(lineVec1, lineVec1);
|
||||
float b = FVector::DotProduct(lineVec1, lineVec2);
|
||||
float e = FVector::DotProduct(lineVec2, lineVec2);
|
||||
|
||||
float d = a*e - b*b;
|
||||
|
||||
//lines are not parallel
|
||||
if (d != 0.0f)
|
||||
{
|
||||
FVector r = linePoint1 - linePoint2;
|
||||
float c = FVector::DotProduct(lineVec1, r);
|
||||
float f = FVector::DotProduct(lineVec2, r);
|
||||
|
||||
float s = (b*f - c*e) / d;
|
||||
float t = (a*f - c*b) / d;
|
||||
|
||||
closestPointLine1 = linePoint1 + lineVec1 * s;
|
||||
closestPointLine2 = linePoint2 + lineVec2 * t;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int32 UTKMathFunctionLibrary::PointOnWhichSideOfLineSegment(FVector linePoint1, FVector linePoint2, FVector point)
|
||||
{
|
||||
FVector lineVec = linePoint2 - linePoint1;
|
||||
FVector pointVec = point - linePoint1;
|
||||
|
||||
float dot = FVector::DotProduct(pointVec, lineVec);
|
||||
|
||||
//point is on side of linePoint2, compared to linePoint1
|
||||
if (dot > 0)
|
||||
{
|
||||
//point is on the line segment
|
||||
if (pointVec.Size() <= lineVec.Size())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//point is not on the line segment and it is on the side of linePoint2
|
||||
else
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
//Point is not on side of linePoint2, compared to linePoint1.
|
||||
//Point is not on the line segment and it is on the side of linePoint1.
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
bool UTKMathFunctionLibrary::AreLineSegmentsCrossing(FVector pointA1, FVector pointA2, FVector pointB1, FVector pointB2)
|
||||
{
|
||||
FVector closestPointA;
|
||||
FVector closestPointB;
|
||||
int32 sideA;
|
||||
int32 sideB;
|
||||
|
||||
FVector lineVecA = pointA2 - pointA1;
|
||||
FVector lineVecB = pointB2 - pointB1;
|
||||
|
||||
bool valid = ClosestPointsOnTwoLines(closestPointA, closestPointB, pointA1, lineVecA.GetSafeNormal(), pointB1, lineVecB.GetSafeNormal());
|
||||
|
||||
//lines are not parallel
|
||||
if (valid)
|
||||
{
|
||||
sideA = PointOnWhichSideOfLineSegment(pointA1, pointA2, closestPointA);
|
||||
sideB = PointOnWhichSideOfLineSegment(pointB1, pointB2, closestPointB);
|
||||
|
||||
if ((sideA == 0) && (sideB == 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//lines are parallel
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
FVector UTKMathFunctionLibrary::GridSnap(FVector A, float Grid)
|
||||
{
|
||||
return A.GridSnap(Grid);
|
||||
}
|
||||
|
||||
void UTKMathFunctionLibrary::ConvertAnchorToAnchor(UObject* WorldContextObject, FAnchors CurrentAnchor, FMargin Offsets, FAnchors TargetAnchor, FMargin& ConvertedOffsets)
|
||||
{
|
||||
if (CurrentAnchor.Minimum == TargetAnchor.Minimum && CurrentAnchor.Maximum == TargetAnchor.Maximum)
|
||||
{
|
||||
ConvertedOffsets = Offsets;
|
||||
return;
|
||||
}
|
||||
|
||||
FVector2D View = FVector2D(1, 1);
|
||||
UWorld* World = GEngine->GetWorldFromContextObjectChecked(WorldContextObject);
|
||||
if (World && World->IsGameWorld())
|
||||
{
|
||||
if (UGameViewportClient* ViewportClient = World->GetGameViewport())
|
||||
{
|
||||
ViewportClient->GetViewportSize(View);
|
||||
}
|
||||
}
|
||||
|
||||
FMargin ZeroAnchorOffsets = Offsets;
|
||||
//Convert to 0,0 anchor first.
|
||||
if (CurrentAnchor.Minimum != FVector2D(0, 0) || CurrentAnchor.Maximum != FVector2D(0, 0))
|
||||
{
|
||||
ZeroAnchorOffsets.Left = View.X * CurrentAnchor.Minimum.X + Offsets.Left;
|
||||
ZeroAnchorOffsets.Top = View.Y * CurrentAnchor.Minimum.Y + Offsets.Top;
|
||||
|
||||
if (CurrentAnchor.Minimum.X != CurrentAnchor.Maximum.X)
|
||||
{
|
||||
ZeroAnchorOffsets.Right = View.X * CurrentAnchor.Maximum.X - (Offsets.Right + Offsets.Left);
|
||||
}
|
||||
if (CurrentAnchor.Minimum.Y != CurrentAnchor.Maximum.Y)
|
||||
{
|
||||
ZeroAnchorOffsets.Bottom = View.Y * CurrentAnchor.Maximum.Y - (Offsets.Bottom + Offsets.Top);
|
||||
}
|
||||
|
||||
if (TargetAnchor.Minimum == FVector2D(0, 0) && TargetAnchor.Maximum == FVector2D(0, 0))
|
||||
{
|
||||
ConvertedOffsets = ZeroAnchorOffsets;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Convert 0,0 anchor offsets to target anchor offsets.
|
||||
ConvertedOffsets.Left = (-View.X) * TargetAnchor.Minimum.X + ZeroAnchorOffsets.Left;
|
||||
ConvertedOffsets.Top = (-View.Y) * TargetAnchor.Minimum.Y + ZeroAnchorOffsets.Top;
|
||||
|
||||
ConvertedOffsets.Right = TargetAnchor.Minimum.X != TargetAnchor.Maximum.X ? View.X * TargetAnchor.Maximum.X - (ZeroAnchorOffsets.Left + ZeroAnchorOffsets.Right) : ZeroAnchorOffsets.Right;
|
||||
ConvertedOffsets.Bottom = TargetAnchor.Minimum.Y != TargetAnchor.Maximum.Y ? View.Y * TargetAnchor.Maximum.Y - (ZeroAnchorOffsets.Top + ZeroAnchorOffsets.Bottom) : ZeroAnchorOffsets.Bottom;
|
||||
}
|
||||
|
||||
|
||||
float UTKMathFunctionLibrary::ConvertPhysicsLinearVelocity(FVector Velocity, TEnumAsByte<enum ESpeedUnit> SpeedUnit)
|
||||
{
|
||||
if (Velocity.IsZero()) return 0.f;
|
||||
|
||||
float unit = 0;
|
||||
switch (SpeedUnit)
|
||||
{
|
||||
case CentimeterPerSecond:
|
||||
unit = 1;
|
||||
break;
|
||||
case FootPerSecond:
|
||||
unit = 0.03280839895013;
|
||||
break;
|
||||
case MeterPerSecond:
|
||||
unit = 0.01;
|
||||
break;
|
||||
case MeterPerMinute:
|
||||
unit = 0.6;
|
||||
break;
|
||||
case KilometerPerSecond:
|
||||
unit = 0.00001;
|
||||
case KilometerPerMinute:
|
||||
unit = 0.0006;
|
||||
break;
|
||||
case KilometerPerHour:
|
||||
unit = 0.036;
|
||||
break;
|
||||
case MilePerHour:
|
||||
unit = 0.02236936292054;
|
||||
break;
|
||||
case Knot:
|
||||
unit = 0.01943844492441;
|
||||
break;
|
||||
case Mach:
|
||||
unit = 0.00002915451895044;
|
||||
break;
|
||||
case SpeedOfLight:
|
||||
unit = 3.335640951982E-11;
|
||||
break;
|
||||
case YardPerSecond:
|
||||
unit = 0.01093613298338;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
return Velocity.Size() * unit;
|
||||
}
|
||||
|
||||
FVector UTKMathFunctionLibrary::GetVelocityAtPoint(UPrimitiveComponent* Target, FVector Point, FName BoneName, bool DrawDebugInfo)
|
||||
{
|
||||
|
||||
//FTransform Transform = Target->GetComponentTransform();
|
||||
//FVector LocalLinearVelocity = Transform.InverseTransformVectorNoScale(Target->GetPhysicsLinearVelocity());
|
||||
//FVector LocalAngularVelocity = Transform.InverseTransformVectorNoScale(Target->GetPhysicsAngularVelocity());
|
||||
//FVector ResultPointVelocity = LocalLinearVelocity + FVector::CrossProduct(FVector::DegreesToRadians(LocalAngularVelocity), Transform.InverseTransformVectorNoScale(Point - Target->GetCenterOfMass()));
|
||||
|
||||
|
||||
if (!Target) return FVector::ZeroVector;
|
||||
|
||||
//You can actually get it from the physx body instance instead.
|
||||
FBodyInstance* BI = Target->GetBodyInstance(BoneName);
|
||||
if (BI && BI->IsValidBodyInstance())
|
||||
{
|
||||
FVector PointVelocity = BI->GetUnrealWorldVelocityAtPoint(Point);
|
||||
|
||||
UWorld* TheWorld = Target->GetWorld();
|
||||
if (DrawDebugInfo && TheWorld)
|
||||
{
|
||||
FColor DefaultColor(255,200,0);
|
||||
DrawDebugPoint(TheWorld, Point, 10, DefaultColor);
|
||||
DrawDebugString(TheWorld, Point, FString::SanitizeFloat(PointVelocity.Size()), NULL, FColor::White, 0.0f);
|
||||
}
|
||||
|
||||
return PointVelocity;
|
||||
}
|
||||
return FVector::ZeroVector;
|
||||
}
|
||||
|
||||
void UTKMathFunctionLibrary::SetCenterOfMassOffset(UPrimitiveComponent* Target, FVector Offset, FName BoneName)
|
||||
{
|
||||
if (!Target) return;
|
||||
|
||||
FBodyInstance* BI = Target->GetBodyInstance(BoneName);
|
||||
if (BI && BI->IsValidBodyInstance())
|
||||
{
|
||||
BI->COMNudge = Offset;
|
||||
BI->UpdateMassProperties();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
By Rama
|
||||
*/
|
||||
|
||||
#include "VictoryBPLibraryPrivatePCH.h"
|
||||
#include "VictoryBPFunctionLibrary.h"
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
#include "AllowWindowsPlatformTypes.h"
|
||||
//#include "AdditionalWindowsHeaders.h"
|
||||
#endif
|
||||
|
||||
void UVictoryBPFunctionLibrary::FlashGameOnTaskBar(APlayerController* PC, bool FlashContinuous, int32 MaxFlashCount, int32 FlashFrequencyMilliseconds)
|
||||
{
|
||||
#if PLATFORM_WINDOWS
|
||||
if(!PC) return;
|
||||
|
||||
//Local Player
|
||||
ULocalPlayer* VictoryPlayer = Cast<ULocalPlayer>(PC->Player);
|
||||
if(!VictoryPlayer) return;
|
||||
|
||||
//Game Viewport Client
|
||||
UGameViewportClient* GameViewport = Cast<UGameViewportClient>(VictoryPlayer->ViewportClient);
|
||||
if(!GameViewport) return;
|
||||
|
||||
//Slate Game Window
|
||||
TSharedPtr< SWindow > GWSlate = GameViewport->GetWindow();
|
||||
if(!GWSlate.IsValid()) return;
|
||||
|
||||
//Native OS Window
|
||||
TSharedPtr<FGenericWindow> GW = GWSlate->GetNativeWindow();
|
||||
if(!GW.IsValid()) return;
|
||||
|
||||
//Windows
|
||||
FLASHWINFO fi;
|
||||
fi.cbSize = sizeof(FLASHWINFO);
|
||||
fi.hwnd = (HWND)GW->GetOSWindowHandle();
|
||||
fi.dwFlags = FLASHW_ALL;
|
||||
|
||||
//Continuous? <3 Rama
|
||||
if(FlashContinuous)
|
||||
{
|
||||
fi.dwFlags |= FLASHW_TIMERNOFG;
|
||||
fi.uCount = 0;
|
||||
fi.dwTimeout = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fi.uCount = MaxFlashCount;
|
||||
fi.dwTimeout = FlashFrequencyMilliseconds;
|
||||
}
|
||||
|
||||
FlashWindowEx(&fi);
|
||||
#endif
|
||||
|
||||
//<3 Rama
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
#include "HideWindowsPlatformTypes.h"
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
By Rama
|
||||
*/
|
||||
#include "VictoryBPLibraryPrivatePCH.h"
|
||||
#include "VictoryBPHTML.h"
|
||||
|
||||
#if PLATFORM_HTML5
|
||||
#include "SDL_opengl.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY_STATIC(VictoryPluginHTML, Log, All);
|
||||
|
||||
#include "emscripten.h"
|
||||
#include "html5.h"
|
||||
#endif
|
||||
|
||||
bool UVictoryBPHTML::IsHTML()
|
||||
{
|
||||
#if PLATFORM_HTML5
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif //HTML
|
||||
}
|
||||
|
||||
void UVictoryBPHTML::VictoryHTML5_SetCursorVisible(bool MakeVisible)
|
||||
{
|
||||
if(MakeVisible)
|
||||
{
|
||||
#if PLATFORM_HTML5
|
||||
{
|
||||
emscripten_exit_pointerlock();
|
||||
UE_LOG(VictoryPluginHTML, Warning, TEXT("Exiting Pointer Lock"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if PLATFORM_HTML5
|
||||
{
|
||||
emscripten_request_pointerlock ( "#canvas" , true);
|
||||
UE_LOG(VictoryPluginHTML, Warning, TEXT("Entering Pointer Lock"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
By Rama
|
||||
*/
|
||||
#include "VictoryBPLibraryPrivatePCH.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FVictoryBPLibraryModule"
|
||||
|
||||
|
||||
void FVictoryBPLibraryModule::StartupModule()
|
||||
{
|
||||
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
|
||||
|
||||
}
|
||||
|
||||
void FVictoryBPLibraryModule::ShutdownModule()
|
||||
{
|
||||
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
|
||||
// we call this function before unloading the module.
|
||||
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FVictoryBPLibraryModule, VictoryBPLibrary)
|
||||
@@ -0,0 +1,4 @@
|
||||
/*
|
||||
By Rama
|
||||
*/
|
||||
#include "VictoryBPLibrary.h"
|
||||
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
By TK-Master
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//For the Anchor Conversion
|
||||
#include "Runtime/UMG/Public/UMG.h"
|
||||
|
||||
#include "TKMathFunctionLibrary.generated.h"
|
||||
|
||||
/* Speed Units Enum. */
|
||||
UENUM()
|
||||
enum ESpeedUnit
|
||||
{
|
||||
/* Centimeter / second (cm/s). This is default unreal velocity unit. */
|
||||
CentimeterPerSecond,
|
||||
|
||||
/* Foot / second (ft/s). */
|
||||
FootPerSecond,
|
||||
|
||||
/* Meter / second (m/s). */
|
||||
MeterPerSecond,
|
||||
|
||||
/* Meter / minute (m/min). */
|
||||
MeterPerMinute,
|
||||
|
||||
/* Kilometer / second (km/s). */
|
||||
KilometerPerSecond,
|
||||
|
||||
/* Kilometer / minute (km/min). */
|
||||
KilometerPerMinute,
|
||||
|
||||
/*Kilometer / hour (km/h). */
|
||||
KilometerPerHour,
|
||||
|
||||
/* Mile / hour (mph). */
|
||||
MilePerHour,
|
||||
|
||||
/* Knot (kn). Nautical mile per hour. */
|
||||
Knot,
|
||||
|
||||
/* Mach (speed of sound) (M) at standard atm. */
|
||||
Mach,
|
||||
|
||||
/* Speed of light. */
|
||||
SpeedOfLight,
|
||||
|
||||
/* Yard / second. */
|
||||
YardPerSecond
|
||||
};
|
||||
|
||||
|
||||
UCLASS()
|
||||
class VICTORYBPLIBRARY_API UTKMathFunctionLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|Console")
|
||||
static float GetConsoleVariableFloat(FString VariableName);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|Console")
|
||||
static int32 GetConsoleVariableInt(FString VariableName);
|
||||
|
||||
//Reverses the sign (- or +) of a float.
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Float")
|
||||
static float NegateFloat(float A);
|
||||
|
||||
//Reverses the sign (- or +) of an integer.
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Integer")
|
||||
static int32 NegateInt(int32 A);
|
||||
|
||||
//Reverses the sign (- or +) of a Vector2D.
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector2D")
|
||||
static FVector2D NegateVector2D(FVector2D A);
|
||||
|
||||
//Changes the size (length) of a Vector to the given size (normalized vector * size).
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector")
|
||||
static FVector SetVectorLength(FVector A, float size);
|
||||
|
||||
//Converts radians to degrees.
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector")
|
||||
static FVector VectorRadiansToDegrees(FVector RadVector);
|
||||
|
||||
//Converts degrees to radians.
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector")
|
||||
static FVector VectorDegreesToRadians(FVector DegVector);
|
||||
|
||||
/**
|
||||
* Rounds an integer to the lower multiple of the given number.
|
||||
* If Skip Self is set to True it will skip to the previous multiple if the integer rounds to itself.
|
||||
* @param Multiple - The multiple number to round to.
|
||||
* @param skipSelf - Skip to the previous multiple if the integer rounds to itself.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Integer")
|
||||
static int32 RoundToLowerMultiple(int32 A, int32 Multiple = 32, bool skipSelf = false);
|
||||
|
||||
/**
|
||||
* Rounds an integer to the upper multiple of the given number.
|
||||
* If Skip Self is set to True it will skip to the next multiple if the integer rounds to itself.
|
||||
* @param Multiple - The multiple number to round to.
|
||||
* @param skipSelf - Skip to the next multiple if the integer rounds to itself.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Integer")
|
||||
static int32 RoundToUpperMultiple(int32 A, int32 Multiple = 32, bool skipSelf = false);
|
||||
|
||||
/** Rounds an integer to the nearest multiple of the given number. */
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Integer")
|
||||
static int32 RoundToNearestMultiple(int32 A, int32 Multiple = 32);
|
||||
|
||||
/** Returns true if the integer is a power of two number. */
|
||||
UFUNCTION(BlueprintPure, meta = (CompactNodeTitle = "PwrOf2"), Category = "Victory BP Library|TK-Master Math|Integer")
|
||||
static bool IsPowerOfTwo(int32 x);
|
||||
|
||||
/** Returns true if the integer is a multiple of the given number. */
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Integer")
|
||||
static bool IsMultipleOf(int32 A, int32 Multiple);
|
||||
|
||||
/** Returns true if the number is even (false if it's odd). */
|
||||
UFUNCTION(BlueprintPure, meta = (CompactNodeTitle = "isEven"), Category = "Victory BP Library|TK-Master Math|Float")
|
||||
static bool IsEvenNumber(float A);
|
||||
|
||||
/**
|
||||
* Find closest point on a Sphere to a Line.
|
||||
* When line intersects Sphere, then closest point to LineOrigin is returned.
|
||||
* @param SphereOrigin Origin of Sphere
|
||||
* @param SphereRadius Radius of Sphere
|
||||
* @param LineOrigin Origin of line
|
||||
* @param LineDir Direction of line.
|
||||
* @return Closest point on sphere to given line.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector")
|
||||
static FVector ClosestPointOnSphereToLine(FVector SphereOrigin, float SphereRadius, FVector LineOrigin, FVector LineDir);
|
||||
|
||||
/** Find the point on line segment from LineStart to LineEnd which is closest to Point. */
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector")
|
||||
static FVector ClosestPointOnLineSeqment(FVector Point, FVector LineStart, FVector LineEnd);
|
||||
|
||||
/** Returns true if the given Point vector is within a box (defined by BoxOrigin and BoxExtent). */
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector|Intersection")
|
||||
static bool IsPointInsideBox(FVector Point, FVector BoxOrigin, FVector BoxExtent);
|
||||
|
||||
/** Determines whether a line intersects a sphere. */
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector|Intersection")
|
||||
static bool IsLineInsideSphere(FVector LineStart, FVector LineDir, float LineLength, FVector SphereOrigin, float SphereRadius);
|
||||
|
||||
/**
|
||||
* Swept-Box vs Box test.
|
||||
* Sweps a box defined by Extend from Start to End points and returns whether it hit a box or not plus the hit location and hit normal if successful.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector|Intersection")
|
||||
static bool LineExtentBoxIntersection(FBox inBox, FVector Start, FVector End, FVector Extent, FVector& HitLocation, FVector& HitNormal, float& HitTime);
|
||||
|
||||
/**
|
||||
* Get the shortest distance between a point and a plane.
|
||||
* The output is signed so it holds information as to which side of the plane normal the point is.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector")
|
||||
static float SignedDistancePlanePoint(FVector planeNormal, FVector planePoint, FVector point);
|
||||
|
||||
/**
|
||||
* Returns a vector point which is a projection from a point to a line (defined by the vector couple LineOrigin, LineDirection).
|
||||
* The line is infinite (in both directions).
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector")
|
||||
static FVector ProjectPointOnLine(FVector LineOrigin, FVector LineDirection, FVector Point);
|
||||
|
||||
/**
|
||||
* Performs a sphere vs box intersection test.
|
||||
* @param SphereOrigin the center of the sphere being tested against the box.
|
||||
* @param SphereRadius the size of the sphere being tested.
|
||||
* @param BoxOrigin the box origin being tested against.
|
||||
* @param BoxExtent the box extend (width, depth, height).
|
||||
* @return Whether the sphere/box intersect or not.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector|Intersection")
|
||||
static bool SphereBoxIntersection(FVector SphereOrigin, float SphereRadius, FVector BoxOrigin, FVector BoxExtent);
|
||||
|
||||
/**
|
||||
* Find closest points between 2 line segments.
|
||||
* @param (Line1Start, Line1End) defines the first line segment.
|
||||
* @param (Line2Start, Line2End) defines the second line segment.
|
||||
* @param LinePoint1 Closest point on segment 1 to segment 2.
|
||||
* @param LinePoint2 Closest point on segment 2 to segment 1.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector|Intersection")
|
||||
static void ClosestPointsOfLineSegments(FVector Line1Start, FVector Line1End, FVector Line2Start, FVector Line2End, FVector& LinePoint1, FVector& LinePoint2);
|
||||
|
||||
/**
|
||||
* Calculate the intersection point of two infinitely long lines. Returns true if lines intersect, otherwise false.
|
||||
* Note that in 3d, two lines do not intersect most of the time.
|
||||
* So if the two lines are not in the same plane, use Closest Points On Two Lines instead.
|
||||
* @param IntersectionPoint The intersection point of the lines. Returns zero if the lines do not intersect or the operation fails.
|
||||
* @param LinePoint1 Line point of the first line.
|
||||
* @param LineDir1 Line direction (normal) of the first line. Should be a normalized vector.
|
||||
* @param LinePoint2 Line point of the second line.
|
||||
* @param LineDir2 Line direction (normal) of the second line. Should be a normalized vector.
|
||||
* @return true if lines intersect, otherwise false.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector|Intersection")
|
||||
static bool LineToLineIntersection(FVector& IntersectionPoint, FVector LinePoint1, FVector LineDir1, FVector LinePoint2, FVector LineDir2);
|
||||
|
||||
/*
|
||||
* Calculate the closest points between two infinitely long lines.
|
||||
* If lines are intersecting (not parallel) it will return false! Use Line To Line Intersection instead.
|
||||
* @param closestPointLine1 The closest point of line1 to line2. Returns zero if the lines intersect.
|
||||
* @param closestPointLine2 The closest point of line2 to line1. Returns zero if the lines intersect.
|
||||
* @param linePoint1 Line point of the first line.
|
||||
* @param lineVec1 Line direction (normal) of the first line. Should be a normalized vector.
|
||||
* @param linePoint2 Line point of the second line.
|
||||
* @param lineVec2 Line direction (normal) of the second line. Should be a normalized vector.
|
||||
* @return true if lines are parallel, false otherwise.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector")
|
||||
static bool ClosestPointsOnTwoLines(FVector& closestPointLine1, FVector& closestPointLine2, FVector linePoint1, FVector lineVec1, FVector linePoint2, FVector lineVec2);
|
||||
|
||||
/*
|
||||
* Returns 0 if point is on the line segment.
|
||||
* Returns 1 if point is not on the line segment and it is on the side of linePoint1.
|
||||
* Returns 2 if point is not on the line segment and it is on the side of linePoint2.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector")
|
||||
static int32 PointOnWhichSideOfLineSegment(FVector linePoint1, FVector linePoint2, FVector point);
|
||||
|
||||
/*
|
||||
* Returns true if the two line segments are intersecting and not parallel.
|
||||
* If you need the intersection point, use Closest Points On Two Lines.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector|Intersection")
|
||||
static bool AreLineSegmentsCrossing(FVector pointA1, FVector pointA2, FVector pointB1, FVector pointB2);
|
||||
|
||||
/*Snaps vector to nearest grid multiple.*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector")
|
||||
static FVector GridSnap(FVector A, float Grid);
|
||||
|
||||
/*Converts UMG layout offsets to another anchor.*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Anchor", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
|
||||
static void ConvertAnchorToAnchor(UObject* WorldContextObject, FAnchors CurrentAnchor, FMargin Offsets, FAnchors TargetAnchor, FMargin& ConvertedOffsets);
|
||||
|
||||
/*Converts Physics Linear Velocity to a more useful speed unit.*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|TK-Master Math|Vector")
|
||||
static float ConvertPhysicsLinearVelocity(FVector Velocity, TEnumAsByte<enum ESpeedUnit> SpeedUnit);
|
||||
|
||||
//------------------------------------------------------------
|
||||
//Physics functions! (why aren't these exposed by Epic yet?!)
|
||||
|
||||
/**
|
||||
* Get the current world velocity of a point on a physics-enabled component.
|
||||
* @param Point - Point in world space.
|
||||
* @param DrawDebugInfo - Draw debug point & string.
|
||||
* @param BoneName - If a SkeletalMeshComponent, name of body to get velocity of. 'None' indicates root body.
|
||||
* @return The velocity of the point in world space.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "Physics")
|
||||
static FVector GetVelocityAtPoint(UPrimitiveComponent* Target, FVector Point, FName BoneName = NAME_None, bool DrawDebugInfo = false);
|
||||
|
||||
/*
|
||||
* Set the physx center of mass offset.
|
||||
* Note: this offsets the physx-calculated center of mass (it is not an offset from the pivot point).
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "Physics")
|
||||
static void SetCenterOfMassOffset(UPrimitiveComponent* Target, FVector Offset, FName BoneName = NAME_None);
|
||||
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
|
||||
By Rama
|
||||
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Runtime/Engine/Classes/Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "VictoryBPHTML.generated.h"
|
||||
|
||||
// BP Library for You
|
||||
//
|
||||
// Written by Rama
|
||||
|
||||
//note about UBlueprintFunctionLibrary
|
||||
// This class is a base class for any function libraries exposed to blueprints.
|
||||
// Methods in subclasses are expected to be static, and no methods should be added to the base class.
|
||||
|
||||
|
||||
UCLASS()
|
||||
class VICTORYBPLIBRARY_API UVictoryBPHTML : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
/** Is the current OS HTML5? This code will only run in games packaged for HTML5, it will not run in Editor builds :) Use this to customize particle FX for HTML5 vs PC builds! Or for any custom HTML5-specific game logic! <3 Rama*/
|
||||
UFUNCTION(BlueprintPure, Category = "Victory BP Library|HTML5")
|
||||
static bool IsHTML();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Victory BP Library|HTML5")
|
||||
static void VictoryHTML5_SetCursorVisible(bool MakeVisible);
|
||||
|
||||
};
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
By Rama
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "ModuleManager.h"
|
||||
|
||||
class FVictoryBPLibraryModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
|
||||
By Rama
|
||||
|
||||
*/
|
||||
#include "VictoryBPLibraryPrivatePCH.h"
|
||||
#include "VictoryISM.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// VictoryISM
|
||||
|
||||
AVictoryISM::AVictoryISM(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
RootComponent = Mesh = ObjectInitializer.CreateDefaultSubobject<UInstancedStaticMeshComponent>(this, "VictoryInstancedMesh");
|
||||
}
|
||||
|
||||
void AVictoryISM::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
//~~~~~~~~~
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
|
||||
By Rama
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Runtime/Engine/Classes/Components/InstancedStaticMeshComponent.h"
|
||||
#include "VictoryISM.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class AVictoryISM : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
AVictoryISM(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
UPROPERTY(Category = "Joy ISM", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
|
||||
UInstancedStaticMeshComponent* Mesh;
|
||||
|
||||
//~~~~~~~~~~~~~
|
||||
// ISM
|
||||
//~~~~~~~~~~~~~
|
||||
public:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
};
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
|
||||
By Rama
|
||||
|
||||
*/
|
||||
|
||||
#include "VictoryBPLibraryPrivatePCH.h"
|
||||
#include "VictoryPC.h"
|
||||
|
||||
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY(VictoryPCLog)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AVictoryPC
|
||||
|
||||
AVictoryPC::AVictoryPC(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
UAudioComponent* AVictoryPC::VictoryPlaySpeechSound(
|
||||
USoundBase* Sound
|
||||
,float VolumeMultiplier
|
||||
,float PitchMultiplier
|
||||
, float StartTime)
|
||||
{
|
||||
|
||||
UAudioComponent* Audio = UGameplayStatics::SpawnSound2D(this,Sound,VolumeMultiplier,PitchMultiplier,StartTime);
|
||||
if(Audio)
|
||||
{
|
||||
//Subtitle Delegate for You!
|
||||
// <3 Rama
|
||||
Audio->OnQueueSubtitles.BindDynamic(this, &AVictoryPC::Subtitles_CPPDelegate);
|
||||
}
|
||||
|
||||
/*
|
||||
Note that the OnAudioFinished is BP assignable off of return of this node!
|
||||
|
||||
//called when we finish playing audio, either because it played to completion or because a Stop() call turned it off early
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOnAudioFinished OnAudioFinished;
|
||||
*/
|
||||
|
||||
return Audio;
|
||||
}
|
||||
|
||||
void AVictoryPC::Subtitles_CPPDelegate(const TArray<struct FSubtitleCue>& Subtitles, float CueDuration)
|
||||
{
|
||||
TArray<FVictorySubtitleCue> VictorySubtitles;
|
||||
for(const FSubtitleCue& Each : Subtitles)
|
||||
{
|
||||
VictorySubtitles.Add(FVictorySubtitleCue(Each.Text,Each.Time));
|
||||
}
|
||||
|
||||
OnVictorySubtitlesQueued(VictorySubtitles,CueDuration);
|
||||
}
|
||||
|
||||
//~~~
|
||||
|
||||
bool AVictoryPC::VictoryPC_GetMyIP_SendRequest()
|
||||
{
|
||||
FHttpModule* Http = &FHttpModule::Get();
|
||||
|
||||
if(!Http)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!Http->IsHttpEnabled())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
FString TargetHost = "http://api.ipify.org";
|
||||
TSharedRef < IHttpRequest > Request = Http->CreateRequest();
|
||||
Request->SetVerb("GET");
|
||||
Request->SetURL(TargetHost);
|
||||
Request->SetHeader("User-Agent", "VictoryBPLibrary/1.0");
|
||||
Request->SetHeader("Content-Type" ,"text/html");
|
||||
|
||||
Request->OnProcessRequestComplete().BindUObject(this, &AVictoryPC::HTTPOnResponseReceived);
|
||||
if (!Request->ProcessRequest())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AVictoryPC::HTTPOnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
|
||||
{
|
||||
FString ResponseStr = "AVictoryPC::HTTPOnResponseReceived>>> Connection Error";
|
||||
if(bWasSuccessful)
|
||||
{
|
||||
ResponseStr = Response->GetContentAsString();
|
||||
}
|
||||
|
||||
this->VictoryPC_GetMyIP_DataReceived(ResponseStr);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
|
||||
By Rama
|
||||
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//HTTP
|
||||
#include "Http.h"
|
||||
|
||||
#include "Runtime/Engine/Classes/GameFramework/PlayerController.h"
|
||||
#include "VictoryPC.generated.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(VictoryPCLog, Log, All);
|
||||
|
||||
|
||||
//Exposing the UE4 Subtitle system for Solus
|
||||
// <3 Rama
|
||||
USTRUCT(BlueprintType)
|
||||
struct FVictorySubtitleCue
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
/** The text to appear in the subtitle. */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SubtitleCue)
|
||||
FText SubtitleText;
|
||||
|
||||
/** The time at which the subtitle is to be displayed, in seconds relative to the beginning of the line. */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SubtitleCue)
|
||||
float Time;
|
||||
|
||||
FVictorySubtitleCue()
|
||||
: Time(0)
|
||||
{ }
|
||||
FVictorySubtitleCue(const FText& InText, float InTime)
|
||||
: SubtitleText(InText)
|
||||
, Time(InTime)
|
||||
{}
|
||||
};
|
||||
|
||||
UCLASS()
|
||||
class VICTORYBPLIBRARY_API AVictoryPC : public APlayerController
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AVictoryPC(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
/**
|
||||
* When the sound is played OnVictorySubtitlesQueued will be called with the subtitles!
|
||||
* You can bind an event off of the audio component for OnAudioFinished to know hwen the sound is done!
|
||||
*/
|
||||
UFUNCTION(Category="Victory Subtitles", BlueprintCallable, BlueprintCosmetic, meta=( UnsafeDuringActorConstruction = "true", Keywords = "play" ))
|
||||
UAudioComponent* VictoryPlaySpeechSound(class USoundBase* Sound, float VolumeMultiplier = 1.f, float PitchMultiplier = 1.f, float StartTime = 0.f);
|
||||
|
||||
UFUNCTION(Category="Victory Subtitles", BlueprintImplementableEvent)
|
||||
void OnVictorySubtitlesQueued(const TArray<struct FVictorySubtitleCue>& VictorySubtitles, float CueDuration);
|
||||
|
||||
UFUNCTION()
|
||||
void Subtitles_CPPDelegate(const TArray<struct FSubtitleCue>& VictorySubtitles, float CueDuration);
|
||||
|
||||
public:
|
||||
/** This node relies on http://api.ipify.org, so if this node ever stops working, check out http://api.ipify.org. Returns false if the operation could not occur because HTTP module was not loaded or unable to process request. */
|
||||
UFUNCTION(BlueprintCallable, Category="Victory PC")
|
||||
bool VictoryPC_GetMyIP_SendRequest();
|
||||
|
||||
/** Implement this event to receive your IP once the request is processed! This requires that your computer has a live internet connection */
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "Victory PC", meta = (DisplayName = "Victory PC ~ GetMyIP ~ Data Received!"))
|
||||
void VictoryPC_GetMyIP_DataReceived(const FString& YourIP);
|
||||
|
||||
void HTTPOnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
|
||||
};
|
||||
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
|
||||
By Rama
|
||||
|
||||
*/
|
||||
|
||||
#include "VictoryBPLibraryPrivatePCH.h"
|
||||
#include "VictoryTMapComp.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY(VictoryTMapLog)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UVictoryTMapComp
|
||||
|
||||
UVictoryTMapComp::UVictoryTMapComp(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//~~~ Add ~~~
|
||||
void UVictoryTMapComp::String_Actor__AddPair(FString Key, AActor* Value)
|
||||
{
|
||||
StringActor.Add(Key,Value);
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::String_String__AddPair(FString Key, FString Value)
|
||||
{
|
||||
StringString.Add(Key,Value);
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::String_Int__AddPair(FString Key, int32 Value)
|
||||
{
|
||||
StringInt.Add(Key,Value);
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::String_Vector__AddPair(FString Key, FVector Value)
|
||||
{
|
||||
StringVector.Add(Key,Value);
|
||||
}
|
||||
void UVictoryTMapComp::String_Rotator__AddPair(FString Key, FRotator Value)
|
||||
{
|
||||
StringRotator.Add(Key,Value);
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::Int_Vector__AddPair(int32 Key, FVector Value)
|
||||
{
|
||||
IntVector.Add(Key,Value);
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::Int_Float__AddPair(int32 Key, float Value)
|
||||
{
|
||||
IntFloat.Add(Key,Value);
|
||||
}
|
||||
|
||||
//~~~ Get ~~~
|
||||
AActor* UVictoryTMapComp::String_Actor__Get(FString Key, bool& IsValid)
|
||||
{
|
||||
IsValid = false;
|
||||
if(!StringActor.Contains(Key))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
IsValid = true;
|
||||
return StringActor[Key];
|
||||
}
|
||||
|
||||
FString UVictoryTMapComp::String_String__Get(FString Key, bool& IsValid)
|
||||
{
|
||||
IsValid = false;
|
||||
if(!StringString.Contains(Key))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
IsValid = true;
|
||||
return StringString[Key];
|
||||
}
|
||||
|
||||
int32 UVictoryTMapComp::String_Int__Get(FString Key, bool& IsValid)
|
||||
{
|
||||
IsValid = false;
|
||||
if(!StringInt.Contains(Key))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
IsValid = true;
|
||||
return StringInt[Key];
|
||||
}
|
||||
|
||||
FVector UVictoryTMapComp::String_Vector__Get(FString Key, bool& IsValid)
|
||||
{
|
||||
IsValid = false;
|
||||
if(!StringVector.Contains(Key))
|
||||
{
|
||||
return FVector::ZeroVector;
|
||||
}
|
||||
IsValid = true;
|
||||
return StringVector[Key];
|
||||
}
|
||||
FRotator UVictoryTMapComp::String_Rotator__Get(FString Key, bool& IsValid)
|
||||
{
|
||||
IsValid = false;
|
||||
if(!StringRotator.Contains(Key))
|
||||
{
|
||||
return FRotator::ZeroRotator;
|
||||
}
|
||||
IsValid = true;
|
||||
return StringRotator[Key];
|
||||
}
|
||||
|
||||
FVector UVictoryTMapComp::Int_Vector__Get(int32 Key, bool& IsValid)
|
||||
{
|
||||
IsValid = false;
|
||||
if(!IntVector.Contains(Key))
|
||||
{
|
||||
return FVector::ZeroVector;
|
||||
}
|
||||
IsValid = true;
|
||||
return IntVector[Key];
|
||||
}
|
||||
|
||||
float UVictoryTMapComp::Int_Float__Get(int32 Key, bool& IsValid)
|
||||
{
|
||||
IsValid = false;
|
||||
if(!IntFloat.Contains(Key))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
IsValid = true;
|
||||
return IntFloat[Key];
|
||||
}
|
||||
|
||||
//~~~ Remove ~~~
|
||||
void UVictoryTMapComp::String_Actor__Remove(FString Key)
|
||||
{
|
||||
StringActor.Remove(Key);
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::String_String__Remove(FString Key)
|
||||
{
|
||||
StringString.Remove(Key);
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::String_Int__Remove(FString Key)
|
||||
{
|
||||
StringInt.Remove(Key);
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::String_Vector__Remove(FString Key)
|
||||
{
|
||||
StringVector.Remove(Key);
|
||||
}
|
||||
void UVictoryTMapComp::String_Rotator__Remove(FString Key)
|
||||
{
|
||||
StringRotator.Remove(Key);
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::Int_Vector__Remove(int32 Key)
|
||||
{
|
||||
IntVector.Remove(Key);
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::Int_Float__Remove(int32 Key, float Value)
|
||||
{
|
||||
IntFloat.Remove(Key);
|
||||
}
|
||||
|
||||
//~~~ Clear ~~~
|
||||
void UVictoryTMapComp::String_Actor__Clear()
|
||||
{
|
||||
StringActor.Empty();
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::String_String__Clear()
|
||||
{
|
||||
StringString.Empty();
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::String_Int__Clear()
|
||||
{
|
||||
StringInt.Empty();
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::String_Vector__Clear()
|
||||
{
|
||||
StringVector.Empty();
|
||||
}
|
||||
void UVictoryTMapComp::String_Rotator__Clear()
|
||||
{
|
||||
StringRotator.Empty();
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::Int_Vector__Clear()
|
||||
{
|
||||
IntVector.Empty();
|
||||
}
|
||||
|
||||
void UVictoryTMapComp::Int_Float__Clear()
|
||||
{
|
||||
IntFloat.Empty();
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
|
||||
By Rama
|
||||
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "VictoryTMapComp.generated.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(VictoryTMapLog, Log, All);
|
||||
|
||||
UCLASS(ClassGroup=VictoryBPLibrary, meta=(BlueprintSpawnableComponent))
|
||||
class UVictoryTMapComp : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UVictoryTMapComp(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
//Add
|
||||
public:
|
||||
/** If a key already exists in the TMap, its current value is replaced with your new value! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Add")
|
||||
void String_Actor__AddPair(FString Key, AActor* Value);
|
||||
|
||||
/** If a key already exists in the TMap, its current value is replaced with your new value! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Add")
|
||||
void String_String__AddPair(FString Key, FString Value);
|
||||
|
||||
/** If a key already exists in the TMap, its current value is replaced with your new value! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Add")
|
||||
void String_Int__AddPair(FString Key, int32 Value);
|
||||
|
||||
/** If a key already exists in the TMap, its current value is replaced with your new value! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Add")
|
||||
void String_Vector__AddPair(FString Key, FVector Value);
|
||||
|
||||
/** If a key already exists in the TMap, its current value is replaced with your new value! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Add")
|
||||
void String_Rotator__AddPair(FString Key, FRotator Value);
|
||||
|
||||
/** If a key already exists in the TMap, its current value is replaced with your new value! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Add")
|
||||
void Int_Vector__AddPair(int32 Key, FVector Value);
|
||||
|
||||
/** If a key already exists in the TMap, its current value is replaced with your new value! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Add")
|
||||
void Int_Float__AddPair(int32 Key, float Value);
|
||||
|
||||
//Get
|
||||
public:
|
||||
/** Get the value associated with they key at fastest possible speed! <3 Rama */
|
||||
UFUNCTION(BlueprintPure,Category="Victory BP Library|TMap Component|Get")
|
||||
AActor* String_Actor__Get(FString Key, bool& IsValid);
|
||||
|
||||
/** Get the value associated with they key at fastest possible speed! <3 Rama */
|
||||
UFUNCTION(BlueprintPure,Category="Victory BP Library|TMap Component|Get")
|
||||
FString String_String__Get(FString Key, bool& IsValid);
|
||||
|
||||
/** Get the value associated with they key at fastest possible speed! <3 Rama */
|
||||
UFUNCTION(BlueprintPure,Category="Victory BP Library|TMap Component|Get")
|
||||
int32 String_Int__Get(FString Key, bool& IsValid);
|
||||
|
||||
/** Get the value associated with they key at fastest possible speed! <3 Rama */
|
||||
UFUNCTION(BlueprintPure,Category="Victory BP Library|TMap Component|Get")
|
||||
FVector String_Vector__Get(FString Key, bool& IsValid);
|
||||
|
||||
/** Get the value associated with they key at fastest possible speed! <3 Rama */
|
||||
UFUNCTION(BlueprintPure,Category="Victory BP Library|TMap Component|Get")
|
||||
FRotator String_Rotator__Get(FString Key, bool& IsValid);
|
||||
|
||||
/** Get the value associated with they key at fastest possible speed! <3 Rama */
|
||||
UFUNCTION(BlueprintPure,Category="Victory BP Library|TMap Component|Get")
|
||||
FVector Int_Vector__Get(int32 Key, bool& IsValid);
|
||||
|
||||
/** Get the value associated with they key at fastest possible speed! <3 Rama */
|
||||
UFUNCTION(BlueprintPure,Category="Victory BP Library|TMap Component|Get")
|
||||
float Int_Float__Get(int32 Key, bool& IsValid);
|
||||
|
||||
//Remove
|
||||
public:
|
||||
/** Removes the key and any associated value from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Remove")
|
||||
void String_Actor__Remove(FString Key);
|
||||
|
||||
/** Removes the key and any associated value from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Remove")
|
||||
void String_String__Remove(FString Key);
|
||||
|
||||
/** Removes the key and any associated value from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Remove")
|
||||
void String_Int__Remove(FString Key);
|
||||
|
||||
/** Removes the key and any associated value from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Remove")
|
||||
void String_Vector__Remove(FString Key);
|
||||
|
||||
/** Removes the key and any associated value from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Remove")
|
||||
void String_Rotator__Remove(FString Key);
|
||||
|
||||
/** Removes the key and any associated value from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Remove")
|
||||
void Int_Vector__Remove(int32 Key);
|
||||
|
||||
/** Removes the key and any associated value from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Remove")
|
||||
void Int_Float__Remove(int32 Key, float Value);
|
||||
|
||||
//Clear
|
||||
public:
|
||||
/** Removes every entry from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Clear", meta = (Keywords = "Clear Empty Reset"))
|
||||
void String_Actor__Clear();
|
||||
|
||||
/** Removes every entry from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Clear", meta = (Keywords = "Clear Empty Reset"))
|
||||
void String_String__Clear();
|
||||
|
||||
/** Removes every entry from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Clear", meta = (Keywords = "Clear Empty Reset"))
|
||||
void String_Int__Clear();
|
||||
|
||||
/** Removes every entry from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Clear", meta = (Keywords = "Clear Empty Reset"))
|
||||
void String_Vector__Clear();
|
||||
|
||||
/** Removes every entry from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Clear", meta = (Keywords = "Clear Empty Reset"))
|
||||
void String_Rotator__Clear();
|
||||
|
||||
/** Removes every entry from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Clear", meta = (Keywords = "Clear Empty Reset"))
|
||||
void Int_Vector__Clear();
|
||||
|
||||
/** Removes every entry from the TMap! <3 Rama */
|
||||
UFUNCTION(BlueprintCallable,Category="Victory BP Library|TMap Component|Clear", meta = (Keywords = "Clear Empty Reset"))
|
||||
void Int_Float__Clear();
|
||||
|
||||
public:
|
||||
TMap<FString,AActor*> StringActor;
|
||||
TMap<FString,FString> StringString;
|
||||
TMap<FString,int32> StringInt;
|
||||
TMap<FString,FVector> StringVector;
|
||||
TMap<FString,FRotator> StringRotator;
|
||||
TMap<int32,FVector> IntVector;
|
||||
TMap<int32,float> IntFloat;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,93 @@
|
||||
// Some copyright should be here...
|
||||
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class VictoryBPLibrary : ModuleRules
|
||||
{
|
||||
public VictoryBPLibrary(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
//4.15 Include What You Use
|
||||
bEnforceIWYU = false;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
"VictoryBPLibrary/Public"
|
||||
|
||||
// ... add public include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
"VictoryBPLibrary/Private",
|
||||
|
||||
// ... add other private include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core"
|
||||
|
||||
// ... add other public dependencies that you statically link with here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"InputCore",
|
||||
|
||||
"RHI",
|
||||
"RenderCore",
|
||||
|
||||
"HTTP",
|
||||
"UMG", "Slate", "SlateCore",
|
||||
|
||||
"ImageWrapper",
|
||||
|
||||
"PhysX",
|
||||
|
||||
"HeadMountedDisplay",
|
||||
|
||||
"AIModule",
|
||||
|
||||
//FPlatformApplicationMisc
|
||||
"ApplicationCore"
|
||||
}
|
||||
);
|
||||
|
||||
//APEX EXCLUSIONS
|
||||
if (Target.Platform != UnrealTargetPlatform.Android && Target.Platform != UnrealTargetPlatform.HTML5 && Target.Platform != UnrealTargetPlatform.IOS)
|
||||
{
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"APEX"
|
||||
}
|
||||
);
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"ApexDestruction"
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
DynamicallyLoadedModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
// ... add any modules that your module loads dynamically here ...
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user