diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index 43d434e8..e54b1dbc 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/Languages/ChineseSimplified (简体中文)/Keyed/WULA_Keys.xml b/1.6/1.6/Languages/ChineseSimplified (简体中文)/Keyed/WULA_Keys.xml new file mode 100644 index 00000000..863f54d8 --- /dev/null +++ b/1.6/1.6/Languages/ChineseSimplified (简体中文)/Keyed/WULA_Keys.xml @@ -0,0 +1,10 @@ + + + + + 切换自动召唤 + 启用或禁用所有信标的自动空投功能。启用后,信标在建造完成后会立即自动呼叫空投。 + 自动空投已启用。 + 自动空投已禁用。 + + \ No newline at end of file diff --git a/Source/WulaFallenEmpire/BuildingComp/WULA_SkyfallerCaller/CompProperties_SkyfallerCaller.cs b/Source/WulaFallenEmpire/BuildingComp/WULA_SkyfallerCaller/CompProperties_SkyfallerCaller.cs index 80b009f8..04d985e5 100644 --- a/Source/WulaFallenEmpire/BuildingComp/WULA_SkyfallerCaller/CompProperties_SkyfallerCaller.cs +++ b/Source/WulaFallenEmpire/BuildingComp/WULA_SkyfallerCaller/CompProperties_SkyfallerCaller.cs @@ -8,6 +8,9 @@ namespace WulaFallenEmpire public ThingDef skyfallerDef; public bool destroyBuilding = true; public int delayTicks = 0; + + public bool canAutoCall = true; // 默认启用自动召唤 + public int autoCallDelayTicks = 600; // 默认10秒 // 新增:是否需要 FlyOver 作为前提条件 public bool requireFlyOver = false; // 默认不需要 FlyOver diff --git a/Source/WulaFallenEmpire/BuildingComp/WULA_SkyfallerCaller/CompSkyfallerCaller.cs b/Source/WulaFallenEmpire/BuildingComp/WULA_SkyfallerCaller/CompSkyfallerCaller.cs index ffdfa3bc..4ce61946 100644 --- a/Source/WulaFallenEmpire/BuildingComp/WULA_SkyfallerCaller/CompSkyfallerCaller.cs +++ b/Source/WulaFallenEmpire/BuildingComp/WULA_SkyfallerCaller/CompSkyfallerCaller.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using RimWorld; +using RimWorld.Planet; using UnityEngine; using Verse; using Verse.AI; @@ -10,6 +11,19 @@ namespace WulaFallenEmpire public class CompSkyfallerCaller : ThingComp { private CompProperties_SkyfallerCaller Props => (CompProperties_SkyfallerCaller)props; + + private WulaSkyfallerWorldComponent _worldComponent; + private WulaSkyfallerWorldComponent WorldComp + { + get + { + if (_worldComponent == null) + { + _worldComponent = Find.World.GetComponent(); + } + return _worldComponent; + } + } private bool used = false; private int callTick = -1; @@ -138,6 +152,15 @@ namespace WulaFallenEmpire } } + public override void PostSpawnSetup(bool respawningAfterLoad) + { + base.PostSpawnSetup(respawningAfterLoad); + if (!respawningAfterLoad && Props.canAutoCall && WorldComp.AutoCallSkyfaller && CanCallSkyfaller) + { + CallSkyfaller(true); + } + } + public override void PostExposeData() { base.PostExposeData(); @@ -156,7 +179,7 @@ namespace WulaFallenEmpire } } - public void CallSkyfaller() + public void CallSkyfaller(bool isAutoCall = false) { if (!CanCallSkyfaller) { @@ -183,15 +206,16 @@ namespace WulaFallenEmpire calling = true; used = true; - callTick = Find.TickManager.TicksGame + Props.delayTicks; + int delay = isAutoCall ? Props.autoCallDelayTicks : Props.delayTicks; + callTick = Find.TickManager.TicksGame + delay; - if (Props.delayTicks <= 0) + if (delay <= 0) { ExecuteSkyfallerCall(); } else { - Messages.Message("WULA_SkyfallerIncoming".Translate(Props.delayTicks.ToStringTicksToPeriod()), parent, MessageTypeDefOf.ThreatBig); + Messages.Message("WULA_SkyfallerIncoming".Translate(delay.ToStringTicksToPeriod()), parent, MessageTypeDefOf.ThreatBig); } } @@ -253,19 +277,42 @@ namespace WulaFallenEmpire foreach (var gizmo in base.CompGetGizmosExtra()) yield return gizmo; - if (!CanCall) - yield break; - - Command_Action callCommand = new Command_Action + if (CanCall) { - defaultLabel = "WULA_CallSkyfaller".Translate(), - defaultDesc = GetCallDescription(), - icon = ContentFinder.Get("Wula/UI/Commands/WULA_DropBuilding"), - action = CallSkyfaller, - disabledReason = GetDisabledReason() - }; + Command_Action callCommand = new Command_Action + { + defaultLabel = "WULA_CallSkyfaller".Translate(), + defaultDesc = GetCallDescription(), + icon = ContentFinder.Get("Wula/UI/Commands/WULA_DropBuilding"), + action = () => CallSkyfaller(false), + disabledReason = GetDisabledReason() + }; + yield return callCommand; + } - yield return callCommand; + if (Props.canAutoCall) + { + Command_Toggle toggleAutoCall = new Command_Toggle + { + defaultLabel = "WULA_ToggleAutoCallSkyfaller".Translate(), + defaultDesc = "WULA_ToggleAutoCallSkyfallerDesc".Translate(), + icon = ContentFinder.Get("Wula/UI/Commands/WULA_DropBuilding"), + isActive = () => WorldComp.AutoCallSkyfaller, + toggleAction = () => + { + WorldComp.AutoCallSkyfaller = !WorldComp.AutoCallSkyfaller; + if (WorldComp.AutoCallSkyfaller) + { + Messages.Message("WULA_AutoCallEnabled".Translate(), MessageTypeDefOf.PositiveEvent); + } + else + { + Messages.Message("WULA_AutoCallDisabled".Translate(), MessageTypeDefOf.NegativeEvent); + } + } + }; + yield return toggleAutoCall; + } } private string GetCallDescription() diff --git a/Source/WulaFallenEmpire/BuildingComp/WULA_SkyfallerCaller/WulaSkyfallerWorldComponent.cs b/Source/WulaFallenEmpire/BuildingComp/WULA_SkyfallerCaller/WulaSkyfallerWorldComponent.cs new file mode 100644 index 00000000..d59b0de3 --- /dev/null +++ b/Source/WulaFallenEmpire/BuildingComp/WULA_SkyfallerCaller/WulaSkyfallerWorldComponent.cs @@ -0,0 +1,21 @@ +using RimWorld.Planet; +using Verse; + +namespace WulaFallenEmpire +{ + public class WulaSkyfallerWorldComponent : WorldComponent + { + // 默认为 true,即自动召唤 + public bool AutoCallSkyfaller = true; + + public WulaSkyfallerWorldComponent(World world) : base(world) + { + } + + public override void ExposeData() + { + base.ExposeData(); + Scribe_Values.Look(ref AutoCallSkyfaller, "AutoCallSkyfaller", true); + } + } +} \ No newline at end of file diff --git a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj index 8215eff1..24db7d58 100644 --- a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj +++ b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj @@ -114,6 +114,7 @@ +