This repository has been archived on 2025-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Cryville.EEW.Unity/Assets/Cryville.EEW.Unity/Map/Element/MapElement.cs
2025-02-14 16:06:00 +08:00

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++);
}
}