diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll
index 803d889b..2de3a52b 100644
Binary files a/1.6/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/1.6/Assemblies/WulaFallenEmpire.dll differ
diff --git a/1.6/1.6/Defs/EventDefs/EventDef_Examples_Loop.xml b/1.6/1.6/Defs/EventDefs/EventDef_Examples_Loop.xml
new file mode 100644
index 00000000..92e2535a
--- /dev/null
+++ b/1.6/1.6/Defs/EventDefs/EventDef_Examples_Loop.xml
@@ -0,0 +1,79 @@
+
+
+
+
+ WULA_Example_Loop
+ 循环大师
+ 这是一个演示循环效果列表功能的事件。
+
+首先,设置一个循环次数,然后看看会发生什么!
+
+
+
+
+
+
+
+ LoopCount
+ 3
+
+
+ 变量 'LoopCount' 已被设置为 3。
+ PositiveEvent
+
+
+
+
+
+
+
+
+
+
+
+ LoopCount
+
+ 1
+
+
+ Silver
+ 10
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 5
+
+
+ Steel
+ 20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/1.6/1.6/Defs/EventDefs/EventDef_Examples_RandomList.xml b/1.6/1.6/Defs/EventDefs/EventDef_Examples_RandomList.xml
new file mode 100644
index 00000000..f357275a
--- /dev/null
+++ b/1.6/1.6/Defs/EventDefs/EventDef_Examples_RandomList.xml
@@ -0,0 +1,56 @@
+
+
+
+
+ WULA_Example_RandomList
+ 系统管理员
+ 这是一个演示随机效果列表功能的事件。
+
+点击下面的选项,你会看到一条固定消息,然后会随机获得一件物品。
+
+
+
+
+
+
+
+
+ 你总是会看到这条消息!
+ PositiveEvent
+
+
+
+
+
+ Silver
+ 100
+ 3.0
+
+
+ Gold
+ 10
+ 1.0
+
+
+ ComponentIndustrial
+ 5
+ 1.5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Source/WulaFallenEmpire/EventSystem/Dialog_CustomDisplay.cs b/Source/WulaFallenEmpire/EventSystem/Dialog_CustomDisplay.cs
index 295ff4d9..c7f41f87 100644
--- a/Source/WulaFallenEmpire/EventSystem/Dialog_CustomDisplay.cs
+++ b/Source/WulaFallenEmpire/EventSystem/Dialog_CustomDisplay.cs
@@ -216,13 +216,7 @@ namespace WulaFallenEmpire
{
if (AreConditionsMet(ce.conditions, out _))
{
- if (!ce.effects.NullOrEmpty())
- {
- foreach (var effect in ce.effects)
- {
- effect.Execute(this);
- }
- }
+ ce.Execute(this);
}
}
}
diff --git a/Source/WulaFallenEmpire/EventSystem/Effect.cs b/Source/WulaFallenEmpire/EventSystem/Effect.cs
index 38a1ec24..119627d9 100644
--- a/Source/WulaFallenEmpire/EventSystem/Effect.cs
+++ b/Source/WulaFallenEmpire/EventSystem/Effect.cs
@@ -8,6 +8,7 @@ namespace WulaFallenEmpire
{
public abstract class Effect
{
+ public float weight = 1.0f;
public abstract void Execute(Dialog_CustomDisplay dialog = null);
}
@@ -50,13 +51,7 @@ namespace WulaFallenEmpire
string reason;
if (AreConditionsMet(conditionalEffect.conditions, out reason))
{
- if (!conditionalEffect.effects.NullOrEmpty())
- {
- foreach (var effect in conditionalEffect.effects)
- {
- effect.Execute(null);
- }
- }
+ conditionalEffect.Execute(null);
}
}
}
diff --git a/Source/WulaFallenEmpire/EventSystem/EventDef.cs b/Source/WulaFallenEmpire/EventSystem/EventDef.cs
index eb35dc02..1c2945ad 100644
--- a/Source/WulaFallenEmpire/EventSystem/EventDef.cs
+++ b/Source/WulaFallenEmpire/EventSystem/EventDef.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Linq;
using UnityEngine;
using Verse;
@@ -68,10 +69,73 @@ namespace WulaFallenEmpire
public bool hideWhenDisabled = false;
}
+ public class LoopEffects
+ {
+ public int count = 1;
+ public string countVariableName;
+ public List effects;
+ }
+
public class ConditionalEffects
{
public List conditions;
public List effects;
+ public List randomlistEffects;
+ public List loopEffects;
+
+ public void Execute(Dialog_CustomDisplay dialog)
+ {
+ // Execute all standard effects
+ if (!effects.NullOrEmpty())
+ {
+ foreach (var effect in effects)
+ {
+ effect.Execute(dialog);
+ }
+ }
+
+ // Execute one random effect from the random list
+ if (!randomlistEffects.NullOrEmpty())
+ {
+ float totalWeight = randomlistEffects.Sum(e => e.weight);
+ float randomPoint = Rand.Value * totalWeight;
+
+ foreach (var effect in randomlistEffects)
+ {
+ if (randomPoint < effect.weight)
+ {
+ effect.Execute(dialog);
+ break;
+ }
+ randomPoint -= effect.weight;
+ }
+ }
+
+ // Execute looped effects
+ if (!loopEffects.NullOrEmpty())
+ {
+ var eventVarManager = Find.World.GetComponent();
+ foreach (var loop in loopEffects)
+ {
+ int loopCount = loop.count;
+ if (!loop.countVariableName.NullOrEmpty() && eventVarManager.HasVariable(loop.countVariableName))
+ {
+ loopCount = eventVarManager.GetVariable(loop.countVariableName);
+ }
+
+ for (int i = 0; i < loopCount; i++)
+ {
+ if (!loop.effects.NullOrEmpty())
+ {
+ foreach (var effect in loop.effects)
+ {
+ effect.Execute(dialog);
+ }
+ }
+ }
+ }
+ }
+ }
}
public class ConditionalDescription
diff --git a/Source/WulaFallenEmpire/EventSystem/Letter_EventChoice.cs b/Source/WulaFallenEmpire/EventSystem/Letter_EventChoice.cs
index 9e753643..a868fa42 100644
--- a/Source/WulaFallenEmpire/EventSystem/Letter_EventChoice.cs
+++ b/Source/WulaFallenEmpire/EventSystem/Letter_EventChoice.cs
@@ -36,13 +36,7 @@ namespace WulaFallenEmpire
string reason;
if (AreConditionsMet(conditionalEffect.conditions, out reason))
{
- if (!conditionalEffect.effects.NullOrEmpty())
- {
- foreach (var effect in conditionalEffect.effects)
- {
- effect.Execute(null);
- }
- }
+ conditionalEffect.Execute(null);
}
}
}