Client LuaCsForBarotrauma
Memento.cs
1
using
System.Collections.Generic;
2
using
System.Linq;
3
4
namespace
Barotrauma
5
{
6
interface
IMemorizable
<T>
7
{
8
Memento<T>
Memento
{
get
; }
9
void
StoreSnapshot
();
10
void
Undo
();
11
void
Redo
();
12
void
ClearHistory
();
13
}
14
15
public
class
Memento
<T>
16
{
17
public
T
Current
{
get
;
private
set
; }
18
19
public
int
UndoCount
=> undoStack.Count;
20
public
int
RedoCount
=> redoStack.Count;
21
22
private
Stack<T> undoStack =
new
Stack<T>();
23
private
Stack<T> redoStack =
new
Stack<T>();
24
25
public
void
Store
(T newState)
26
{
27
redoStack.Clear();
28
if
(
Current
!=
null
&& !
Current
.Equals(
default
(T)))
29
{
30
undoStack.Push(
Current
);
31
}
32
Current
= newState;
33
}
34
35
public
T
Undo
()
36
{
37
if
(undoStack.Any())
38
{
39
redoStack.Push(
Current
);
40
Current
= undoStack.Pop();
41
}
42
return
Current
;
43
}
44
45
public
T
Redo
()
46
{
47
if
(redoStack.Any())
48
{
49
undoStack.Push(
Current
);
50
Current
= redoStack.Pop();
51
}
52
return
Current
;
53
}
54
55
public
void
Clear
()
56
{
57
undoStack.Clear();
58
redoStack.Clear();
59
Current
=
default
(T);
60
}
61
}
62
}
Barotrauma.Memento
Definition:
Memento.cs:16
Barotrauma.Memento.Store
void Store(T newState)
Definition:
Memento.cs:25
Barotrauma.Memento.Redo
T Redo()
Definition:
Memento.cs:45
Barotrauma.Memento.Clear
void Clear()
Definition:
Memento.cs:55
Barotrauma.Memento.UndoCount
int UndoCount
Definition:
Memento.cs:19
Barotrauma.Memento.RedoCount
int RedoCount
Definition:
Memento.cs:20
Barotrauma.Memento.Undo
T Undo()
Definition:
Memento.cs:35
Barotrauma.Memento.Current
T Current
Definition:
Memento.cs:17
Barotrauma.IMemorizable
Definition:
Memento.cs:7
Barotrauma.IMemorizable.StoreSnapshot
void StoreSnapshot()
Barotrauma.IMemorizable.Redo
void Redo()
Barotrauma.IMemorizable.Undo
void Undo()
Barotrauma.IMemorizable.ClearHistory
void ClearHistory()
Barotrauma
Definition:
AchievementManager.cs:12
Barotrauma
BarotraumaShared
SharedSource
Memento.cs
Generated by
1.9.1