暂存
This commit is contained in:
97
Source/WulaFallenEmpire/Quests/CustomQuestNodes.cs
Normal file
97
Source/WulaFallenEmpire/Quests/CustomQuestNodes.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using RimWorld;
|
||||
using RimWorld.Planet;
|
||||
using RimWorld.QuestGen;
|
||||
using Verse;
|
||||
using Verse.Grammar;
|
||||
|
||||
namespace WulaFallenEmpire.Quests
|
||||
{
|
||||
public class QuestNode_DropShuttleForRecovery : QuestNode
|
||||
{
|
||||
[NoTranslate]
|
||||
public SlateRef<Map> map;
|
||||
|
||||
[NoTranslate]
|
||||
public SlateRef<Thing> itemToRecover;
|
||||
|
||||
protected override void RunInt()
|
||||
{
|
||||
Slate slate = QuestGen.slate;
|
||||
Map targetMap = map.GetValue(slate);
|
||||
Thing item = itemToRecover.GetValue(slate);
|
||||
|
||||
if (targetMap == null || item == null) return;
|
||||
|
||||
var shuttle = ThingMaker.MakeThing(ThingDefOf.Shuttle) as ThingWithComps;
|
||||
if (shuttle == null) return;
|
||||
|
||||
var comp = shuttle.TryGetComp<CompTransporter>();
|
||||
if (comp != null)
|
||||
{
|
||||
comp.groupID = Find.UniqueIDsManager.GetNextTransporterGroupID();
|
||||
var questComponent = Current.Game.GetComponent<GameComponent_WulaQuests>();
|
||||
questComponent?.RegisterRecoveryQuest(item, comp.groupID);
|
||||
}
|
||||
|
||||
DropCellFinder.TryFindDropSpotNear(targetMap.Center, targetMap, out var spot, allowFogged: false, canRoofPunch: false);
|
||||
DropPodUtility.DropThingsNear(spot, targetMap, new[] { shuttle });
|
||||
}
|
||||
|
||||
protected override bool TestRunInt(Slate slate)
|
||||
{
|
||||
return map.GetValue(slate) != null && itemToRecover.GetValue(slate) != null;
|
||||
}
|
||||
}
|
||||
|
||||
public class QuestNode_AddThingRules : QuestNode
|
||||
{
|
||||
[NoTranslate]
|
||||
public SlateRef<Thing> thing;
|
||||
|
||||
[NoTranslate]
|
||||
public SlateRef<string> prefix;
|
||||
|
||||
protected override void RunInt()
|
||||
{
|
||||
Slate slate = QuestGen.slate;
|
||||
Thing value = thing.GetValue(slate);
|
||||
if (value != null)
|
||||
{
|
||||
var rulePack = new RulePack();
|
||||
rulePack.Rules.Add(new Rule_String(prefix.GetValue(slate) + "_label", value.Label));
|
||||
QuestGen.AddQuestDescriptionRules(rulePack);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool TestRunInt(Slate slate)
|
||||
{
|
||||
return thing.GetValue(slate) != null;
|
||||
}
|
||||
}
|
||||
|
||||
public class QuestNode_SpawnThing_Wula : QuestNode
|
||||
{
|
||||
[NoTranslate]
|
||||
public SlateRef<MapParent> mapParent;
|
||||
[NoTranslate]
|
||||
public SlateRef<Thing> thing;
|
||||
[NoTranslate]
|
||||
public SlateRef<Faction> faction;
|
||||
|
||||
protected override void RunInt()
|
||||
{
|
||||
Slate slate = QuestGen.slate;
|
||||
var part = new QuestPart_SpawnThing();
|
||||
part.mapParent = mapParent.GetValue(slate);
|
||||
part.thing = thing.GetValue(slate);
|
||||
part.factionForFindingSpot = faction.GetValue(slate);
|
||||
part.inSignal = QuestGen.slate.Get<string>("inSignal");
|
||||
QuestGen.quest.AddPart(part);
|
||||
}
|
||||
|
||||
protected override bool TestRunInt(Slate slate)
|
||||
{
|
||||
return mapParent.GetValue(slate) != null && thing.GetValue(slate) != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
70
Source/WulaFallenEmpire/Quests/QuestUtility.cs
Normal file
70
Source/WulaFallenEmpire/Quests/QuestUtility.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WulaFallenEmpire.Quests
|
||||
{
|
||||
public class GameComponent_WulaQuests : GameComponent
|
||||
{
|
||||
// key: 任务物品, value: 对应的回收穿梭机groupID
|
||||
private Dictionary<Thing, int> activeRecoveryQuests = new Dictionary<Thing, int>();
|
||||
|
||||
public GameComponent_WulaQuests(Game game)
|
||||
{
|
||||
}
|
||||
|
||||
public void RegisterRecoveryQuest(Thing item, int shuttleGroupID)
|
||||
{
|
||||
if (!activeRecoveryQuests.ContainsKey(item))
|
||||
{
|
||||
activeRecoveryQuests.Add(item, shuttleGroupID);
|
||||
}
|
||||
}
|
||||
|
||||
public void UnregisterRecoveryQuest(Thing item)
|
||||
{
|
||||
if (activeRecoveryQuests.ContainsKey(item))
|
||||
{
|
||||
activeRecoveryQuests.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
public override void GameComponentTick()
|
||||
{
|
||||
base.GameComponentTick();
|
||||
|
||||
if (Find.TickManager.TicksGame % 60 != 0) return;
|
||||
|
||||
var questsToCheck = new Dictionary<Thing, int>(activeRecoveryQuests);
|
||||
|
||||
foreach (var entry in questsToCheck)
|
||||
{
|
||||
var item = entry.Key;
|
||||
var shuttleGroupID = entry.Value;
|
||||
|
||||
if (item == null || item.Destroyed)
|
||||
{
|
||||
UnregisterRecoveryQuest(item);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.Map != null && item.Map.IsPlayerHome)
|
||||
{
|
||||
Find.SignalManager.SendSignal(new Signal("WulaFallenEmpire.Quest.RecoverItem.ItemRecoveredToHome"));
|
||||
}
|
||||
|
||||
if (item.ParentHolder is CompTransporter transporter && transporter.groupID == shuttleGroupID)
|
||||
{
|
||||
Find.SignalManager.SendSignal(new Signal("WulaFallenEmpire.Quest.RecoverItem.ItemLoadedOnShuttle"));
|
||||
UnregisterRecoveryQuest(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExposeData()
|
||||
{
|
||||
base.ExposeData();
|
||||
Scribe_Collections.Look(ref activeRecoveryQuests, "activeRecoveryQuests", LookMode.Reference, LookMode.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,6 +192,8 @@
|
||||
<Compile Include="Verb\Verb_Excalibur\VerbProperties_Excalibur.cs" />
|
||||
<Compile Include="Verb\Verb_Excalibur\Verb_Excalibur.cs" />
|
||||
<Compile Include="HediffComp\GD3_HediffComp_TopTurret\HediffComp_TopTurret.cs" />
|
||||
<Compile Include="Quests\CustomQuestNodes.cs" />
|
||||
<Compile Include="Quests\QuestUtility.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="WULA_MutiFuelSpawner\CompMultiFuelSpawner.cs" />
|
||||
|
||||
Reference in New Issue
Block a user