diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll index 4534f6e..f396c6d 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ diff --git a/1.6/1.6/Defs/ThingDef_Races/ARA_RaceNodeSwarm.xml b/1.6/1.6/Defs/ThingDef_Races/ARA_RaceNodeSwarm.xml index 33e7a9d..838661c 100644 --- a/1.6/1.6/Defs/ThingDef_Races/ARA_RaceNodeSwarm.xml +++ b/1.6/1.6/Defs/ThingDef_Races/ARA_RaceNodeSwarm.xml @@ -1693,7 +1693,7 @@
  • - ArachnaeSwarm/Things/ARA_HiveNode/Addons/ArachnaeNode_Race_Addons_NeuroSwarm + ArachnaeSwarm/Apparel/ARA_Evening_Dress_Hat true false diff --git a/1.6/1.6/Defs/Thing_Misc/ARA_Flyover_Item.xml b/1.6/1.6/Defs/Thing_Misc/ARA_Flyover_Item.xml index 1dd2d27..66ecc78 100644 --- a/1.6/1.6/Defs/Thing_Misc/ARA_Flyover_Item.xml +++ b/1.6/1.6/Defs/Thing_Misc/ARA_Flyover_Item.xml @@ -170,13 +170,13 @@
  • - 60 + 60 虫巢母舰 苍穹之上传来嘶鸣,无数的虫群掠过殖民地,一只庞然大物投下的阴影遮天蔽日——\n\n虫巢母舰,阿拉克涅虫群中最大的节点生物,也是虫群永恒远征的支柱。现在,正有这样的一只骇人之物盘踞在殖民地的上空。它会使用一切手段摧毁你的防御,并投放无穷无尽的虫海淹没你的殖民者,直到其离开殖民地上方轨道。准备好迎接冲击! ThreatBig true true - false + false
  • @@ -244,16 +244,16 @@ 60 3 0.1 - + ARA_HiveShip_Fire_Incoming - + Skyfaller_Crashing Explosion_Bomb - + true true 10 - + false 战舰炮击警告 一艘敌方战舰正在对殖民地进行炮击!立即寻找掩护! @@ -262,39 +262,39 @@
  • ARA_HiveCorvette_Fake - + - 250 + 250 30 1 - + 0 100 5 true - 10 - 70 - + 10 + 70 + - 20 - 10 + 20 + 10 false - + true false true - + true - + 0.3 1.2 - + true @@ -307,39 +307,39 @@
  • ARA_HiveShip_Fake - + - 3000 + 3000 3 1 - + 20 380 5 true - 25 - 100 - + 25 + 100 + - 1 - 10 + 1 + 10 false - + true true true - + true - + 0.3 0.5 - + true @@ -350,7 +350,7 @@ 1.3
  • - + ARA_HiveShip_Fake @@ -392,37 +392,37 @@
  • ARA_HiveCorvette_Fake - + - 250 + 250 5 1 - + 0 50 5 true - + - 20 - 10 + 20 + 10 false - + true false true - + true - + 0.3 1.2 - + true @@ -433,7 +433,7 @@ 1.3
  • -
    + ARA_HiveCorvette_Fake @@ -519,14 +519,14 @@
  • Proj_ARA_HiveCorvette 50 - + 13 0 0 0 Alternating - + 13 13 @@ -539,19 +539,19 @@
  • Bullet_ARA_HiveCorvette - 30 - 50 - 3 - 0.3 - 24 - + 30 + 50 + 3 + 0.3 + 24 + 13 0 0 0 Alternating - + 13 13 @@ -607,14 +607,14 @@
  • Projectile_CatastropheMissile 50 - + 13 0 0 0 Alternating - + 13 13 @@ -668,16 +668,16 @@ MetaOverlays
  • - Bullet_ARA_RW_Acid_Mortar + Bullet_ARA_Acid_Bombardment 15 - + 11 0 0 0 Alternating - + 11 3 @@ -690,19 +690,19 @@
  • Bullet_ARA_HiveCorvette - 60 - 50 - 1 - 0.5 - -1 - + 60 + 50 + 1 + 0.5 + -1 + 13 0 0 0 Alternating - + 13 13 @@ -715,6 +715,43 @@
  • + + Bullet_ARA_Acid_Bombardment + + + Graphic_Single_AgeSecs + Things/Projectile/FleshmassSpitterProjectileSheet + (.75, .75) + MoteGlow + + 0.8 + Projectile_Explosive + + True + 1 + ARA_AcidBurn + 15 + 10 + 30 + 1 + 3.5 + true + ThumpCannon_Impact + ARA_Filth_SpentAcid + 2 + Shell_AcidSpitImpact + 60 + false + + +
  • + Shell_AcidSpitStream +
  • +
  • + Shell_AcidSpitLaunched +
  • +
    +
    ARA_HiveCorvette_Strike @@ -757,19 +794,19 @@
  • Bullet_ARA_HiveCorvette - 30 - 50 - 10 - 0.5 - -1 - + 30 + 50 + 10 + 0.5 + -1 + 13 0 0 0 Alternating - + 13 13 diff --git a/1.6/1.6/Defs/Thing_Misc/Apparels/ARA_Apparel.xml b/1.6/1.6/Defs/Thing_Misc/Apparels/ARA_Apparel.xml index 3d8a328..2f9bf5d 100644 --- a/1.6/1.6/Defs/Thing_Misc/Apparels/ARA_Apparel.xml +++ b/1.6/1.6/Defs/Thing_Misc/Apparels/ARA_Apparel.xml @@ -696,6 +696,83 @@ + + ARA_Eveningdress + + 阿拉克涅督虫们所着织物中的一种,高贵又富有魅力,蕴含着强大的灵能力量,这件织物能够增幅穿着者的灵能力量。 + + ARA_Cocoon_Cloth_1Stage + ARA_TerrainHeal_Ability + + + + ARA_Technology_5DIL + UnfinishedArmor + + + 25 + + + 50 + 3 + + + ArachnaeSwarm/Apparel/ARA_Evening_Dress_Thin_south + + + +
  • Torso
  • +
  • Shoulders
  • +
  • Arms
  • +
  • Legs
  • + + + +
  • Middle
  • +
    + ArachnaeSwarm/Apparel/ARA_Evening_Dress + + + + 0 + +
  • + +
  • ARA_Cocoon_Cloth_1Stage
  • +
  • ARA_Cocoon_Cloth_1Stage_From_Death
  • +
  • ARA_BioforgeIncubator_Thing
  • + + +
  • + + + 3 + 1000 + 2800 + + + true + false + true + + + (0.5, 0.3, 0.9, 0.5) + Interceptor_BlockedProjectile + Shield_Break + BulletShieldGenerator_Reactivate + + + true + 0 + + + 1 + +
  • +
    + +
    + ARA_Shield diff --git a/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Hat_east.png b/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Hat_east.png new file mode 100644 index 0000000..18a04e6 Binary files /dev/null and b/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Hat_east.png differ diff --git a/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Hat_nouth.png b/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Hat_nouth.png new file mode 100644 index 0000000..15b92b5 Binary files /dev/null and b/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Hat_nouth.png differ diff --git a/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Hat_south.png b/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Hat_south.png new file mode 100644 index 0000000..8d7b00a Binary files /dev/null and b/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Hat_south.png differ diff --git a/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Thin_east.png b/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Thin_east.png new file mode 100644 index 0000000..bf5b2fc Binary files /dev/null and b/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Thin_east.png differ diff --git a/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Thin_nouth.png b/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Thin_nouth.png new file mode 100644 index 0000000..e52147d Binary files /dev/null and b/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Thin_nouth.png differ diff --git a/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Thin_south.png b/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Thin_south.png new file mode 100644 index 0000000..6654aaa Binary files /dev/null and b/Content/Textures/ArachnaeSwarm/Apparel/ARA_Evening_Dress_Thin_south.png differ diff --git a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj index d038e60..21dac4b 100644 --- a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj +++ b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj @@ -258,6 +258,7 @@ + diff --git a/Source/ArachnaeSwarm/Thing_Comps/CompApparelInterceptor.cs b/Source/ArachnaeSwarm/Thing_Comps/CompApparelInterceptor.cs new file mode 100644 index 0000000..cc974d4 --- /dev/null +++ b/Source/ArachnaeSwarm/Thing_Comps/CompApparelInterceptor.cs @@ -0,0 +1,357 @@ +using HarmonyLib; +using RimWorld; +using System; +using System.Collections.Generic; +using System.Text; +using UnityEngine; +using Verse; +using Verse.Sound; + +namespace ArachnaeSwarm +{ + public class CompProperties_ApparelInterceptor : CompProperties + { + public float radius = 3f; + public int startupDelay = 0; + public int rechargeDelay = 3200; + public int hitPoints = 100; + + public bool interceptGroundProjectiles = false; + public bool interceptNonHostileProjectiles = false; + public bool interceptAirProjectiles = true; + + public EffecterDef soundInterceptEffecter; + public EffecterDef soundBreakEffecter; + public EffecterDef reactivateEffect; + + public Color color = new Color(0.5f, 0.5f, 0.9f); + public bool drawWithNoSelection = true; + public bool isImmuneToEMP = false; + + public int cooldownTicks = 0; + public int chargeDurationTicks = 0; + public int chargeIntervalTicks = 0; + public bool startWithMaxHitPoints = true; + public bool hitPointsRestoreInstantlyAfterCharge = true; + public int rechargeHitPointsIntervalTicks = 60; + public bool activated = false; + public int activeDuration = 0; + public SoundDef activeSound; + public bool alwaysShowHitpointsGizmo = false; + public float minAlpha = 0f; + public float idlePulseSpeed = 0.02f; + public float minIdleAlpha = 0.05f; + public int disarmedByEmpForTicks = 0; + + public CompProperties_ApparelInterceptor() + { + compClass = typeof(CompApparelInterceptor); + } + } + + [StaticConstructorOnStartup] + public class CompApparelInterceptor : ThingComp + { + // 状态变量 + private int lastInterceptTicks = -999999; + private int startedChargingTick = -1; + private bool shutDown; + private StunHandler stunner; + private Sustainer sustainer; + public int currentHitPoints = -1; + private int ticksToReset; + private int activatedTick = -999999; + + // 视觉效果变量 + private float lastInterceptAngle; + private bool drawInterceptCone; + + // 静态资源 + private static readonly Material ForceFieldMat = MaterialPool.MatFrom("Other/ForceField", ShaderDatabase.MoteGlow); + private static readonly Material ForceFieldConeMat = MaterialPool.MatFrom("Other/ForceFieldCone", ShaderDatabase.MoteGlow); + private static readonly MaterialPropertyBlock MatPropertyBlock = new MaterialPropertyBlock(); + private static readonly Color InactiveColor = new Color(0.2f, 0.2f, 0.2f); + + // 属性 + public CompProperties_ApparelInterceptor Props => (CompProperties_ApparelInterceptor)props; + private Pawn PawnOwner => (parent as Apparel)?.Wearer; + + public bool Active + { + get + { + if (PawnOwner == null || !PawnOwner.Spawned) return false; + if (OnCooldown || Charging || stunner.Stunned || shutDown || currentHitPoints <= 0) return false; + if (Props.activated && Find.TickManager.TicksGame > activatedTick + Props.activeDuration) return false; + return true; + } + } + + protected bool ShouldDisplay + { + get + { + if (PawnOwner == null || !PawnOwner.Spawned || PawnOwner.Dead || PawnOwner.Downed || !Active) + { + return false; + } + if (PawnOwner.Drafted || PawnOwner.InAggroMentalState || (PawnOwner.Faction != null && PawnOwner.Faction.HostileTo(Faction.OfPlayer) && !PawnOwner.IsPrisoner)) + { + return true; + } + if (Find.Selector.IsSelected(PawnOwner)) + { + return true; + } + return false; + } + } + + public bool OnCooldown => ticksToReset > 0; + public bool Charging => startedChargingTick >= 0 && Find.TickManager.TicksGame < startedChargingTick + Props.startupDelay; + public int CooldownTicksLeft => ticksToReset; + public int ChargingTicksLeft => (startedChargingTick < 0) ? 0 : Mathf.Max(startedChargingTick + Props.startupDelay - Find.TickManager.TicksGame, 0); + public int HitPointsMax => Props.hitPoints; + protected virtual int HitPointsPerInterval => 1; + + public override void PostPostMake() + { + base.PostPostMake(); + stunner = new StunHandler(parent); + if (Props.startupDelay > 0) + { + startedChargingTick = Find.TickManager.TicksGame; + currentHitPoints = 0; + } + else + { + currentHitPoints = HitPointsMax; + } + } + + public override void PostExposeData() + { + base.PostExposeData(); + Scribe_Values.Look(ref lastInterceptTicks, "lastInterceptTicks", -999999); + Scribe_Values.Look(ref shutDown, "shutDown", defaultValue: false); + Scribe_Values.Look(ref startedChargingTick, "startedChargingTick", -1); + Scribe_Values.Look(ref currentHitPoints, "currentHitPoints", -1); + Scribe_Values.Look(ref ticksToReset, "ticksToReset", 0); + Scribe_Values.Look(ref activatedTick, "activatedTick", -999999); + Scribe_Deep.Look(ref stunner, "stunner", parent); + + if (Scribe.mode == LoadSaveMode.PostLoadInit) + { + if (stunner == null) stunner = new StunHandler(parent); + if (currentHitPoints == -1) currentHitPoints = HitPointsMax; + } + } + + public bool TryIntercept(Projectile projectile, Vector3 lastExactPos, Vector3 newExactPos) + { + if (PawnOwner == null || !PawnOwner.Spawned || !Active) + { + return false; + } + + if (!GenGeo.IntersectLineCircleOutline(PawnOwner.Position.ToVector2(), Props.radius, lastExactPos.ToVector2(), newExactPos.ToVector2())) + { + return false; + } + + if (!InterceptsProjectile(Props, projectile)) + { + return false; + } + + bool isHostile = (projectile.Launcher != null && projectile.Launcher.HostileTo(PawnOwner)) || (projectile.Launcher == null && Props.interceptNonHostileProjectiles); + if (!isHostile) + { + return false; + } + + // --- Interception Success --- + lastInterceptAngle = projectile.ExactPosition.AngleToFlat(PawnOwner.TrueCenter()); + lastInterceptTicks = Find.TickManager.TicksGame; + drawInterceptCone = true; + if (Props.soundInterceptEffecter != null) Props.soundInterceptEffecter.Spawn(PawnOwner.Position, PawnOwner.Map).Cleanup(); + + if (projectile.DamageDef == DamageDefOf.EMP && !Props.isImmuneToEMP) + { + BreakShieldEmp(new DamageInfo(projectile.DamageDef, projectile.DamageAmount, instigator: projectile.Launcher)); + } + else if (HitPointsMax > 0) + { + currentHitPoints -= projectile.DamageAmount; + if (currentHitPoints <= 0) + { + BreakShieldHitpoints(new DamageInfo(projectile.DamageDef, projectile.DamageAmount, instigator: projectile.Launcher)); + } + } + return true; + } + + public override void CompTick() + { + base.CompTick(); + if (PawnOwner == null || !PawnOwner.Spawned) return; + + stunner.StunHandlerTick(); + + if (OnCooldown) + { + ticksToReset--; + if (ticksToReset <= 0) Reset(); + } + else if (Charging) + { + // Charging logic handled by property + } + else if (currentHitPoints < HitPointsMax && parent.IsHashIntervalTick(Props.rechargeHitPointsIntervalTicks)) + { + currentHitPoints = Mathf.Clamp(currentHitPoints + HitPointsPerInterval, 0, HitPointsMax); + } + + if (Props.activeSound != null) + { + if (Active && (sustainer == null || sustainer.Ended)) sustainer = Props.activeSound.TrySpawnSustainer(SoundInfo.InMap(parent)); + sustainer?.Maintain(); + if (!Active && sustainer != null && !sustainer.Ended) sustainer.End(); + } + } + + public void Reset() + { + if (PawnOwner.Spawned) Props.reactivateEffect?.Spawn(PawnOwner.Position, PawnOwner.Map).Cleanup(); + currentHitPoints = HitPointsMax; + ticksToReset = 0; + } + + private void BreakShieldHitpoints(DamageInfo dinfo) + { + if (PawnOwner.Spawned) + { + if (Props.soundBreakEffecter != null) Props.soundBreakEffecter.SpawnAttached(PawnOwner, PawnOwner.MapHeld, Props.radius).Cleanup(); + } + currentHitPoints = 0; + ticksToReset = Props.rechargeDelay; + } + + private void BreakShieldEmp(DamageInfo dinfo) + { + BreakShieldHitpoints(dinfo); + if (Props.disarmedByEmpForTicks > 0) stunner.Notify_DamageApplied(new DamageInfo(DamageDefOf.EMP, (float)Props.disarmedByEmpForTicks / 30f)); + } + + public static bool InterceptsProjectile(CompProperties_ApparelInterceptor props, Projectile projectile) + { + if (projectile.def.projectile.flyOverhead) return props.interceptAirProjectiles; + return props.interceptGroundProjectiles; + } + + // --- DRAWING LOGIC --- + public override void CompDrawWornExtras() + { + base.CompDrawWornExtras(); + if (PawnOwner == null || !PawnOwner.Spawned || !ShouldDisplay) return; + + Vector3 drawPos = PawnOwner.Drawer.DrawPos; + drawPos.y = AltitudeLayer.MoteOverhead.AltitudeFor(); + + float alpha = GetCurrentAlpha(); + if (alpha > 0f) + { + Color color = Props.color; + color.a *= alpha; + MatPropertyBlock.SetColor(ShaderPropertyIDs.Color, color); + Matrix4x4 matrix = default(Matrix4x4); + matrix.SetTRS(drawPos, Quaternion.identity, new Vector3(Props.radius * 2f * 1.1601562f, 1f, Props.radius * 2f * 1.1601562f)); + Graphics.DrawMesh(MeshPool.plane10, matrix, ForceFieldMat, 0, null, 0, MatPropertyBlock); + } + + float coneAlpha = GetCurrentConeAlpha_RecentlyIntercepted(); + if (coneAlpha > 0f) + { + Color color = Props.color; + color.a *= coneAlpha; + MatPropertyBlock.SetColor(ShaderPropertyIDs.Color, color); + Matrix4x4 matrix = default(Matrix4x4); + matrix.SetTRS(drawPos, Quaternion.Euler(0f, lastInterceptAngle - 90f, 0f), new Vector3(Props.radius * 2f, 1f, Props.radius * 2f)); + Graphics.DrawMesh(MeshPool.plane10, matrix, ForceFieldConeMat, 0, null, 0, MatPropertyBlock); + } + } + + private float GetCurrentAlpha() + { + float idleAlpha = Mathf.Lerp(0.3f, 0.6f, (Mathf.Sin((float)Gen.HashCombineInt(parent.thingIDNumber, 35990913) + Time.realtimeSinceStartup * 2f) + 1f) / 2f); + float interceptAlpha = Mathf.Clamp01(1f - (float)(Find.TickManager.TicksGame - lastInterceptTicks) / 40f); + return Mathf.Max(idleAlpha, interceptAlpha); + } + + private float GetCurrentConeAlpha_RecentlyIntercepted() + { + if (!drawInterceptCone) return 0f; + return Mathf.Clamp01(1f - (float)(Find.TickManager.TicksGame - lastInterceptTicks) / 40f) * 0.82f; + } + + // --- GIZMO --- + public override IEnumerable CompGetWornGizmosExtra() + { + if (PawnOwner != null && Find.Selector.SingleSelectedThing == PawnOwner) + { + yield return new Gizmo_EnergyShieldStatus { shield = this }; + } + } + + public override string CompInspectStringExtra() + { + StringBuilder sb = new StringBuilder(); + if (OnCooldown) + { + sb.Append("Cooldown: " + CooldownTicksLeft.ToStringTicksToPeriod()); + } + else if (stunner.Stunned) + { + sb.Append("EMP Shutdown: " + stunner.StunTicksLeft.ToStringTicksToPeriod()); + } + return sb.ToString(); + } + } + + [StaticConstructorOnStartup] + public class Gizmo_EnergyShieldStatus : Gizmo + { + public CompApparelInterceptor shield; + private static readonly Texture2D FullShieldBarTex = SolidColorMaterials.NewSolidColorMaterial(new Color(0.2f, 0.8f, 0.85f), ShaderDatabase.MetaOverlay).mainTexture as Texture2D; + private static readonly Texture2D EmptyShieldBarTex = SolidColorMaterials.NewSolidColorMaterial(new Color(0.2f, 0.2f, 0.24f), ShaderDatabase.MetaOverlay).mainTexture as Texture2D; + + public override float GetWidth(float maxWidth) => 140f; + + public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth, GizmoRenderParms parms) + { + Rect rect = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f); + Rect rect2 = rect.ContractedBy(6f); + Widgets.DrawWindowBackground(rect); + + Rect labelRect = rect2; + labelRect.height = rect.height / 2f; + Text.Font = GameFont.Tiny; + Widgets.Label(labelRect, shield.parent.LabelCap); + + Rect barRect = rect2; + barRect.yMin = rect2.y + rect2.height / 2f; + float fillPercent = (float)shield.currentHitPoints / shield.HitPointsMax; + Widgets.FillableBar(barRect, fillPercent, FullShieldBarTex, EmptyShieldBarTex, false); + + Text.Font = GameFont.Small; + Text.Anchor = TextAnchor.MiddleCenter; + + TaggedString statusText = shield.OnCooldown ? "Broken".Translate() : new TaggedString(shield.currentHitPoints + " / " + shield.HitPointsMax); + Widgets.Label(barRect, statusText); + + Text.Anchor = TextAnchor.UpperLeft; + + return new GizmoResult(GizmoState.Clear); + } + } +}