|
27 | 27 |
|
28 | 28 | using System; |
29 | 29 | using System.Collections.Generic; |
| 30 | +using Microsoft.Xna.Framework; |
30 | 31 | using StateMachine.Events; |
31 | 32 |
|
32 | 33 | namespace MonoGameStateMachine.Api |
33 | 34 | { |
34 | | - public class FluentImplementation<TS, TT, TD> : StateMachine.Fluent.Api.FluentImplementation<TS, TT, TD>, |
35 | | - TransitionStateFluent<TS, TT, TD>, GlobalTransitionBuilderFluent<TS, TT, TD> |
| 35 | + public class FluentImplementation<TS, TT> : StateMachine.Fluent.Api.FluentImplementation<TS, TT, GameTime>, |
| 36 | + TransitionStateFluent<TS, TT, GameTime>, GlobalTransitionBuilderFluent<TS, TT, GameTime> |
36 | 37 | { |
37 | | - public Dictionary<Tuple<TS, TS>, List<Timer>> AfterEntries { get; set; } = new Dictionary<Tuple<TS, TS>, List<Timer>>(); |
38 | | - public Dictionary<Tuple<TS>, List<Timer>> GlobalAfterEntries { get; set; } = new Dictionary<Tuple<TS>, List<Timer>>(); |
| 38 | + public Dictionary<Tuple<TS, TS>, List<Timer<TS>>> AfterEntries { get; set; } = new Dictionary<Tuple<TS, TS>, List<Timer<TS>>>(); |
| 39 | + public List<Timer<TS>> GlobalAfterEntries { get; set; } = new List<Timer<TS>>(); |
39 | 40 |
|
40 | 41 | public FluentImplementation(TS startState) : base(startState) |
41 | 42 | { |
42 | 43 | } |
43 | 44 |
|
44 | | - public new Fsm<TS, TT, TD> Build() |
| 45 | + public new Fsm<TS, TT> Build() |
45 | 46 | { |
46 | 47 | base.Build(); |
47 | | - var m = new Fsm<TS, TT, TD>(FsmModel); |
| 48 | + var m = new Fsm<TS, TT>(FsmModel); |
48 | 49 | m.AfterEntries = AfterEntries; |
49 | 50 | m.GlobalAfterEntries = GlobalAfterEntries; |
50 | 51 | return m; |
51 | 52 | } |
52 | 53 |
|
53 | | - public TransitionStateFluent<TS, TT, TD> After(float amount, TimeUnit timeUnit) |
| 54 | + public TransitionStateFluent<TS, TT, GameTime> After(float amount, TimeUnit timeUnit) |
54 | 55 | { |
55 | | - List<Timer> l; |
| 56 | + List<Timer<TS>> l; |
56 | 57 | var key = currentTransition; |
57 | 58 | if (!AfterEntries.TryGetValue(key, out l)) |
58 | 59 | { |
59 | | - l = new List<Timer>(); |
| 60 | + l = new List<Timer<TS>>(); |
60 | 61 | AfterEntries.Add(key, l); |
61 | 62 | } |
62 | | - l.Add(new Timer(amount, timeUnit)); |
| 63 | + l.Add(new Timer<TS>(key.Item2, amount, timeUnit)); |
63 | 64 | return this; |
64 | 65 | } |
65 | 66 |
|
66 | | - public TransitionStateFluent<TS, TT, TD> AfterGlobal(float amount, TimeUnit timeUnit) |
| 67 | + public TransitionStateFluent<TS, TT, GameTime> AfterGlobal(float amount, TimeUnit timeUnit) |
67 | 68 | { |
68 | | - List<Timer> l; |
69 | 69 | var key = currentGlobalTransition; |
70 | | - if (!GlobalAfterEntries.TryGetValue(key, out l)) |
71 | | - { |
72 | | - l = new List<Timer>(); |
73 | | - GlobalAfterEntries.Add(key, l); |
74 | | - } |
75 | | - l.Add(new Timer(amount, timeUnit)); |
| 70 | + GlobalAfterEntries.Add(new Timer<TS>(key.Item1, amount, timeUnit)); |
76 | 71 | return this; |
77 | 72 | } |
78 | 73 |
|
79 | | - public new StateFluent<TS, TT, TD> State(TS state) |
| 74 | + public new StateFluent<TS, TT, GameTime> State(TS state) |
80 | 75 | { |
81 | 76 | base.State(state); |
82 | 77 | return this; |
83 | 78 | } |
84 | 79 |
|
85 | | - public new TransitionFluent<TS, TT, TD> TransitionTo(TS state) |
| 80 | + public new TransitionFluent<TS, TT, GameTime> TransitionTo(TS state) |
86 | 81 | { |
87 | 82 | base.TransitionTo(state); |
88 | 83 | return this; |
89 | 84 | } |
90 | 85 |
|
91 | | - public new TransitionFluent<TS, TT, TD> PopTransition() |
| 86 | + public new TransitionFluent<TS, TT, GameTime> PopTransition() |
92 | 87 | { |
93 | 88 | base.PopTransition(); |
94 | 89 | return this; |
95 | 90 | } |
96 | 91 |
|
97 | | - public new TransitionStateFluent<TS, TT, TD> On(TT trigger) |
| 92 | + public new TransitionStateFluent<TS, TT, GameTime> On(TT trigger) |
98 | 93 | { |
99 | 94 | base.On(trigger); |
100 | 95 | return this; |
101 | 96 | } |
102 | 97 |
|
103 | | - public new TransitionStateFluent<TS, TT, TD> If(Func<IfArgs<TS, TT>, bool> condition) |
| 98 | + public new TransitionStateFluent<TS, TT, GameTime> If(Func<IfArgs<TS>, bool> condition) |
104 | 99 | { |
105 | 100 | base.If(condition); |
106 | 101 | return this; |
107 | 102 | } |
108 | 103 |
|
109 | | - public new StateFluent<TS, TT, TD> OnEnter( |
110 | | - Action<StateChangeArgs<TS, TT, TD>> stateChangeArgs) |
| 104 | + public new StateFluent<TS, TT, GameTime> OnEnter( |
| 105 | + Action<StateChangeArgs<TS, TT, GameTime>> stateChangeArgs) |
111 | 106 | { |
112 | 107 | base.OnEnter(stateChangeArgs); |
113 | 108 | return this; |
114 | 109 | } |
115 | 110 |
|
116 | | - public new StateFluent<TS, TT, TD> OnExit( |
117 | | - Action<StateChangeArgs<TS, TT, TD>> stateChangeArgs) |
| 111 | + public new StateFluent<TS, TT, GameTime> OnExit( |
| 112 | + Action<StateChangeArgs<TS, TT, GameTime>> stateChangeArgs) |
118 | 113 | { |
119 | 114 | base.OnExit(stateChangeArgs); |
120 | 115 | return this; |
121 | 116 | } |
122 | 117 |
|
123 | | - public new StateFluent<TS, TT, TD> Update(Action<UpdateArgs<TS, TT, TD>> updateArgs) |
| 118 | + public new StateFluent<TS, TT, GameTime> Update(Action<UpdateArgs<TS, TT, GameTime>> updateArgs) |
124 | 119 | { |
125 | 120 | base.Update(updateArgs); |
126 | 121 | return this; |
127 | 122 | } |
128 | 123 |
|
129 | | - public new StateFluent<TS, TT, TD> ClearsStack() |
| 124 | + public new StateFluent<TS, TT, GameTime> ClearsStack() |
130 | 125 | { |
131 | 126 | base.ClearsStack(); |
132 | 127 | return this; |
133 | 128 | } |
134 | 129 |
|
135 | | - public new BuilderFluent<TS, TT, TD> EnableStack() |
| 130 | + public new BuilderFluent<TS, TT, GameTime> EnableStack() |
136 | 131 | { |
137 | 132 | base.EnableStack(); |
138 | 133 | return this; |
139 | 134 | } |
140 | 135 |
|
141 | | - public new GlobalTransitionFluent<TS, TT, TD> GlobalTransitionTo(TS state) |
| 136 | + public new GlobalTransitionFluent<TS, TT, GameTime> GlobalTransitionTo(TS state) |
142 | 137 | { |
143 | 138 | base.GlobalTransitionTo(state); |
144 | 139 | return this; |
145 | 140 | } |
146 | 141 |
|
147 | | - public new GlobalTransitionBuilderFluent<TS, TT, TD> OnGlobal(TT trigger) |
| 142 | + public new GlobalTransitionBuilderFluent<TS, TT, GameTime> OnGlobal(TT trigger) |
148 | 143 | { |
149 | 144 | base.OnGlobal(trigger); |
150 | 145 | return this; |
151 | 146 | } |
152 | 147 |
|
153 | | - public new GlobalTransitionBuilderFluent<TS, TT, TD> IfGlobal( |
154 | | - Func<IfArgs<TS, TT>, bool> condition) |
| 148 | + public new GlobalTransitionBuilderFluent<TS, TT, GameTime> IfGlobal( |
| 149 | + Func<IfArgs<TS>, bool> condition) |
155 | 150 | { |
156 | 151 | base.IfGlobal(condition); |
157 | 152 | return this; |
|
0 commit comments