40 lines
959 B
C#
40 lines
959 B
C#
using System;
|
|
using System.Drawing;
|
|
using System.Runtime.CompilerServices;
|
|
using UnityEngine;
|
|
|
|
namespace Cryville.EEW.Unity.Map.Element {
|
|
abstract class MapElement : MonoBehaviour {
|
|
public abstract RectangleF? AABB { get; }
|
|
|
|
public float MaxScale { get; set; }
|
|
float m_scale;
|
|
public float Scale {
|
|
get => m_scale;
|
|
set {
|
|
m_scale = value;
|
|
OnSetScale();
|
|
}
|
|
}
|
|
public float ComputedScale => Math.Min(MaxScale, Scale);
|
|
protected virtual void OnSetScale() { }
|
|
|
|
[SerializeField]
|
|
bool m_inheritMaterial = true;
|
|
public bool InheritMaterial => m_inheritMaterial;
|
|
[SerializeField]
|
|
Material m_material;
|
|
public Material Material {
|
|
get => m_material;
|
|
set {
|
|
m_material = value;
|
|
OnSetMaterial(value);
|
|
}
|
|
}
|
|
protected virtual void OnSetMaterial(Material material) { }
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
protected static float OrderToZ(ref int order) => MapElementManager.OrderToZ(order++);
|
|
}
|
|
}
|