diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index e2e0a19..a3950b3 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -180,4 +180,6 @@ ManualIPAddress= [ConsoleVariables] -mass.FullyParallel=False \ No newline at end of file +mass.FullyParallel=False +[CoreRedirects] ++ClassRedirects=(OldName="/Script/MassSample.MSBPFunctionLibarary",NewName="/Script/MassSample.MSBPFunctionLibrary") \ No newline at end of file diff --git a/Config/DefaultInput.ini b/Config/DefaultInput.ini index 2d2a116..b7802b2 100644 --- a/Config/DefaultInput.ini +++ b/Config/DefaultInput.ini @@ -79,6 +79,7 @@ DoubleClickTime=0.200000 +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar) +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Gamepad_FaceButton_Bottom) +ActionMappings=(ActionName="PrimaryAction",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton) ++ActionMappings=(ActionName="SecondaryAction",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=RightMouseButton) +AxisMappings=(AxisName="Move Forward / Backward",Scale=1.000000,Key=W) +AxisMappings=(AxisName="Move Forward / Backward",Scale=-1.000000,Key=S) +AxisMappings=(AxisName="Move Forward / Backward",Scale=1.000000,Key=Gamepad_LeftY) diff --git a/Content/MassSample/Blueprints/BP_FirstPersonCharacter.uasset b/Content/MassSample/Blueprints/BP_FirstPersonCharacter.uasset index 38b2c35..bc3fd1d 100644 --- a/Content/MassSample/Blueprints/BP_FirstPersonCharacter.uasset +++ b/Content/MassSample/Blueprints/BP_FirstPersonCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d0f68f0073603bdaa354a55ce7a00eadd744e49e60f4a881f34cb635bc05d633 -size 208560 +oid sha256:fac23dff987a955dd76ca7c60bcec969c9ac5e9beadc75ce714bfb4adf34934c +size 300067 diff --git a/Content/MassSample/Maps/CrowdGym.umap b/Content/MassSample/Maps/CrowdGym.umap index bef5a83..36c8020 100644 --- a/Content/MassSample/Maps/CrowdGym.umap +++ b/Content/MassSample/Maps/CrowdGym.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3af359afd719f14d43336021ac0d2303f79a9f2ea9eb531dcbd1e623bba57b41 -size 96080 +oid sha256:a71a9c5507adf1b406bb57acac93c8b7b5228ea595346a407f1acbbdaba3d0ce +size 94978 diff --git a/Content/Misc/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset b/Content/Misc/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset index 4f8cf72..66e495d 100644 --- a/Content/Misc/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset +++ b/Content/Misc/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c7e58c7b4c24b382fda1c1331eb24d07797c207d38c7d478e25949bd3a1a3753 -size 247963 +oid sha256:31089540d83af5f5919936ca473905dfa5f6f14842b31f28cec4f0a2e7d194b8 +size 260315 diff --git a/Content/Misc/FirstPersonArms/Animations/FirstPerson_JumpStart.uasset b/Content/Misc/FirstPersonArms/Animations/FirstPerson_JumpStart.uasset index 33f812f..7ecd560 100644 --- a/Content/Misc/FirstPersonArms/Animations/FirstPerson_JumpStart.uasset +++ b/Content/Misc/FirstPersonArms/Animations/FirstPerson_JumpStart.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3a36e430d39a6353229feee9816140bfed88bd689d600f1a5a0456ae3c9bdcbf -size 178494 +oid sha256:b209ca51ddb9a96f56b9dfaf16be3112d643a127b6ce4a9ffae3720e3d3f73f1 +size 98589 diff --git a/Source/MassSample/Common/Fragments/MSHashGridFragments.h b/Source/MassSample/Common/Fragments/MSHashGridFragments.h index 9dae636..f17880c 100644 --- a/Source/MassSample/Common/Fragments/MSHashGridFragments.h +++ b/Source/MassSample/Common/Fragments/MSHashGridFragments.h @@ -11,7 +11,6 @@ //todo: less weird place to stuff this? some types thing? oh well... typedef UE::Geometry::TPointHashGrid3 FMSHashGrid3D; - //This entity's startomg location on our 2D hashgrid this frame USTRUCT() struct MASSSAMPLE_API FMSGridCellStartingLocationFragment : public FMassFragment diff --git a/Source/MassSample/Common/Misc/MSBPFunctionLibarary.cpp b/Source/MassSample/Common/Misc/MSBPFunctionLibrary.cpp similarity index 58% rename from Source/MassSample/Common/Misc/MSBPFunctionLibarary.cpp rename to Source/MassSample/Common/Misc/MSBPFunctionLibrary.cpp index 3da8b7f..beff93e 100644 --- a/Source/MassSample/Common/Misc/MSBPFunctionLibarary.cpp +++ b/Source/MassSample/Common/Misc/MSBPFunctionLibrary.cpp @@ -1,18 +1,19 @@ // Fill out your copyright notice in the Description page of Project Settings. -#include "MSBPFunctionLibarary.h" +#include "MSBPFunctionLibrary.h" #include "MassCommonFragments.h" #include "MassEntityConfigAsset.h" #include "MassEntityTemplateRegistry.h" #include "MassExecutor.h" #include "MassMovementFragments.h" +#include "MassProcessingPhase.h" #include "MSSubsystem.h" #include "AI/NavigationSystemBase.h" #include "ProjectileSim/Fragments/MSProjectileFragments.h" -FEntityHandleWrapper UMSBPFunctionLibarary::SpawnEntityFromEntityConfig(AActor* Owner, UMassEntityConfigAsset* MassEntityConfig, +FEntityHandleWrapper UMSBPFunctionLibrary::SpawnEntityFromEntityConfig(AActor* Owner, UMassEntityConfigAsset* MassEntityConfig, const UObject* WorldContextObject) { @@ -39,7 +40,7 @@ FEntityHandleWrapper UMSBPFunctionLibarary::SpawnEntityFromEntityConfig(AActor* return FEntityHandleWrapper(); } -void UMSBPFunctionLibarary::SetEntityTransform(const FEntityHandleWrapper EntityHandle,const FTransform Transform,const UObject* WorldContextObject) +void UMSBPFunctionLibrary::SetEntityTransform(const FEntityHandleWrapper EntityHandle,const FTransform Transform,const UObject* WorldContextObject) { const UMassEntitySubsystem* EntitySubSystem = WorldContextObject->GetWorld()->GetSubsystem(); @@ -53,7 +54,7 @@ void UMSBPFunctionLibarary::SetEntityTransform(const FEntityHandleWrapper Entity } -void UMSBPFunctionLibarary::SetEntityCollisionQueryIgnoredActors(const FEntityHandleWrapper EntityHandle,const TArray IgnoredActors,const UObject* WorldContextObject) +void UMSBPFunctionLibrary::SetEntityCollisionQueryIgnoredActors(const FEntityHandleWrapper EntityHandle,const TArray IgnoredActors,const UObject* WorldContextObject) { const UMassEntitySubsystem* EntitySubSystem = WorldContextObject->GetWorld()->GetSubsystem(); @@ -66,11 +67,13 @@ void UMSBPFunctionLibarary::SetEntityCollisionQueryIgnoredActors(const FEntityHa } } -FTransform UMSBPFunctionLibarary::GetEntityTransform(const FEntityHandleWrapper EntityHandle,const UObject* WorldContextObject) +FTransform UMSBPFunctionLibrary::GetEntityTransform(const FEntityHandleWrapper EntityHandle,const UObject* WorldContextObject) { const UMassEntitySubsystem* EntitySubSystem = WorldContextObject->GetWorld()->GetSubsystem(); check(EntitySubSystem) + + if(!EntitySubSystem->IsEntityValid(EntityHandle.Entity)) return FTransform::Identity; if(const auto TransformFragmentPtr = EntitySubSystem->GetFragmentDataPtr(EntityHandle.Entity)) { @@ -81,7 +84,7 @@ FTransform UMSBPFunctionLibarary::GetEntityTransform(const FEntityHandleWrapper } -void UMSBPFunctionLibarary::SetEntityForce(const FEntityHandleWrapper EntityHandle,const FVector Force,const UObject* WorldContextObject) +void UMSBPFunctionLibrary::SetEntityForce(const FEntityHandleWrapper EntityHandle,const FVector Force,const UObject* WorldContextObject) { const UMassEntitySubsystem* EntitySubSystem = WorldContextObject->GetWorld()->GetSubsystem(); @@ -96,7 +99,7 @@ void UMSBPFunctionLibarary::SetEntityForce(const FEntityHandleWrapper EntityHand -void UMSBPFunctionLibarary::FindHashGridEntitiesInSphere(const FVector Location, double Radius, TArray& Entities ,const UObject* WorldContextObject) +void UMSBPFunctionLibrary::FindHashGridEntitiesInSphere(const FVector Location,const double Radius, TArray& Entities ,const UObject* WorldContextObject) { QUICK_SCOPE_CYCLE_COUNTER(FindHashGridEntitiesInSphere); @@ -123,7 +126,37 @@ void UMSBPFunctionLibarary::FindHashGridEntitiesInSphere(const FVector Location, } } -void UMSBPFunctionLibarary::AddFragmentToEntity(FFragmentWrapper Fragment, FEntityHandleWrapper Entity, +void UMSBPFunctionLibrary::FindClosestHashGridEntityInSphere(const FVector Location,const double Radius, FEntityHandleWrapper& Entity ,const UObject* WorldContextObject,TEnumAsByte& ReturnBranch) +{ + + QUICK_SCOPE_CYCLE_COUNTER(FindCloestHashGridEntityInSphere); + + if(auto MassSampleSystem = WorldContextObject->GetWorld()->GetSubsystem()) + { + auto EntitySystem = WorldContextObject->GetWorld()->GetSubsystem(); + + const auto FoundEntityHashMember = MassSampleSystem->HashGrid.FindNearestInRadius(Location, Radius, + //todo-performance it feels bad to get random entities to query... + [&,Location](const FMassEntityHandle Entity) + { + const FVector EntityLocation = EntitySystem->GetFragmentDataPtr(Entity)-> + GetTransform().GetLocation(); + return UE::Geometry::DistanceSquared(Location, EntityLocation); + }); + + if(FoundEntityHashMember.Key.IsValid()) + { + Entity.Entity = FoundEntityHashMember.Key; + ReturnBranch = EReturnSuccess::Success; + } + else + { + ReturnBranch = EReturnSuccess::Failure; + } + } +} + +void UMSBPFunctionLibrary::AddFragmentToEntity(FFragmentWrapper Fragment, FEntityHandleWrapper Entity, const UObject* WorldContextObject) { @@ -132,4 +165,22 @@ void UMSBPFunctionLibarary::AddFragmentToEntity(FFragmentWrapper Fragment, FEnti } +FString UMSBPFunctionLibrary::GetEntityDebugString(FEntityHandleWrapper Entity, const UObject* WorldContextObject) +{ + auto EntitySystem = WorldContextObject->GetWorld()->GetSubsystem(); + check(EntitySystem) + + if (!Entity.Entity.IsValid()) + return FString(); + + + FStringOutputDevice OutPut; + OutPut.SetAutoEmitLineTerminator(true); + EntitySystem->DebugPrintEntity(Entity.Entity,OutPut); + + + return FString{OutPut}; + +} + diff --git a/Source/MassSample/Common/Misc/MSBPFunctionLibarary.h b/Source/MassSample/Common/Misc/MSBPFunctionLibrary.h similarity index 81% rename from Source/MassSample/Common/Misc/MSBPFunctionLibarary.h rename to Source/MassSample/Common/Misc/MSBPFunctionLibrary.h index b8a06fb..d6d5c41 100644 --- a/Source/MassSample/Common/Misc/MSBPFunctionLibarary.h +++ b/Source/MassSample/Common/Misc/MSBPFunctionLibrary.h @@ -7,7 +7,8 @@ #include "MassEntityTypes.h" -#include "MSBPFunctionLibarary.generated.h" +#include "MSBPFunctionLibrary.generated.h" + USTRUCT(BlueprintType) @@ -15,10 +16,11 @@ struct FEntityHandleWrapper { GENERATED_BODY() FMassEntityHandle Entity; - + }; + USTRUCT(BlueprintType) struct FFragmentWrapper { @@ -29,8 +31,15 @@ struct FFragmentWrapper }; +UENUM(BlueprintType) +enum EReturnSuccess +{ + Success, + Failure +}; + UCLASS() -class MASSSAMPLE_API UMSBPFunctionLibarary : public UBlueprintFunctionLibrary +class MASSSAMPLE_API UMSBPFunctionLibrary : public UBlueprintFunctionLibrary { GENERATED_BODY() @@ -53,13 +62,18 @@ class MASSSAMPLE_API UMSBPFunctionLibarary : public UBlueprintFunctionLibrary UFUNCTION(BlueprintCallable, Category = "Mass", meta = (WorldContext = "WorldContextObject")) - static void FindHashGridEntitiesInSphere(const FVector Location, double Radius, TArray& Entities ,const UObject* WorldContextObject); + static void FindHashGridEntitiesInSphere(const FVector Location,const double Radius, TArray& Entities ,const UObject* WorldContextObject); + + UFUNCTION(BlueprintCallable, Category = "Mass", meta = (WorldContext = "WorldContextObject",ExpandEnumAsExecs = "ReturnBranch")) + static void FindClosestHashGridEntityInSphere(const FVector Location,const double Radius, FEntityHandleWrapper& Entity, const UObject* WorldContextObject,TEnumAsByte& ReturnBranch); UFUNCTION(BlueprintCallable, Category = "Mass", meta = (WorldContext = "WorldContextObject")) static void AddFragmentToEntity(FFragmentWrapper Fragment , FEntityHandleWrapper Entity ,const UObject* WorldContextObject); + UFUNCTION(BlueprintCallable, Category = "Mass", meta = (WorldContext = "WorldContextObject")) + static FString GetEntityDebugString(FEntityHandleWrapper Entity, const UObject* WorldContextObject); diff --git a/Source/MassSample/ProjectileSim/MassProjectileHitInterface.h b/Source/MassSample/ProjectileSim/MassProjectileHitInterface.h index 4c7454d..fea532c 100644 --- a/Source/MassSample/ProjectileSim/MassProjectileHitInterface.h +++ b/Source/MassSample/ProjectileSim/MassProjectileHitInterface.h @@ -3,7 +3,7 @@ #pragma once #include "CoreMinimal.h" -#include "Common/Misc/MSBPFunctionLibarary.h" +#include "Common/Misc/MSBPFunctionLibrary.h" #include "UObject/Interface.h" #include "MassProjectileHitInterface.generated.h"