/*
Copyright 2025 Maciej Pawłowski

This file is part of "Table Eating Toggle".

"Table Eating Toggle" is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

"Table Eating Toggle" is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with "Table Eating Toggle". If not, see <https://www.gnu.org/licenses/>.
*/

using System.Collections.Generic;
using RimWorld;
using Verse;

namespace TableToggle;

public class EatableComp : ThingComp
{
    public bool EatableFrom = true;
    public override IEnumerable<Gizmo> CompGetGizmosExtra()
    {
        foreach (Gizmo item in base.CompGetGizmosExtra())
        {
            yield return item;
        }
        if (parent.Faction == Faction.OfPlayer)
        {
            Command_Toggle command_Toggle = new()
            {
                icon = TexCommand.ForbidOff,
                isActive = () => EatableFrom,
                defaultLabel = "eating",
                defaultDesc = "Colonists will eat from this table.",
                toggleAction = delegate
                {
                    EatableFrom = !EatableFrom;
                }
            };
            if (!EatableFrom)
            {
                command_Toggle.defaultDesc = "Colonists will not eat from this table.";
            }
            yield return command_Toggle;
        }
    }
    public override void PostExposeData()
    {
        Scribe_Values.Look(ref EatableFrom, "eatable", defaultValue: true);
    }
}