Skip to content

Commit eae3435

Browse files
committed
Added compatibility list in door type asset
1 parent 0dbf480 commit eae3435

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

Source/ProceduralDungeon/Private/DoorType.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ UDoorType::UDoorType()
1717
Color = FColor::Blue;
1818
Description = FText::FromString(TEXT("No Description"));
1919
#endif
20+
bCompatibleWithItself = true;
2021
}
2122

2223
FVector UDoorType::GetSize(const UDoorType* DoorType)
@@ -33,3 +34,18 @@ FColor UDoorType::GetColor(const UDoorType* DoorType)
3334
{
3435
return IsValid(DoorType) ? DoorType->Color : Dungeon::DefaultDoorColor();
3536
}
37+
38+
bool UDoorType::AreCompatible(const UDoorType* A, const UDoorType* B)
39+
{
40+
// If both are null, they are compatible
41+
if (!IsValid(A) && !IsValid(B))
42+
return true;
43+
44+
// If only one of them is null, they are not compatible
45+
if (!IsValid(A) || !IsValid(B))
46+
return false;
47+
48+
if (A == B)
49+
return A->bCompatibleWithItself;
50+
return A->Compatibility.Contains(B) || B->Compatibility.Contains(A);
51+
}

Source/ProceduralDungeon/Private/ProceduralDungeonTypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ bool FDoorDef::operator==(const FDoorDef& Other) const
228228

229229
bool FDoorDef::AreCompatible(const FDoorDef& A, const FDoorDef& B)
230230
{
231-
return A.Type == B.Type;
231+
return UDoorType::AreCompatible(A.Type, B.Type);
232232
}
233233

234234
FVector FDoorDef::GetDoorSize() const

Source/ProceduralDungeon/Public/DoorType.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class PROCEDURALDUNGEON_API UDoorType : public UDataAsset
3333
// Returns the door color from the door type asset,
3434
// or the default door color in plugin's settings if no door type defined.
3535
static FColor GetColor(const UDoorType* DoorType);
36+
37+
// Returns true if one of the door type is explicitely set to be compatible with the other.
38+
static bool AreCompatible(const UDoorType* A, const UDoorType* B);
3639

3740
protected:
3841
// Size of the door bounds, only used by the debug draw as a visual hint for designers and artists.
@@ -52,4 +55,12 @@ class PROCEDURALDUNGEON_API UDoorType : public UDataAsset
5255
UPROPERTY(EditInstanceOnly, Category = "Door Type")
5356
FText Description;
5457
#endif
58+
59+
// Can this door type be connected with itself?
60+
UPROPERTY(EditInstanceOnly, Category = "Door Type")
61+
bool bCompatibleWithItself;
62+
63+
// Which door types are compatible with this one
64+
UPROPERTY(EditInstanceOnly, Category = "Door Type")
65+
TArray<UDoorType*> Compatibility;
5566
};

0 commit comments

Comments
 (0)