暂存
This commit is contained in:
Binary file not shown.
@@ -1,13 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
|
||||
<JobDef>
|
||||
<defName>WULA_LoadComponentsToMaintenancePod</defName>
|
||||
<driverClass>WulaFallenEmpire.JobDriver_HaulToMaintenancePod</driverClass>
|
||||
<reportString>正在为维护舱补充修复组件。</reportString>
|
||||
<allowOpportunisticPrefix>true</allowOpportunisticPrefix>
|
||||
</JobDef>
|
||||
|
||||
<JobDef>
|
||||
<defName>WULA_EnterMaintenancePod</defName>
|
||||
<driverClass>WulaFallenEmpire.JobDriver_EnterMaintenancePod</driverClass>
|
||||
|
||||
45
1.6/Defs/Misc/FactionExists_Example.xml
Normal file
45
1.6/Defs/Misc/FactionExists_Example.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
|
||||
<!--
|
||||
这是一个如何使用 Condition_FactionExists 的示例。
|
||||
它定义了一个自定义事件,该事件只有在满足特定条件时才会触发。
|
||||
-->
|
||||
<WulaFallenEmpire.EventDef>
|
||||
<defName>MyCustomEvent_RequiresMechanoids</defName>
|
||||
<label>需要机械族的事件</label>
|
||||
<description>一个只有在机械族存在时才会发生的特殊事件。</description>
|
||||
|
||||
<!-- 在这里放置其他的事件相关属性, 例如事件的触发概率、效果等 -->
|
||||
|
||||
<conditions>
|
||||
<!--
|
||||
这是条件列表。游戏会检查所有这些条件是否都满足。
|
||||
'Class' 属性指定了要使用的 C# 条件类。
|
||||
-->
|
||||
<li Class="WulaFallenEmpire.Condition_FactionExists">
|
||||
<!--
|
||||
这会设置 Condition_FactionExists 类中的 'factionDef' 字段。
|
||||
游戏会检查 defName 为 "Mechanoid" 的派系当前是否存在于世界地图上。
|
||||
-->
|
||||
<factionDef>Mechanoid</factionDef>
|
||||
</li>
|
||||
|
||||
<!-- 您可以在这里添加更多的条件, 例如:
|
||||
<li Class="AnotherCondition">
|
||||
<someValue>123</someValue>
|
||||
</li>
|
||||
-->
|
||||
|
||||
</conditions>
|
||||
|
||||
<!--
|
||||
如果所有条件都满足,事件的效果将在这里定义。
|
||||
<effects>
|
||||
...
|
||||
</effects>
|
||||
-->
|
||||
|
||||
</WulaFallenEmpire.EventDef>
|
||||
|
||||
</Defs>
|
||||
@@ -56,16 +56,26 @@
|
||||
<basePowerConsumption>50</basePowerConsumption> <!-- This is now idle power -->
|
||||
</li>
|
||||
<li Class="CompProperties_Flickable"/>
|
||||
<li Class="CompProperties_Refuelable">
|
||||
<fuelCapacity>50.0</fuelCapacity>
|
||||
<fuelFilter>
|
||||
<thingDefs>
|
||||
<li>ComponentIndustrial</li>
|
||||
</thingDefs>
|
||||
</fuelFilter>
|
||||
<fuelLabel>零部件</fuelLabel>
|
||||
<consumeFuelOnlyWhenUsed>true</consumeFuelOnlyWhenUsed>
|
||||
<showAllowAutoRefuelToggle>true</showAllowAutoRefuelToggle>
|
||||
<targetFuelLevelConfigurable>true</targetFuelLevelConfigurable>
|
||||
</li>
|
||||
<li Class="WulaFallenEmpire.CompProperties_MaintenancePod">
|
||||
<durationTicks>60000</durationTicks> <!-- 1 day -->
|
||||
<powerConsumptionRunning>250</powerConsumptionRunning>
|
||||
<powerConsumptionIdle>5</powerConsumptionIdle>
|
||||
<hediffToRemove>WULA_Maintenance_Neglect</hediffToRemove>
|
||||
<componentDef>ComponentIndustrial</componentDef>
|
||||
<componentCostPerSeverity>5</componentCostPerSeverity> <!-- 5 components per 100% severity -->
|
||||
<baseComponentCost>0</baseComponentCost>
|
||||
<minSeverityToMaintain>0.75</minSeverityToMaintain>
|
||||
<capacity>5</capacity>
|
||||
<hediffSeverityAfterCycle>0.01</hediffSeverityAfterCycle>
|
||||
<enterSound>BiosculpterPod_Enter</enterSound>
|
||||
<exitSound>BiosculpterPod_Exit</exitSound>
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
|
||||
<WorkGiverDef>
|
||||
<defName>WULA_HaulToMaintenancePod</defName>
|
||||
<label>haul to maintenance pod</label>
|
||||
<giverClass>WulaFallenEmpire.WorkGiver_HaulToMaintenancePod</giverClass>
|
||||
<workType>Hauling</workType>
|
||||
<priorityInType>20</priorityInType>
|
||||
<verb>haul</verb>
|
||||
<gerund>hauling</gerund>
|
||||
<requiredCapacities>
|
||||
<li>Manipulation</li>
|
||||
</requiredCapacities>
|
||||
</WorkGiverDef>
|
||||
|
||||
</Defs>
|
||||
@@ -20,11 +20,9 @@ namespace WulaFallenEmpire
|
||||
public float powerConsumptionRunning = 250f;
|
||||
public float powerConsumptionIdle = 50f;
|
||||
public HediffDef hediffToRemove;
|
||||
public ThingDef componentDef;
|
||||
public float componentCostPerSeverity = 1f; // How many components per 1.0 severity
|
||||
public int baseComponentCost = 0; // A flat cost in addition to severity cost
|
||||
public float minSeverityToMaintain = 0.75f; // The hediff severity required to trigger maintenance
|
||||
public int capacity = 50;
|
||||
public float hediffSeverityAfterCycle = 0.01f;
|
||||
|
||||
public CompProperties_MaintenancePod()
|
||||
@@ -34,13 +32,12 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
|
||||
[StaticConstructorOnStartup]
|
||||
public class CompMaintenancePod : ThingComp, IThingHolder, IStoreSettingsParent
|
||||
public class CompMaintenancePod : ThingComp, IThingHolder
|
||||
{
|
||||
// ===================== Fields =====================
|
||||
private ThingOwner innerContainer;
|
||||
private CompPowerTrader powerComp;
|
||||
private StorageSettings allowedComponentSettings;
|
||||
public float storedComponents = 0f;
|
||||
private CompRefuelable refuelableComp;
|
||||
private int ticksRemaining;
|
||||
private MaintenancePodState state = MaintenancePodState.Idle;
|
||||
|
||||
@@ -60,8 +57,6 @@ namespace WulaFallenEmpire
|
||||
return Props.baseComponentCost + (int)(hediff.Severity * Props.componentCostPerSeverity);
|
||||
}
|
||||
|
||||
public bool CanAcceptComponents(int count) => storedComponents + count <= Props.capacity;
|
||||
|
||||
// ===================== Setup =====================
|
||||
public CompMaintenancePod()
|
||||
{
|
||||
@@ -72,28 +67,21 @@ namespace WulaFallenEmpire
|
||||
public override void Initialize(CompProperties props)
|
||||
{
|
||||
base.Initialize(props);
|
||||
allowedComponentSettings = new StorageSettings(this);
|
||||
if (Props.componentDef != null)
|
||||
{
|
||||
allowedComponentSettings.filter = new ThingFilter();
|
||||
allowedComponentSettings.filter.SetAllow(Props.componentDef, true);
|
||||
}
|
||||
}
|
||||
|
||||
public override void PostSpawnSetup(bool respawningAfterLoad)
|
||||
{
|
||||
base.PostSpawnSetup(respawningAfterLoad);
|
||||
powerComp = parent.TryGetComp<CompPowerTrader>();
|
||||
refuelableComp = parent.TryGetComp<CompRefuelable>();
|
||||
}
|
||||
|
||||
public override void PostExposeData()
|
||||
{
|
||||
base.PostExposeData();
|
||||
Scribe_Values.Look(ref state, "state", MaintenancePodState.Idle);
|
||||
Scribe_Values.Look(ref storedComponents, "storedComponents", 0f);
|
||||
Scribe_Values.Look(ref ticksRemaining, "ticksRemaining", 0);
|
||||
Scribe_Deep.Look(ref innerContainer, "innerContainer", this);
|
||||
Scribe_Deep.Look(ref allowedComponentSettings, "allowedComponentSettings", this);
|
||||
}
|
||||
|
||||
// ===================== IThingHolder Implementation =====================
|
||||
@@ -107,12 +95,6 @@ namespace WulaFallenEmpire
|
||||
return innerContainer;
|
||||
}
|
||||
|
||||
// ===================== IStoreSettingsParent Implementation =====================
|
||||
public StorageSettings GetStoreSettings() => allowedComponentSettings;
|
||||
public StorageSettings GetParentStoreSettings() => null; // No parent settings
|
||||
public void Notify_SettingsChanged() { }
|
||||
public bool StorageTabVisible => false; // We show it in the inspect string
|
||||
|
||||
// ===================== Core Logic =====================
|
||||
public override void CompTick()
|
||||
{
|
||||
@@ -142,13 +124,13 @@ namespace WulaFallenEmpire
|
||||
public void StartCycle(Pawn pawn)
|
||||
{
|
||||
float required = RequiredComponents(pawn);
|
||||
if (storedComponents < required)
|
||||
if (refuelableComp.Fuel < required)
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Tried to start maintenance cycle for {pawn.LabelShort} without enough components. This should have been checked earlier.");
|
||||
return;
|
||||
}
|
||||
|
||||
storedComponents -= required;
|
||||
refuelableComp.ConsumeFuel(required);
|
||||
state = MaintenancePodState.Running;
|
||||
ticksRemaining = Props.durationTicks;
|
||||
|
||||
@@ -197,13 +179,6 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
|
||||
|
||||
public void AddComponents(Thing components)
|
||||
{
|
||||
int count = components.stackCount;
|
||||
storedComponents += count;
|
||||
components.Destroy();
|
||||
}
|
||||
|
||||
// ===================== UI & Gizmos =====================
|
||||
public override string CompInspectStringExtra()
|
||||
{
|
||||
@@ -215,8 +190,6 @@ namespace WulaFallenEmpire
|
||||
sb.AppendLine("Contains".Translate() + ": " + Occupant.NameShortColored.Resolve());
|
||||
sb.AppendLine("TimeLeft".Translate() + ": " + ticksRemaining.ToStringTicksToPeriod());
|
||||
}
|
||||
|
||||
sb.AppendLine("WULA_MaintenancePod_StoredComponents".Translate() + ": " + storedComponents.ToString("F0") + " / " + Props.capacity.ToString("F0"));
|
||||
|
||||
if (!PowerOn)
|
||||
{
|
||||
@@ -244,10 +217,10 @@ namespace WulaFallenEmpire
|
||||
if (Props.hediffToRemove != null && p.health.hediffSet.HasHediff(Props.hediffToRemove))
|
||||
{
|
||||
float required = RequiredComponents(p);
|
||||
if (storedComponents >= required)
|
||||
{
|
||||
options.Add(new FloatMenuOption(p.LabelShort, () =>
|
||||
{
|
||||
if (refuelableComp.Fuel >= required)
|
||||
{
|
||||
options.Add(new FloatMenuOption(p.LabelShort, () =>
|
||||
{
|
||||
Job job = JobMaker.MakeJob(JobDefOf_WULA.WULA_EnterMaintenancePod, parent);
|
||||
p.jobs.TryTakeOrderedJob(job, JobTag.Misc);
|
||||
}));
|
||||
|
||||
@@ -151,7 +151,8 @@ namespace WulaFallenEmpire
|
||||
return met;
|
||||
}
|
||||
}
|
||||
public class Condition_FactionExists : Condition
|
||||
|
||||
public class Condition_FactionExists : Condition
|
||||
{
|
||||
public FactionDef factionDef;
|
||||
|
||||
|
||||
@@ -100,7 +100,6 @@
|
||||
<Compile Include="IngestPatch.cs" />
|
||||
<Compile Include="JobDriver_FeedWulaPatient.cs" />
|
||||
<Compile Include="JobDriver_EnterMaintenancePod.cs" />
|
||||
<Compile Include="JobDriver_HaulToMaintenancePod.cs" />
|
||||
<Compile Include="JobDriver_IngestWulaEnergy.cs" />
|
||||
<Compile Include="JobGiver_WulaGetEnergy.cs" />
|
||||
<Compile Include="JobGiver_WulaPackEnergy.cs" />
|
||||
@@ -136,7 +135,6 @@
|
||||
<Compile Include="Verb\Verb_ShootBeamExplosive.cs" />
|
||||
<Compile Include="Verb\VerbPropertiesExplosiveBeam.cs" />
|
||||
<Compile Include="WorkGiver_FeedWulaPatient.cs" />
|
||||
<Compile Include="WorkGiver_HaulToMaintenancePod.cs" />
|
||||
<Compile Include="WorkGiver_Warden_DeliverEnergy.cs" />
|
||||
<Compile Include="WorkGiver_Warden_FeedWula.cs" />
|
||||
<Compile Include="WorkGiverDefExtension_FeedWula.cs" />
|
||||
|
||||
Reference in New Issue
Block a user