module state game objects

This commit is contained in:
2022-11-13 20:49:32 +01:00
parent 14ab0374cc
commit 5f19adcb43
13 changed files with 251 additions and 84 deletions

View File

@@ -1,6 +1,5 @@
using System;
using UnityEngine;
using LogType = Escape_Room_Engine.Engine.Scripts.Utilities.LogType;
namespace Escape_Room_Engine.Engine.Scripts.Modules
{
@@ -14,19 +13,24 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules
{
public bool IsEntrance => IsType((ModuleType)DoorType.Entrance);
public bool IsExit => IsType((ModuleType)DoorType.Exit);
private bool _unlocked;
internal new DoorState State { get; private set; }
internal DoorModule(Space space, DoorModuleDescription description) : base(space, description)
{
srDimensions.Size = Vector2Int.one; // door always has size 1x1
}
internal void Unlock()
internal override void InstantiateModule(Transform parent)
{
_unlocked = true;
base.InstantiateModule(parent);
Utilities.Logger.Log($"{this} has been unlocked", LogType.PuzzleFlow);
space.room.AddDoor(this);
}
protected override void AddStateComponent()
{
State = moduleObject.AddComponent<DoorState>();
State.SetModule(this);
}
public override string ToString()