add PreconditionRequirement and RelatedModule requirement

This commit is contained in:
2022-11-20 18:05:50 +01:00
parent 1dcd6e67e1
commit 8ee43d6823
21 changed files with 270 additions and 7 deletions

View File

@@ -47,7 +47,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
}
else
{
throw new Exception("Tried to set wrong type of module.");
throw new Exception($"Tried to set wrong type of module ({module.GetType()} instead of DoorModule)");
}
}

View File

@@ -103,6 +103,24 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
State.SetModule(this);
}
internal static Module CreateModuleByType(Space space, ModuleDescription description)
{
if (description.HasType(ModuleType.Puzzle) &&
description is PuzzleModuleDescription puzzleModuleDescription)
{
return new PuzzleModule(space, puzzleModuleDescription);
}
else if((description.HasType(ModuleType.DoorEntrance) || description.HasType(ModuleType.DoorExit)) &&
description is DoorModuleDescription doorModuleDescription)
{
return new DoorModule(space, doorModuleDescription);
}
else
{
throw new Exception("Module description does not have fitting type.");
}
}
public override string ToString()
{
return $"Module ({string.Join(", ", description.types.ToList().ConvertAll(type => type.ToString()))})";

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using EscapeRoomEngine.Engine.Runtime.Requirements;
using NaughtyAttributes;
using UnityEngine;
namespace EscapeRoomEngine.Engine.Runtime.Modules
@@ -9,7 +10,16 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
{
public List<ModuleType> types = new();
public ModuleState modulePrefab;
[BoxGroup("Requirements")]
public List<PreconditionRequirement> preconditionRequirements = new();
[BoxGroup("Requirements")]
public List<PlacementRequirement> placementRequirements = new();
[BoxGroup("Requirements")]
public List<OrientationRequirement> orientationRequirements = new();
internal bool HasType(ModuleType type)
{
return types.Contains(type);
}
}
}

View File

@@ -64,7 +64,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
}
else
{
throw new Exception("Tried to set wrong type of module.");
throw new Exception($"Tried to set wrong type of module ({module.GetType()} instead of PuzzleModule)");
}
}