add PreconditionRequirement and RelatedModule requirement
This commit is contained in:
@@ -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)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()))})";
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user