net.dreditor.gachasurface 0.0.0-stage → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DREditor.GachaSurface.asmdef +21 -0
- package/DREditor.GachaSurface.asmdef.meta +7 -0
- package/Gacha.cs +98 -0
- package/Gacha.cs.meta +11 -0
- package/ItemRolledAnimationSurface.cs +40 -0
- package/ItemRolledAnimationSurface.cs.meta +2 -0
- package/ItemRolledResponse.cs +103 -0
- package/ItemRolledResponse.cs.meta +2 -0
- package/PresentRoller.cs +232 -0
- package/PresentRoller.cs.meta +2 -0
- package/Samples/Gacha_Canvas_ETemplate.prefab +955 -0
- package/Samples/Gacha_Canvas_ETemplate.prefab.meta +7 -0
- package/Samples/Gacha_Surface_ETemplate.prefab +508 -0
- package/Samples/Gacha_Surface_ETemplate.prefab.meta +7 -0
- package/Samples/Present_Roller_ETemplate.prefab +54 -0
- package/Samples/Present_Roller_ETemplate.prefab.meta +7 -0
- package/Samples/Repeat_Rate_Canvas_ETemplate.prefab +489 -0
- package/Samples/Repeat_Rate_Canvas_ETemplate.prefab.meta +7 -0
- package/Samples.meta +8 -0
- package/SubmittableAnimationSurfaceComponent.cs +62 -0
- package/SubmittableAnimationSurfaceComponent.cs.meta +2 -0
- package/package.json +39 -6
- package/package.json.meta +7 -0
- package/README.md +0 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "DREditor.GachaSurface",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"Unity.TextMeshPro",
|
|
6
|
+
"DREditor",
|
|
7
|
+
"DREditor.UIHandling",
|
|
8
|
+
"DREditor.Presents",
|
|
9
|
+
"DREditor.FreeTimeSurfacing",
|
|
10
|
+
"DREditor.ItemRolling"
|
|
11
|
+
],
|
|
12
|
+
"includePlatforms": [],
|
|
13
|
+
"excludePlatforms": [],
|
|
14
|
+
"allowUnsafeCode": false,
|
|
15
|
+
"overrideReferences": false,
|
|
16
|
+
"precompiledReferences": [],
|
|
17
|
+
"autoReferenced": true,
|
|
18
|
+
"defineConstraints": [],
|
|
19
|
+
"versionDefines": [],
|
|
20
|
+
"noEngineReferences": false
|
|
21
|
+
}
|
package/Gacha.cs
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.FreeTimeSurfacing;
|
|
3
|
+
using DREditor.ItemRolling;
|
|
4
|
+
using DREditor.Processables;
|
|
5
|
+
using DREditor.Utility;
|
|
6
|
+
using UnityEngine;
|
|
7
|
+
|
|
8
|
+
namespace DREditor.GachaSurface
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
///
|
|
12
|
+
/// </summary>
|
|
13
|
+
[ClassHeader(nameof(SubmittableFTESurfaceCollection) + ", " + nameof(SubmittableFTESurfaceComponent) + ", " +
|
|
14
|
+
nameof(FTESurfaceComponent) + ", " + nameof(ISubmittable) + ", " + nameof(IComponentsCache) + ", " +
|
|
15
|
+
nameof(IRollerContainer) +
|
|
16
|
+
"\n\n")]
|
|
17
|
+
public class Gacha : SubmittableFTESurfaceCollection, IRollerContainer
|
|
18
|
+
{
|
|
19
|
+
/// <summary>
|
|
20
|
+
///
|
|
21
|
+
/// </summary>
|
|
22
|
+
[Header("")]
|
|
23
|
+
[Divider]
|
|
24
|
+
[Tooltip("")]
|
|
25
|
+
[SerializeField] protected ItemRollerBase roller;
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
/// <inheritdoc/>
|
|
29
|
+
public virtual IItemRoller GetRoller() => roller;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/// <inheritdoc/>
|
|
33
|
+
protected override void OnSubmit()
|
|
34
|
+
{
|
|
35
|
+
RollItem();
|
|
36
|
+
|
|
37
|
+
ProcessRollResult();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/// <summary>
|
|
41
|
+
///
|
|
42
|
+
/// </summary>
|
|
43
|
+
protected virtual void RollItem() => roller.RollForItem();
|
|
44
|
+
|
|
45
|
+
/// <summary>
|
|
46
|
+
///
|
|
47
|
+
/// </summary>
|
|
48
|
+
protected virtual void ProcessRollResult()
|
|
49
|
+
{
|
|
50
|
+
if (RollSucceded())
|
|
51
|
+
OnRollSucceded();
|
|
52
|
+
else
|
|
53
|
+
OnRollFailed();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// <summary>
|
|
57
|
+
///
|
|
58
|
+
/// </summary>
|
|
59
|
+
/// <returns></returns>
|
|
60
|
+
protected virtual bool RollSucceded() => roller.TryGetRolledObject(out object _);
|
|
61
|
+
|
|
62
|
+
/// <summary>
|
|
63
|
+
///
|
|
64
|
+
/// </summary>
|
|
65
|
+
protected virtual void OnRollSucceded()
|
|
66
|
+
{
|
|
67
|
+
this.InvokeThisPlusComponents<IItemRollerResponse>((response) => response?.InitializeForResponse(roller));
|
|
68
|
+
|
|
69
|
+
base.OnSubmit();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/// <summary>
|
|
73
|
+
///
|
|
74
|
+
/// </summary>
|
|
75
|
+
protected virtual void OnRollFailed()
|
|
76
|
+
{
|
|
77
|
+
AlertRollFailed();
|
|
78
|
+
|
|
79
|
+
base.InvokeCompleted();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/// <summary>
|
|
83
|
+
///
|
|
84
|
+
/// </summary>
|
|
85
|
+
protected virtual void AlertRollFailed() =>
|
|
86
|
+
UnityEngine.Debug.LogWarning($"ALERT: The item roller failed in rolling an item! Forcing process as Complete.");
|
|
87
|
+
|
|
88
|
+
/// <summary>
|
|
89
|
+
///
|
|
90
|
+
/// </summary>
|
|
91
|
+
protected override void InvokeCompleted()
|
|
92
|
+
{
|
|
93
|
+
roller.GivePlayerRolledItem();
|
|
94
|
+
|
|
95
|
+
base.InvokeCompleted();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
package/Gacha.cs.meta
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.ItemRolling;
|
|
3
|
+
using DREditor.Processables;
|
|
4
|
+
|
|
5
|
+
namespace DREditor.GachaSurface
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
///
|
|
9
|
+
/// </summary>
|
|
10
|
+
[ClassHeader(nameof(SubmittableAnimationSurfaceComponent) + ", " +
|
|
11
|
+
nameof(ISubmittable) + ", " + nameof(IStartUpable) + ", " + nameof(IItemRollerResponse) +
|
|
12
|
+
"\n\n")]
|
|
13
|
+
public class ItemRolledAnimationSurface : SubmittableAnimationSurfaceComponent, IItemRollerResponse
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
///
|
|
17
|
+
/// </summary>
|
|
18
|
+
protected IItemRoller itemRoller;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/// <inheritdoc/>
|
|
22
|
+
public virtual void InitializeForResponse(IItemRoller itemRoller) => this.itemRoller = itemRoller;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/// <inheritdoc/>
|
|
26
|
+
protected override void OnSubmit()
|
|
27
|
+
{
|
|
28
|
+
if (RolledItemValid())
|
|
29
|
+
base.OnSubmit();
|
|
30
|
+
else
|
|
31
|
+
InvokeCompleted();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/// <summary>
|
|
35
|
+
///
|
|
36
|
+
/// </summary>
|
|
37
|
+
/// <returns></returns>
|
|
38
|
+
protected virtual bool RolledItemValid() => itemRoller.TryGetRolledObject(out object _);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.FreeTimeSurfacing;
|
|
3
|
+
using DREditor.ItemRolling;
|
|
4
|
+
using DREditor.Items;
|
|
5
|
+
using DREditor.Processables;
|
|
6
|
+
using System;
|
|
7
|
+
using TMPro;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
using UnityEngine.Serialization;
|
|
10
|
+
using UnityEngine.UI;
|
|
11
|
+
|
|
12
|
+
namespace DREditor.GachaSurface
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
[ClassHeader(nameof(FTESurfaceComponent) + ", " + nameof(IItemRollerResponse) + ", " +
|
|
18
|
+
nameof(IStartUpable) + ", " + nameof(ISubmittable) +
|
|
19
|
+
"\n\n")]
|
|
20
|
+
public class ItemRolledResponse : FTESurfaceComponent, IItemRollerResponse, IStartUpable, ISubmittable
|
|
21
|
+
{
|
|
22
|
+
/// <summary>
|
|
23
|
+
///
|
|
24
|
+
/// </summary>
|
|
25
|
+
[Tooltip("")]
|
|
26
|
+
[FormerlySerializedAs("presentImage")]
|
|
27
|
+
[SerializeField] protected Image itemImage = null;
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
///
|
|
31
|
+
/// </summary>
|
|
32
|
+
[Tooltip("")]
|
|
33
|
+
[SerializeField] protected Sprite transparentSprite = null;
|
|
34
|
+
|
|
35
|
+
/// <summary>
|
|
36
|
+
///
|
|
37
|
+
/// </summary>
|
|
38
|
+
[Tooltip("")]
|
|
39
|
+
[FormerlySerializedAs("presentNameText")]
|
|
40
|
+
[SerializeField] protected TextMeshProUGUI itemNameText = null;
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
///
|
|
44
|
+
/// </summary>
|
|
45
|
+
[Tooltip("")]
|
|
46
|
+
[SerializeField] protected string presentNameSuffix = "!";
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
/// <summary>
|
|
50
|
+
///
|
|
51
|
+
/// </summary>
|
|
52
|
+
protected IItemRoller itemRoller;
|
|
53
|
+
|
|
54
|
+
/// <summary>
|
|
55
|
+
///
|
|
56
|
+
/// </summary>
|
|
57
|
+
protected IInventoryItem rolledItem;
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
/// <inheritdoc/>
|
|
61
|
+
public virtual void StartUp()
|
|
62
|
+
{
|
|
63
|
+
if (itemImage != null && transparentSprite != null)
|
|
64
|
+
itemImage.sprite = transparentSprite;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/// <inheritdoc/>
|
|
68
|
+
public virtual void InitializeForResponse(IItemRoller itemRoller) => this.itemRoller = itemRoller;
|
|
69
|
+
|
|
70
|
+
/// <inheritdoc/>
|
|
71
|
+
public virtual void Submit(Action onComplete)
|
|
72
|
+
{
|
|
73
|
+
CheckItemResponse();
|
|
74
|
+
|
|
75
|
+
onComplete?.Invoke();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/// <summary>
|
|
79
|
+
///
|
|
80
|
+
/// </summary>
|
|
81
|
+
protected virtual void CheckItemResponse()
|
|
82
|
+
{
|
|
83
|
+
if (SuccessfullyRolledItem())
|
|
84
|
+
DisplayItemData();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// <summary>
|
|
88
|
+
///
|
|
89
|
+
/// </summary>
|
|
90
|
+
/// <returns></returns>
|
|
91
|
+
protected virtual bool SuccessfullyRolledItem() => itemRoller.TryGetRolledObject(out rolledItem);
|
|
92
|
+
|
|
93
|
+
/// <summary>
|
|
94
|
+
///
|
|
95
|
+
/// </summary>
|
|
96
|
+
protected virtual void DisplayItemData()
|
|
97
|
+
{
|
|
98
|
+
itemImage.sprite = rolledItem.Image;
|
|
99
|
+
|
|
100
|
+
itemNameText.text = rolledItem.DisplayName + presentNameSuffix;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
package/PresentRoller.cs
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.EventObjects;
|
|
3
|
+
using DREditor.ItemRolling;
|
|
4
|
+
using DREditor.Presents;
|
|
5
|
+
using DREditor.Processables;
|
|
6
|
+
using DREditor.Services;
|
|
7
|
+
using System.Collections.Generic;
|
|
8
|
+
using System.Linq;
|
|
9
|
+
using UnityEngine;
|
|
10
|
+
|
|
11
|
+
namespace DREditor.GachaSurface
|
|
12
|
+
{
|
|
13
|
+
/// <summary>
|
|
14
|
+
///
|
|
15
|
+
/// </summary>
|
|
16
|
+
[ClassHeader(nameof(RepeatableRollerBase) + ", " + nameof(ItemRollerBase) + ", " +
|
|
17
|
+
nameof(IItemRoller) + ", " + nameof(IRepeatableRoller) +
|
|
18
|
+
"\n\n")]
|
|
19
|
+
public class PresentRoller : RepeatableRollerBase
|
|
20
|
+
{
|
|
21
|
+
/// <summary>
|
|
22
|
+
///
|
|
23
|
+
/// </summary>
|
|
24
|
+
[Header("")]
|
|
25
|
+
[Divider]
|
|
26
|
+
[Tooltip("")]
|
|
27
|
+
[SerializeField] protected IntWithEvent paidAmount = null;
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
///
|
|
31
|
+
/// </summary>
|
|
32
|
+
[Tooltip("")]
|
|
33
|
+
[SerializeField] protected PresentDatabase presentDatabase = null;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/// <summary>
|
|
37
|
+
///
|
|
38
|
+
/// </summary>
|
|
39
|
+
protected Present rolledObject;
|
|
40
|
+
|
|
41
|
+
/// <summary>
|
|
42
|
+
///
|
|
43
|
+
/// </summary>
|
|
44
|
+
protected IPresentManager presentManager;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
///
|
|
49
|
+
/// </summary>
|
|
50
|
+
protected readonly float OneHundred = 100;
|
|
51
|
+
|
|
52
|
+
/// <summary>
|
|
53
|
+
///
|
|
54
|
+
/// </summary>
|
|
55
|
+
protected readonly float AmountToPercentScale = 10;
|
|
56
|
+
|
|
57
|
+
/// <summary>
|
|
58
|
+
///
|
|
59
|
+
/// </summary>
|
|
60
|
+
protected readonly int Zero = 0;
|
|
61
|
+
|
|
62
|
+
/// <summary>
|
|
63
|
+
///
|
|
64
|
+
/// </summary>
|
|
65
|
+
protected readonly int InvalidRepeatRate = -1;
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
/// <inheritdoc/>
|
|
69
|
+
protected override object GetRolledObject() => rolledObject;
|
|
70
|
+
|
|
71
|
+
/// <inheritdoc/>
|
|
72
|
+
protected override void AddItemToInventory() => presentManager.AddPresent(rolledObject.ID);
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
/// <inheritdoc/>
|
|
76
|
+
public override object RollForItem(params object[] objects) =>
|
|
77
|
+
rolledObject = ServicesMissing() ?
|
|
78
|
+
null : PaidValidAmount() ?
|
|
79
|
+
RollPresent() : null;
|
|
80
|
+
|
|
81
|
+
/// <summary>
|
|
82
|
+
///
|
|
83
|
+
/// </summary>
|
|
84
|
+
/// <returns></returns>
|
|
85
|
+
protected virtual bool ServicesMissing()
|
|
86
|
+
{
|
|
87
|
+
bool databaseMissing = presentDatabase == null;
|
|
88
|
+
|
|
89
|
+
bool presentManagerMissing = !ServiceLocator.HasService(out presentManager);
|
|
90
|
+
|
|
91
|
+
if (presentManagerMissing)
|
|
92
|
+
UnityEngine.Debug.LogError($"ALERT: Repeat Amount calculation failed because there is currently no service " +
|
|
93
|
+
$"matching type {nameof(IPresentManager)} please add one to the scene.");
|
|
94
|
+
|
|
95
|
+
if (databaseMissing)
|
|
96
|
+
UnityEngine.Debug.LogError($"ALERT: The Present Database is missing! Please assign one to this present roller.");
|
|
97
|
+
|
|
98
|
+
return presentManagerMissing || databaseMissing;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/// <summary>
|
|
102
|
+
///
|
|
103
|
+
/// </summary>
|
|
104
|
+
/// <returns></returns>
|
|
105
|
+
protected virtual bool PaidValidAmount()
|
|
106
|
+
{
|
|
107
|
+
bool result = paidAmount.Value > Zero;
|
|
108
|
+
|
|
109
|
+
if (!result)
|
|
110
|
+
OnAmountPaidInvalid();
|
|
111
|
+
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/// <summary>
|
|
116
|
+
///
|
|
117
|
+
/// </summary>
|
|
118
|
+
protected virtual void OnAmountPaidInvalid() =>
|
|
119
|
+
UnityEngine.Debug.LogError($"ALERT: Item Roller {nameof(PresentRoller)} was not given proper payment!");
|
|
120
|
+
|
|
121
|
+
/// <summary>
|
|
122
|
+
///
|
|
123
|
+
/// </summary>
|
|
124
|
+
/// <returns></returns>
|
|
125
|
+
protected virtual Present RollPresent() =>
|
|
126
|
+
RollPresentFrom(presentDatabase.presents) is not Present present ?
|
|
127
|
+
null : PlayerOwnsItem(present) && ShouldGetNewPresent() ?
|
|
128
|
+
RollUnownedPresent(present) : present;
|
|
129
|
+
|
|
130
|
+
/// <summary>
|
|
131
|
+
///
|
|
132
|
+
/// </summary>
|
|
133
|
+
/// <returns></returns>
|
|
134
|
+
protected virtual Present RollPresentFrom(List<Present> collection) =>
|
|
135
|
+
(Present)collection[UnityEngine.Random.Range(Zero, collection.Count)];
|
|
136
|
+
|
|
137
|
+
/// <inheritdoc/>
|
|
138
|
+
protected override bool PlayerOwnsItem(object item) =>
|
|
139
|
+
item is IIdentifiable present && presentManager.HadPresent(present.ID);
|
|
140
|
+
|
|
141
|
+
/// <summary>
|
|
142
|
+
///
|
|
143
|
+
/// </summary>
|
|
144
|
+
/// <returns></returns>
|
|
145
|
+
protected virtual bool ShouldGetNewPresent() =>
|
|
146
|
+
GetRepeatRate() is float modifiedRepeatRate &&
|
|
147
|
+
modifiedRepeatRate != OneHundred &&
|
|
148
|
+
SuccededChanceForNewPresent(modifiedRepeatRate);
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
/// <inheritdoc/>
|
|
152
|
+
public override float GetRepeatRate()
|
|
153
|
+
{
|
|
154
|
+
if (ServicesMissing())
|
|
155
|
+
return InvalidRepeatRate;
|
|
156
|
+
else if (PlayerHasAllPresents())
|
|
157
|
+
return OneHundred;
|
|
158
|
+
else
|
|
159
|
+
return CalculateRepeatRateByPaidAmount();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/// <summary>
|
|
163
|
+
///
|
|
164
|
+
/// </summary>
|
|
165
|
+
/// <returns></returns>
|
|
166
|
+
protected virtual bool PlayerHasAllPresents() => presentManager.Count == presentDatabase.presents.Count;
|
|
167
|
+
|
|
168
|
+
/// <summary>
|
|
169
|
+
///
|
|
170
|
+
/// </summary>
|
|
171
|
+
/// <returns></returns>
|
|
172
|
+
protected virtual float CalculateRepeatRateByPaidAmount()
|
|
173
|
+
{
|
|
174
|
+
float repeatAmount = base.GetRepeatRate() - (paidAmount.Value / AmountToPercentScale);
|
|
175
|
+
|
|
176
|
+
return repeatAmount < Zero ? Zero : repeatAmount;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/// <inheritdoc/>
|
|
180
|
+
protected override float CalculateBaseRepeatRate() =>
|
|
181
|
+
presentManager.Count * OneHundred / presentDatabase.presents.Count;
|
|
182
|
+
|
|
183
|
+
/// <summary>
|
|
184
|
+
///
|
|
185
|
+
/// </summary>
|
|
186
|
+
/// <param name="modifiedRepeatRate"></param>
|
|
187
|
+
/// <returns></returns>
|
|
188
|
+
protected virtual bool SuccededChanceForNewPresent(float modifiedRepeatRate)
|
|
189
|
+
{
|
|
190
|
+
float trueRepeatRate = presentManager.Count / (float)presentDatabase.presents.Count;
|
|
191
|
+
|
|
192
|
+
float scaledRepeatRate = trueRepeatRate > Zero ? modifiedRepeatRate / trueRepeatRate : OneHundred;
|
|
193
|
+
|
|
194
|
+
if (scaledRepeatRate > OneHundred)
|
|
195
|
+
scaledRepeatRate = OneHundred;
|
|
196
|
+
|
|
197
|
+
return UnityEngine.Random.Range(Zero, (int)OneHundred) > scaledRepeatRate;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
/// <summary>
|
|
202
|
+
///
|
|
203
|
+
/// </summary>
|
|
204
|
+
/// <param name="present"></param>
|
|
205
|
+
/// <returns></returns>
|
|
206
|
+
protected virtual Present RollUnownedPresent(Present present) =>
|
|
207
|
+
TryRollUnownedPresent(out Present unownedPresent) ? unownedPresent : present;
|
|
208
|
+
|
|
209
|
+
/// <summary>
|
|
210
|
+
///
|
|
211
|
+
/// </summary>
|
|
212
|
+
/// <param name="present"></param>
|
|
213
|
+
/// <returns></returns>
|
|
214
|
+
protected virtual bool TryRollUnownedPresent(out Present present) =>
|
|
215
|
+
present = ServicesMissing() ? null : RollUnownedPresent();
|
|
216
|
+
|
|
217
|
+
/// <summary>
|
|
218
|
+
///
|
|
219
|
+
/// </summary>
|
|
220
|
+
/// <returns></returns>
|
|
221
|
+
protected virtual Present RollUnownedPresent()
|
|
222
|
+
{
|
|
223
|
+
List<Present> unownedPresents = presentDatabase.presents
|
|
224
|
+
.Where(present => present != null && !PlayerOwnsItem(present))
|
|
225
|
+
.ToList();
|
|
226
|
+
|
|
227
|
+
bool allPresentsOwned = unownedPresents.Count == Zero;
|
|
228
|
+
|
|
229
|
+
return allPresentsOwned ? RollPresentFrom(presentDatabase.presents) : RollPresentFrom(unownedPresents);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|