This repository has been archived by the owner on Apr 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DialogBuilder.cs
663 lines (649 loc) · 27.4 KB
/
DialogBuilder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
using System;
using System.Collections.Generic;
using JetBrains.Annotations;
using TaleWorlds.CampaignSystem;
namespace PreventEscape
{
/// <summary>
/// Represents expression animations tags.
/// </summary>
public class Expressions
{
public enum Key
{
/// <summary>
/// Tags starting with "ib:"
/// </summary>
IdleBody,
/// <summary>
/// Tags starting with "if:"
/// </summary>
IdleFace,
/// <summary>
/// Tags starting with "rb:"
/// </summary>
ReactionBody,
/// <summary>
/// Tags starting with "rf:"
/// </summary>
ReactionFace,
}
public static class IdleBody
{
[PublicAPI] [NotNull] public static readonly Expressions Aggressive = new Expressions(Key.IdleBody, "aggressive");
[PublicAPI] [NotNull] public static readonly Expressions Closed = new Expressions(Key.IdleBody, "closed");
[PublicAPI] [NotNull] public static readonly Expressions Normal = new Expressions(Key.IdleBody, "normal");
[PublicAPI] [NotNull] public static readonly Expressions Warrior = new Expressions(Key.IdleBody, "warrior");
[PublicAPI] [NotNull] public static readonly Expressions Demure = new Expressions(Key.IdleBody, "demure");
}
public static class IdleFace
{
// public static readonly Expressions = new Expressions(Key.IdleFace, "");
[PublicAPI] [NotNull] public static readonly Expressions IdleAngry = new Expressions(Key.IdleFace, "idle_angry");
[PublicAPI] [NotNull] public static readonly Expressions IdleHappy = new Expressions(Key.IdleFace, "idle_happy");
[PublicAPI] [NotNull] public static readonly Expressions IdleInsulted = new Expressions(Key.IdleFace, "idle_insulted");
[PublicAPI] [NotNull] public static readonly Expressions IdlePleased = new Expressions(Key.IdleFace, "idle_pleased");
[PublicAPI] [NotNull] public static readonly Expressions IdleDespise = new Expressions(Key.IdleFace, "idle_despise");
[PublicAPI] [NotNull] public static readonly Expressions IdleCheering1 = new Expressions(Key.IdleFace, "idle_cheering1");
[PublicAPI] [NotNull] public static readonly Expressions IdleCheering2 = new Expressions(Key.IdleFace, "idle_cheering2");
[PublicAPI] [NotNull] public static readonly Expressions IdleSick = new Expressions(Key.IdleFace, "idle_sick");
[PublicAPI] [NotNull] public static readonly Expressions ConvoComposed = new Expressions(Key.IdleFace, "convo_composed");
[PublicAPI] [NotNull] public static readonly Expressions ConvoNonchalant = new Expressions(Key.IdleFace, "convo_nonchalant");
[PublicAPI] [NotNull] public static readonly Expressions ConvoDelighted = new Expressions(Key.IdleFace, "convo_delighted");
[PublicAPI] [NotNull] public static readonly Expressions ConvoHappy = new Expressions(Key.IdleFace, "convo_happy");
[PublicAPI] [NotNull] public static readonly Expressions ConvoStonefaced = new Expressions(Key.IdleFace, "convo_stonefaced");
[PublicAPI] [NotNull] public static readonly Expressions ConvoGrave = new Expressions(Key.IdleFace, "convo_grave");
[PublicAPI] [NotNull] public static readonly Expressions ConvoIrritable = new Expressions(Key.IdleFace, "convo_irritable");
[PublicAPI] [NotNull] public static readonly Expressions ConvoMocking = new Expressions(Key.IdleFace, "convo_mocking");
[PublicAPI] [NotNull] public static readonly Expressions ConvoInsidious = new Expressions(Key.IdleFace, "convo_insidious");
[PublicAPI] [NotNull] public static readonly Expressions ConvoBent = new Expressions(Key.IdleFace, "convo_bent");
[PublicAPI] [NotNull] public static readonly Expressions ConvoGrim = new Expressions(Key.IdleFace, "convo_grim");
[PublicAPI] [NotNull] public static readonly Expressions ConvoCharitable = new Expressions(Key.IdleFace, "convo_charitable");
[PublicAPI] [NotNull] public static readonly Expressions ConvoMerry = new Expressions(Key.IdleFace, "convo_merry");
[PublicAPI] [NotNull] public static readonly Expressions ConvoFriendly = new Expressions(Key.IdleFace, "convo_friendly");
[PublicAPI] [NotNull] public static readonly Expressions TalkingHappy = new Expressions(Key.IdleFace, "talking_happy");
[PublicAPI] [NotNull] public static readonly Expressions Happy = new Expressions(Key.IdleFace, "happy");
}
public static class ReactionBody
{
[PublicAPI] public static readonly Expressions VeryNegative = new Expressions(Key.ReactionBody, "very_negative");
[PublicAPI] [NotNull] public static readonly Expressions Negative = new Expressions(Key.ReactionBody, "negative");
[PublicAPI] [NotNull] public static readonly Expressions Positive= new Expressions(Key.ReactionBody, "positive");
[PublicAPI] [NotNull] public static readonly Expressions VeryPositive= new Expressions(Key.ReactionBody, "very_positive");
[PublicAPI] [NotNull] public static readonly Expressions Unsure = new Expressions(Key.ReactionBody, "unsure");
[PublicAPI] [NotNull] public static readonly Expressions Trivial = new Expressions(Key.ReactionBody, "trivial");
}
public static class ReactionFace
{
[PublicAPI] [NotNull] public static readonly Expressions Happy = new Expressions(Key.ReactionFace, "happy");
[PublicAPI] [NotNull] public static readonly Expressions VeryNegative = new Expressions(Key.ReactionFace, "very_negative");
}
[PublicAPI] public static readonly Expressions None = new Expressions("");
[PublicAPI] public string Tag { get; }
[PublicAPI]
public Expressions(string key, string animationName)
{
Tag = $"[{(!string.IsNullOrEmpty(key) ? key + ':' : "")}{animationName}]";
}
[PublicAPI]
public Expressions(Key key, string animationName)
{
string keyText;
switch (key)
{
case Key.IdleBody:
keyText = "ib";
break;
case Key.IdleFace:
keyText = "if";
break;
case Key.ReactionBody:
keyText = "rb";
break;
case Key.ReactionFace:
keyText = "rf";
break;
default:
keyText = null;
break;
}
Tag = $"[{(!string.IsNullOrEmpty(keyText) ? keyText + ':' : "")}{animationName}]";
}
private Expressions(string tag)
{
Tag = tag;
}
public static Expressions operator|(Expressions a, Expressions b)
{
return new Expressions((a?.Tag ?? "") + (b?.Tag ?? ""));
}
// ib is idle animations (body, I guess?)
// if is facial idle
// rb is idle reaction
// rf ???
}
public class DialogBuilder
{
public abstract class DialogToken : IDialogToken
{
[NotNull] private readonly DialogBuilder _builder;
[NotNull] protected DialogBuilder Builder => _builder;
[CanBeNull] public DialogToken InputToken { get; }
[NotNull] public string TokenName { get; }
[NotNull] public string OutputToken { get; protected set; }
public int Priority { get; protected set; }
[CanBeNull] public ConversationSentence.OnConditionDelegate Condition { get; protected set; }
[CanBeNull] public ConversationSentence.OnConsequenceDelegate Consequence { get; protected set; }
[CanBeNull] public Expressions Expressions { get; protected set; }
protected DialogToken([NotNull] DialogBuilder builder, DialogToken inputToken, [NotNull]string tokenName)
{
_builder = builder;
InputToken = inputToken;
TokenName = tokenName;
OutputToken = TokenName;
Builder.AddToken(this);
}
public void Build()
{
_builder.Build();
}
protected string GetText()
{
try
{
return Builder.Texts[TokenName];
}
catch (KeyNotFoundException)
{
throw new ArgumentException($"DialogBuilder texts parameter should have a value for \"{TokenName}\" token!");
}
}
public abstract void CompileToken([NotNull]CampaignGameStarter campaign);
}
private class InputDialogToken : DialogToken, IInputDialogToken
{
public InputDialogToken([NotNull]DialogBuilder builder, [NotNull]string tokenName = "start") : base(builder, null, tokenName) { }
public IPartnerDialogToken AddDialogLine(string tokenName, ConversationSentence.OnConditionDelegate condition = null)
{
var result = new PartnerDialogToken(Builder, this, tokenName);
if(condition != null)
result.SetCondition(condition);
return result;
}
public IPlayerDialogToken AddPlayerLine(string tokenName, ConversationSentence.OnConditionDelegate condition = null)
{
var result = new PlayerDialogToken(Builder, this, tokenName);
if (condition != null)
result.SetCondition(condition);
return result;
}
public override void CompileToken(CampaignGameStarter campaign)
{
// This is a start token, we don't need to actually do anything
}
}
private class PartnerDialogToken : DialogToken, IPartnerDialogToken
{
public PartnerDialogToken([NotNull]DialogBuilder builder, DialogToken inputToken, [NotNull]string tokenName)
: base(builder, inputToken, tokenName)
{
}
public IPartnerDialogToken SetCondition(ConversationSentence.OnConditionDelegate condition)
{
Condition = condition;
return this;
}
public IPartnerDialogToken SetConsequence(ConversationSentence.OnConsequenceDelegate consequence)
{
Consequence = consequence;
return this;
}
public IPlayerDialogToken CloseWindow()
{
OutputToken = "close_window";
return InputToken as IPlayerDialogToken;
}
public IDecisionToken Decision()
{
var result = new DecisionToken(Builder, this);
this.OutputToken = result.TokenName;
return result;
}
public IPlayerDialogToken Response(string tokenName)
{
return new PlayerDialogToken(Builder, this, tokenName);
}
public IPartnerDialogToken SetExpressions(Expressions expressions)
{
Expressions = expressions;
return this;
}
public IPartnerDialogToken SetPriority(int priority)
{
Priority = priority;
return this;
}
public IPlayerDialogToken End()
{
if (InputToken is IBarterResultToken)
return InputToken.InputToken as IPlayerDialogToken;
return InputToken as IPlayerDialogToken;
}
public override void CompileToken(CampaignGameStarter campaign)
{
var inputToken = InputToken?.TokenName ?? "start";
if (InputToken is IBarterResultToken)
inputToken += "_result";
if (InputToken is IInputDialogToken)
inputToken = InputToken.TokenName;
campaign.AddDialogLine(TokenName, inputToken, OutputToken, GetText() + Expressions?.Tag, Condition, Consequence, Priority);
}
}
private class PlayerDialogToken : DialogToken, IPlayerDialogToken
{
internal PlayerDialogToken([NotNull]DialogBuilder builder, DialogToken inputToken, [NotNull]string tokenName)
: base(builder, inputToken, tokenName)
{
}
public IPlayerDialogToken SetConsequence(ConversationSentence.OnConsequenceDelegate consequence)
{
Consequence = consequence;
return this;
}
public IPlayerDialogToken SetExpressions(Expressions expressions)
{
Expressions = expressions;
return this;
}
public IPlayerDialogToken SetPriority(int priority)
{
Priority = priority;
return this;
}
public IPartnerDialogToken Response(string tokenName)
{
var result = new PartnerDialogToken(Builder, this, tokenName);
//OutputToken = result.TokenName;
return result;
}
public IBarterResultToken Barter(AcquireBarterablesCallback acquireBarterables)
{
var result = new BarterResultToken(Builder, this, acquireBarterables);
OutputToken += "_barter";
return result;
}
public IPartnerDialogToken End()
{
return InputToken as IPartnerDialogToken;
}
public IPlayerDialogToken SetCondition(ConversationSentence.OnConditionDelegate condition)
{
Condition = condition;
return this;
}
public override void CompileToken(CampaignGameStarter campaign)
{
campaign.AddPlayerLine(TokenName, InputToken?.TokenName ?? "start", OutputToken, GetText() + Expressions?.Tag, Condition, Consequence, Priority);
}
}
private class DecisionToken : PlayerDialogToken, IDecisionToken
{
//[NotNull] private readonly List<IPlayerDialogToken> _variants;
public DecisionToken([NotNull]DialogBuilder builder, [NotNull]PartnerDialogToken inputToken)
: base(builder, inputToken, inputToken.TokenName + "_decision")
{
//_variants = new List<IPlayerDialogToken>();
}
public IDecisionToken AddVariant(string tokenName, DecisionVariantTokenCallback callback)
{
var token = new PlayerDialogToken(Builder, this, tokenName);
//_variants.Add(token);
callback(token);
return this;
}
public override void CompileToken(CampaignGameStarter campaign) { }
}
private class BarterResultToken : DialogToken, IBarterResultToken
{
// We don't need DialogToken instance reference in callback, so instead we should use class with everything essential to initialize barter.
private class BarterContext
{
private readonly AcquireBarterablesCallback _acquireBarterables;
public ConversationSentence.OnConsequenceDelegate AdditionalConsequence;
public BarterManager.BarterContextInitializer ContextInitializer;
public BarterPersuasionCostReduction PersuasionCostReduction;
public BarterContext(AcquireBarterablesCallback acquireBarterables)
{
_acquireBarterables = acquireBarterables;
}
public void Consequence()
{
AdditionalConsequence?.Invoke();
BarterManager.Instance?.StartBarterOffer(Hero.MainHero, Hero.OneToOneConversationHero, PartyBase.MainParty,
MobileParty.ConversationParty?.Party, null, ContextInitializer, PersuasionCostReduction?.Invoke() ?? 0, false,
_acquireBarterables?.Invoke());
}
public bool IsAccepted()
{
return BarterManager.Instance?.LastBarterIsAccepted ?? false;
}
public bool IsRejected()
{
return (!BarterManager.Instance?.LastBarterIsAccepted) ?? false;
}
}
[NotNull] private readonly BarterContext _context;
public BarterResultToken([NotNull]DialogBuilder builder, [NotNull]PlayerDialogToken inputToken, [CanBeNull]AcquireBarterablesCallback acquireBarterables) : base(builder, inputToken, inputToken.TokenName + "_barter")
{
_context = new BarterContext(acquireBarterables);
}
public IBarterResultToken BarterAccept(string tokenName, BarterOfferTokenCallback callback)
{
var token = new PartnerDialogToken(Builder, this, tokenName).SetCondition(_context.IsAccepted);
callback(token);
return this;
}
public IBarterResultToken BarterReject(string tokenName, BarterOfferTokenCallback callback)
{
var token = new PartnerDialogToken(Builder, this, tokenName).SetCondition(_context.IsRejected);
callback(token);
return this;
}
public IBarterResultToken BarterResult(string tokenName, BarterOfferTokenCallback callback)
{
var token = new PartnerDialogToken(Builder, this, tokenName);
callback(token);
return this;
}
public IBarterResultToken ContextInitializer(BarterManager.BarterContextInitializer initializer)
{
_context.ContextInitializer = initializer;
return this;
}
public IBarterResultToken PersuasionCostReduction(BarterPersuasionCostReduction callback)
{
_context.PersuasionCostReduction = callback;
return this;
}
public IPlayerDialogToken End()
{
return InputToken as IPlayerDialogToken ?? throw new InvalidOperationException($"{nameof(IBarterResultToken)} should be created with inputToken of type {nameof(IPlayerDialogToken)}!");
}
public override void CompileToken(CampaignGameStarter campaign)
{
_context.AdditionalConsequence = Consequence;
campaign.AddDialogLine(TokenName, InputToken?.TokenName + "_barter", TokenName+"_result", "" + Expressions?.Tag, Condition, _context.Consequence);
}
}
[NotNull] private readonly CampaignGameStarter _campaignGameStarter;
[NotNull] private Dictionary<string, string> Texts { get; }
[NotNull] private readonly List<DialogToken> _tokens;
/// <summary>
/// initializes new instance of DialogBuilder.
/// </summary>
/// <param name="campaignGameStarter"></param>
/// <param name="texts">Map translating token ID to dialog text value.</param>
public DialogBuilder([NotNull]CampaignGameStarter campaignGameStarter, [NotNull]Dictionary<string, string> texts)
{
_campaignGameStarter = campaignGameStarter;
Texts = texts;
_tokens = new List<DialogToken>();
}
/// <summary>
/// Creates input token with id "start".
/// </summary>
/// <returns>Newly created <see cref="IInputDialogToken"/></returns>
[PublicAPI][NotNull]
public IInputDialogToken GetStartToken()
{
return new InputDialogToken(this);
}
/// <summary>
/// Creates input token with id "event_triggered
/// </summary>
/// <returns>Newly created <see cref="IInputDialogToken"/></returns>
[PublicAPI][NotNull]
public IInputDialogToken GetEventTriggeredToken()
{
return new InputDialogToken(this, "event_triggered");
}
/// <summary>
/// Creates input token with id "member_chat"
/// </summary>
/// <returns>Newly created <see cref="IInputDialogToken"/></returns>
[PublicAPI][NotNull]
public IInputDialogToken GetMemberChatToken()
{
return new InputDialogToken(this, "member_chat");
}
/// <summary>
/// Creates input token with id "prisoner_chat"
/// </summary>
/// <returns>Newly created <see cref="IInputDialogToken"/></returns>
[PublicAPI][NotNull]
public IInputDialogToken GetPrisonerChatToken()
{
return new InputDialogToken(this, "prisoner_chat");
}
/// <summary>
/// Creates input token with custom id.
/// </summary>
/// <param name="tokenName"></param>
/// <returns>Newly created <see cref="IInputDialogToken"/></returns>
[PublicAPI][NotNull]
public IInputDialogToken GetExistingToken([NotNull]string tokenName)
{
return new InputDialogToken(this, tokenName);
}
private void AddToken([NotNull]DialogToken token)
{
if (token is IInputDialogToken)
return;
if (_tokens.Exists(t => token.TokenName == t?.TokenName))
throw new ApplicationException("Token with same name already defined!");
_tokens.Add(token);
}
private void Build()
{
foreach (var dialogToken in _tokens)
{
dialogToken.CompileToken(_campaignGameStarter);
}
_tokens.Clear();
}
}
[NotNull] public delegate IEnumerable<Barterable> AcquireBarterablesCallback();
public delegate void BarterOfferTokenCallback([NotNull]IPartnerDialogToken accepted);
public delegate void DecisionVariantTokenCallback([NotNull]IPlayerDialogToken variant);
public delegate int BarterPersuasionCostReduction();
/// <summary>
/// Base type for any dialog token.
/// </summary>
[PublicAPI]
public interface IDialogToken
{
/// <summary>
/// Complete this dialog tree and add it's lines to <see cref="ConversationManager"/>
/// </summary>
[PublicAPI] void Build();
}
/// <summary>
/// Input token with value "start", does not represents any actual dialog line, just an input token name.
/// </summary>
[PublicAPI]
public interface IInputDialogToken : IDialogToken
{
/// <summary>
/// Creates new dialog token for dialog partner.
/// </summary>
/// <param name="tokenName">Unique token ID</param>
/// <param name="condition">Condition to check whether this dialog line could appear</param>
/// <returns>Newly created dialog token</returns>
[PublicAPI][NotNull] IPartnerDialogToken AddDialogLine([NotNull]string tokenName, [CanBeNull]ConversationSentence.OnConditionDelegate condition = null);
/// <summary>
/// Creates new dialog token for player.
/// </summary>
/// <param name="tokenName">Unique token ID </param>
/// <param name="condition">Condition to check whether this dialog line could appear</param>
/// <returns>Newly created dialog token</returns>
[PublicAPI] [NotNull] IPlayerDialogToken AddPlayerLine([NotNull]string tokenName, [CanBeNull]ConversationSentence.OnConditionDelegate condition = null);
}
/// <summary>
/// Represents a player's response dialog line.
/// </summary>
[PublicAPI]
public interface IPlayerDialogToken : IDialogToken
{
/// <summary>
/// Sets new condition callback delegate for this token
/// </summary>
/// <param name="condition"></param>
/// <returns>This <see cref="IPlayerDialogToken"/></returns>
[PublicAPI] [NotNull] IPlayerDialogToken SetCondition([NotNull]ConversationSentence.OnConditionDelegate condition);
/// <summary>
/// Sets new consequence callback delegate for this token
/// </summary>
/// <param name="consequence"></param>
/// <returns>This <see cref="IPlayerDialogToken"/></returns>
[PublicAPI] [NotNull] IPlayerDialogToken SetConsequence([NotNull]ConversationSentence.OnConsequenceDelegate consequence);
/// <summary>
/// Sets facial expressions for player's character (usually useless, unless you've set camera to players' character)
/// </summary>
/// <param name="expressions"></param>
/// <returns>This <see cref="IPlayerDialogToken"/></returns>
[PublicAPI] [NotNull] IPlayerDialogToken SetExpressions([NotNull]Expressions expressions);
/// <summary>
/// Sets new priority value for this dialog token.
/// </summary>
/// <param name="priority"></param>
/// <returns>This <see cref="IPlayerDialogToken"/></returns>
[PublicAPI] [NotNull] IPlayerDialogToken SetPriority(int priority);
/// <summary>
/// Opens a barter window between player and conversation partner.
/// </summary>
/// <param name="acquireBarterables"></param>
/// <returns>Newly created <see cref="IBarterResultToken"/></returns>
[PublicAPI] [NotNull] IBarterResultToken Barter([NotNull]AcquireBarterablesCallback acquireBarterables);
/// <summary>
/// Creates a partner's response to this player token.
/// </summary>
/// <param name="tokenName"></param>
/// <returns>Newly created <see cref="IPartnerDialogToken"/></returns>
[PublicAPI] [NotNull] IPartnerDialogToken Response([NotNull]string tokenName);
/// <summary>
/// Finishes this token and returns it's input <see cref="IPartnerDialogToken"/> or null.
/// </summary>
/// <returns><see cref="IPartnerDialogToken"/> instance by which this <see cref="IPlayerDialogToken"/> was created or null if input token has other type.</returns>
[PublicAPI] [CanBeNull] IPartnerDialogToken End();
}
/// <summary>
/// Represents a barter during dialog.
/// </summary>
[PublicAPI]
public interface IBarterResultToken : IDialogToken
{
/// <summary>
/// Creates a partner's response with predefined condition if barter was accepted.
/// </summary>
/// <remarks>Never do call <see cref="IPartnerDialogToken.SetCondition"/> for returned instance of <see cref="IPartnerDialogToken"/>!</remarks>
/// <param name="tokenName"></param>
/// <param name="callback">this callback is called with newly created <see cref="IPartnerDialogToken"/></param>
/// <returns>Newly created <see cref="IBarterResultToken"/></returns>
[PublicAPI] [NotNull] IBarterResultToken BarterAccept([NotNull]string tokenName, [NotNull] BarterOfferTokenCallback callback);
/// <summary>
/// Creates a partner's response with predefined condition if barter was rejected.
/// </summary>
/// <remarks>Never do call <see cref="IPartnerDialogToken.SetCondition"/> for returned instance of <see cref="IPartnerDialogToken"/>!</remarks>
/// <param name="tokenName"></param>
/// <param name="callback">this callback is called with newly created <see cref="IPartnerDialogToken"/></param>
/// <returns>Newly created <see cref="IBarterResultToken"/></returns>
[PublicAPI] [NotNull] IBarterResultToken BarterReject([NotNull]string tokenName, [NotNull] BarterOfferTokenCallback callback);
/// <summary>
/// Creates a partner's response after barter window is closed (whether barter was accepted or rejected).
/// </summary>
/// <param name="tokenName"></param>
/// <param name="callback">this callback is called with newly created <see cref="IPartnerDialogToken"/></param>
/// <returns>Newly created <see cref="IPartnerDialogToken"/></returns>
[PublicAPI] [NotNull] IBarterResultToken BarterResult([NotNull]string tokenName, [NotNull] BarterOfferTokenCallback callback);
/// <summary>
/// Sets barter context initializer
/// </summary>
/// <param name="initializer"></param>
/// <returns>This <see cref="IBarterResultToken"/></returns>
[PublicAPI] [NotNull] IBarterResultToken ContextInitializer([NotNull]BarterManager.BarterContextInitializer initializer);
/// <summary>
/// Sets persuasion cost reduction value for BarterManager.
/// </summary>
/// <param name="callback"></param>
/// <returns>This <see cref="IBarterResultToken"/></returns>
[PublicAPI] [NotNull] IBarterResultToken PersuasionCostReduction([NotNull]BarterPersuasionCostReduction callback);
/// <summary>
/// Finishes this token and returns it's input <see cref="IPlayerDialogToken"/> or null.
/// </summary>
/// <returns></returns>
[PublicAPI] [CanBeNull] IPlayerDialogToken End();
}
[PublicAPI]
public interface IPartnerDialogToken : IDialogToken
{
/// <summary>
/// Sets new condition callback delegate for this token
/// </summary>
/// <param name="condition"></param>
/// <returns>This <see cref="IPartnerDialogToken"/></returns>
[PublicAPI] [NotNull] IPartnerDialogToken SetCondition([NotNull]ConversationSentence.OnConditionDelegate condition);
/// <summary>
/// Sets new consequence callback delegate for this token
/// </summary>
/// <param name="consequence"></param>
/// <returns>This <see cref="IPartnerDialogToken"/></returns>
[PublicAPI] [NotNull] IPartnerDialogToken SetConsequence([NotNull]ConversationSentence.OnConsequenceDelegate consequence);
/// <summary>
/// Sets facial expressions for partner's character.
/// </summary>
/// <param name="expressions"></param>
/// <returns>This <see cref="IPartnerDialogToken"/></returns>
[PublicAPI] [NotNull] IPartnerDialogToken SetExpressions([NotNull]Expressions expressions);
/// <summary>
/// Sets priority value for this dialog token.
/// </summary>
/// <param name="priority"></param>
/// <returns>This <see cref="IPartnerDialogToken"/></returns>
[PublicAPI] [NotNull] IPartnerDialogToken SetPriority(int priority);
/// <summary>
/// Sets output token value to "close_window" and returns this <see cref="IPartnerDialogToken"/>'s input <see cref="IPlayerDialogToken"/>.
/// </summary>
/// <returns><see cref="IPlayerDialogToken"/> instance by which this <see cref="IPartnerDialogToken"/> was created or null if input token has other type.</returns>
[PublicAPI] [CanBeNull] IPlayerDialogToken CloseWindow();
/// <summary>
/// Creates a new decision token, which allows for multiple player's response dialog lines.
/// </summary>
/// <returns>Newly created <see cref="IDecisionToken"/></returns>
[PublicAPI] [NotNull] IDecisionToken Decision();
/// <summary>
/// Creates a new player response line.
/// </summary>
/// <param name="tokenName"></param>
/// <returns>Newly created <see cref="IPlayerDialogToken"/></returns>
[PublicAPI] [NotNull] IPlayerDialogToken Response([NotNull]string tokenName);
/// <summary>
/// Finishes this token and returns it's input <see cref="IPlayerDialogToken"/> or null.
/// </summary>
/// <returns><see cref="IPlayerDialogToken"/> instance by which this <see cref="IPartnerDialogToken"/> was created or null if input token has other type.</returns>
[PublicAPI] [CanBeNull] IPlayerDialogToken End();
}
/// <summary>
/// Represents a token which acts as an input token for multiple player dialog lines, i.e. allows multiple answers for player.
/// </summary>
[PublicAPI]
public interface IDecisionToken : IPlayerDialogToken
{
/// <summary>
/// Adds a player's response for current decision token.
/// </summary>
/// <param name="tokenName"></param>
/// <param name="callback">this callback is called with newly created <see cref="IPlayerDialogToken"/></param>
/// <returns>This <see cref="IDialogToken"/></returns>
[PublicAPI] [NotNull] IDecisionToken AddVariant([NotNull]string tokenName, [NotNull]DecisionVariantTokenCallback callback);
}
}