Newer
Older
DungeonShooting / DungeonShooting_Godot / src / framework / map / fog / RoomFogMask.cs
@小李xl 小李xl on 22 Sep 2023 714 bytes 地牢迷雾,开发中

using Godot;

public partial class RoomFogMask : PointLight2D, IDestroy
{
    public bool IsDestroyed { get; private set; }
    private bool _init = false;
    
    public void Init(RoomInfo roomInfo, Rect2I rect2)
    {
        if (_init)
        {
            return;
        }
        GlobalPosition = rect2.Position + rect2.Size / 2;
        
        //创建光纹理
        var img = Image.Create(rect2.Size.X, rect2.Size.Y, false, Image.Format.Rgba8);
        img.Fill(Colors.White);
        Texture = ImageTexture.CreateFromImage(img);
    }
    
    public void Destroy()
    {
        if (IsDestroyed)
        {
            return;
        }

        IsDestroyed = true;
        QueueFree();
    }
}