织座特效

This commit is contained in:
2025-10-04 16:27:24 +08:00
parent 8d7541ac85
commit fa3fb2fde9
3 changed files with 34 additions and 22 deletions

Binary file not shown.

View File

@@ -552,7 +552,6 @@
<rechargeHitPointsIntervalTicks>1</rechargeHitPointsIntervalTicks> <rechargeHitPointsIntervalTicks>1</rechargeHitPointsIntervalTicks>
<startWithMaxHitPoints>true</startWithMaxHitPoints> <startWithMaxHitPoints>true</startWithMaxHitPoints>
<alwaysShowHitpointsGizmo>true</alwaysShowHitpointsGizmo> <alwaysShowHitpointsGizmo>true</alwaysShowHitpointsGizmo>
<drawWithNoSelection>true</drawWithNoSelection>
</li> </li>
<li Class="ArachnaeSwarm.CompProperties_Morphable"> <li Class="ArachnaeSwarm.CompProperties_Morphable">
<!-- 休息速度增益例如1.0代表200%的速度 --> <!-- 休息速度增益例如1.0代表200%的速度 -->
@@ -572,7 +571,7 @@
<li>ARA_InsectJelly</li> <li>ARA_InsectJelly</li>
</thingDefs> </thingDefs>
</fuelFilter> </fuelFilter>
<fuelCapacity>2.0</fuelCapacity> <fuelCapacity>5.0</fuelCapacity>
<targetFuelLevelConfigurable>false</targetFuelLevelConfigurable> <targetFuelLevelConfigurable>false</targetFuelLevelConfigurable>
<fuelGizmoLabel>虫蜜</fuelGizmoLabel> <fuelGizmoLabel>虫蜜</fuelGizmoLabel>
<outOfFuelMessage>没有营养</outOfFuelMessage> <outOfFuelMessage>没有营养</outOfFuelMessage>
@@ -687,7 +686,7 @@
</thingDefs> </thingDefs>
</fuelFilter> </fuelFilter>
<targetFuelLevelConfigurable>true</targetFuelLevelConfigurable> <targetFuelLevelConfigurable>false</targetFuelLevelConfigurable>
<showAllowAutoRefuelToggle>true</showAllowAutoRefuelToggle> <showAllowAutoRefuelToggle>true</showAllowAutoRefuelToggle>
<canEjectFuel>true</canEjectFuel> <canEjectFuel>true</canEjectFuel>
</li> </li>

View File

@@ -11,6 +11,7 @@ namespace ArachnaeSwarm
private CompMorphable compMorphable; private CompMorphable compMorphable;
private CompRefuelableNutrition compRefuelable; private CompRefuelableNutrition compRefuelable;
private Effecter researchEffecter; private Effecter researchEffecter;
private Mote psyfocusMote; // For the sustained pulse effect
public float virtualRest; // Public for external access public float virtualRest; // Public for external access
private bool forceSleep; private bool forceSleep;
@@ -37,7 +38,7 @@ namespace ArachnaeSwarm
if (compMorphable?.StoredPawn == null) if (compMorphable?.StoredPawn == null)
{ {
StopResearchEffect(); StopWorkEffects();
return; return;
} }
@@ -87,8 +88,14 @@ namespace ArachnaeSwarm
{ {
// 使用XML中定义的乘数 // 使用XML中定义的乘数
virtualRest = Mathf.Min(VirtualRestMax, virtualRest + (Need_Rest.BaseRestGainPerTick * ((CompProperties_Morphable)compMorphable.props).restGainMultiplier)); virtualRest = Mathf.Min(VirtualRestMax, virtualRest + (Need_Rest.BaseRestGainPerTick * ((CompProperties_Morphable)compMorphable.props).restGainMultiplier));
// --- ADDED: Zzz effect when sleeping ---
if (this.IsHashIntervalTick(120)) // Slightly slower than meditation
{
FleckMaker.ThrowMetaIcon(this.Position, this.Map, FleckDefOf.SleepZ);
} }
StopResearchEffect(); }
StopWorkEffects();
} }
else // 工作或任意时间 (只要不在休息/娱乐,就下降) else // 工作或任意时间 (只要不在休息/娱乐,就下降)
{ {
@@ -105,31 +112,41 @@ namespace ArachnaeSwarm
researchSpeed *= this.GetStatValue(StatDefOf.ResearchSpeedFactor); researchSpeed *= this.GetStatValue(StatDefOf.ResearchSpeedFactor);
Find.ResearchManager.ResearchPerformed(researchSpeed, pawn); Find.ResearchManager.ResearchPerformed(researchSpeed, pawn);
pawn.skills.Learn(SkillDefOf.Intellectual, 0.1f, false); pawn.skills.Learn(SkillDefOf.Intellectual, 0.1f, false);
StartResearchEffect();
}
else
{
StopResearchEffect();
}
}
}
private void StartResearchEffect() // --- Directly replicating the logic of Toil.WithEffect() ---
{
if (researchEffecter == null) if (researchEffecter == null)
{ {
researchEffecter = EffecterDefOf.Research.Spawn(); researchEffecter = EffecterDefOf.Research.Spawn();
} }
researchEffecter.EffectTick(this, TargetInfo.Invalid); researchEffecter.EffectTick(this, this);
// Maintain the other effect as well
if (psyfocusMote == null || psyfocusMote.Destroyed)
{
psyfocusMote = MoteMaker.MakeAttachedOverlay(this, ThingDefOf.Mote_PsyfocusPulse, Vector3.zero);
}
psyfocusMote.Maintain();
}
else
{
StopWorkEffects();
}
}
} }
private void StopResearchEffect() // We no longer need StartWorkEffects, the logic is now directly in Tick()
private void StopWorkEffects()
{ {
if (researchEffecter != null) if (researchEffecter != null)
{ {
researchEffecter.Cleanup(); researchEffecter.Cleanup();
researchEffecter = null; researchEffecter = null;
} }
if (psyfocusMote != null && !psyfocusMote.Destroyed)
{
psyfocusMote.Destroy();
}
psyfocusMote = null;
} }
@@ -251,11 +268,7 @@ namespace ArachnaeSwarm
public override void Destroy(DestroyMode mode) public override void Destroy(DestroyMode mode)
{ {
if (researchEffecter != null) StopWorkEffects();
{
researchEffecter.Cleanup();
researchEffecter = null;
}
if (this.Spawned && compMorphable?.StoredPawn != null) if (this.Spawned && compMorphable?.StoredPawn != null)
{ {