feat: add eating gizmo to TableBase
made a component tracking if colonists are allowed to eat at a table or not (doesn't actually forbid eating yet)
This commit is contained in:
parent
7a5ea082bf
commit
c298657f6f
3 changed files with 132 additions and 0 deletions
52
Source/EatableComp.cs
Normal file
52
Source/EatableComp.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue