ManiaMap.Unity
Procedural generation of metroidvania style maps for Unity.
RoomFlag.cs
1using UnityEngine;
2
4{
8 public class RoomFlag : CellChild
9 {
10 [Header("Room Flag:")]
11 [SerializeField] private bool _editId;
15 public bool EditId { get => _editId; set => _editId = value; }
16
17 [SerializeField] private int _id = -1;
21 public int Id { get => _id; set => _id = value; }
22
23 public override void AutoAssign(RoomComponent room)
24 {
25 base.AutoAssign(room);
27 }
28
32 public bool FlagIsSet()
33 {
34 return Room.RoomState.Flags.Contains(Id);
35 }
36
40 public bool SetFlag()
41 {
42 return Room.RoomState.Flags.Add(Id);
43 }
44
48 public bool RemoveFlag()
49 {
50 return Room.RoomState.Flags.Remove(Id);
51 }
52
56 public bool ToggleFlag()
57 {
58 if (Room.RoomState.Flags.Add(Id))
59 return true;
60
61 Room.RoomState.Flags.Remove(Id);
62 return false;
63 }
64 }
65}
An object tied to the cell index of a RoomComponent.
Definition: CellChild.cs:10
RoomComponent Room
The containing room.
Definition: CellChild.cs:37
Contains methods for creating random ID's.
Definition: Rand.cs:9
static int AutoAssignId(int id)
If the specified ID is greater than zero, returns the ID. Otherwise, returns a random positive intege...
Definition: Rand.cs:15
A component for creating a room.
RoomState RoomState
The room state.
A unique room flag.
Definition: RoomFlag.cs:9
bool FlagIsSet()
True if the flag is set.
Definition: RoomFlag.cs:32
bool RemoveFlag()
Removes the flag. Returns true if the flag was removed.
Definition: RoomFlag.cs:48
override void AutoAssign(RoomComponent room)
Performs auto assignment on the object.
Definition: RoomFlag.cs:23
bool ToggleFlag()
Toggles the flag. Returns true if the flag is now set. Otherwise, returns false.
Definition: RoomFlag.cs:56
bool EditId
If true, the ID can be edited in the inspector.
Definition: RoomFlag.cs:15
bool SetFlag()
Sets the flag. Returns true if the flag was not already set.
Definition: RoomFlag.cs:40
int Id
The unique flag ID.
Definition: RoomFlag.cs:21