48 lines
1.8 KiB
C#
48 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
namespace DepthsOfGreed.HandbookUI
|
|
{
|
|
public enum BuildFailure { None, OutsideRegion, Overlap, WallLimit, InteriorLimit, TypeLimit, Cooldown, Energy, Entrails, InvalidType, PathBlocked }
|
|
public readonly struct BuildCheck
|
|
{
|
|
public readonly BuildFailure failure;
|
|
public readonly string message;
|
|
public bool Allowed => failure == BuildFailure.None;
|
|
public BuildCheck(BuildFailure code, string text = null) { failure = code; message = text; }
|
|
}
|
|
public readonly struct BuildRequest
|
|
{
|
|
public readonly HandbookTowerEntry type;
|
|
public readonly Vector3 position;
|
|
public readonly float rotationDegrees;
|
|
public BuildRequest(HandbookTowerEntry entry, Vector3 point, float angle = 0) { type = entry; position = point; rotationDegrees = angle; }
|
|
}
|
|
public sealed class BuiltObjectSnapshot
|
|
{
|
|
public long instanceId;
|
|
public HandbookTowerEntry type;
|
|
public Vector3 position;
|
|
public float rotationDegrees;
|
|
public GameObject instance;
|
|
public int upgradeLevel;
|
|
public float expiresAt;
|
|
}
|
|
// Implement on a MonoBehaviour and assign HandbookController.gameplayBackend.
|
|
public interface IHandbookGameplay
|
|
{
|
|
event Action StateChanged;
|
|
int Energy { get; }
|
|
int Entrails { get; }
|
|
int WallCount { get; }
|
|
int WallLimit { get; }
|
|
IReadOnlyList<BuiltObjectSnapshot> BuiltObjects { get; }
|
|
BuildCheck CheckAvailability(HandbookTowerEntry type);
|
|
BuildCheck CheckBuild(BuildRequest request);
|
|
BuildCheck ExecuteBuild(BuildRequest request);
|
|
BuildCheck CheckUpgrade(long instanceId);
|
|
BuildCheck ExecuteUpgrade(long instanceId);
|
|
float GetCooldownRemaining(HandbookTowerEntry type);
|
|
}
|
|
}
|