diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index 598ad1fe..3a775e30 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/Defs/PawnKinds/PawnKinds_Wula.xml b/1.6/1.6/Defs/PawnKinds/PawnKinds_Wula.xml index 118907d1..6f810275 100644 --- a/1.6/1.6/Defs/PawnKinds/PawnKinds_Wula.xml +++ b/1.6/1.6/Defs/PawnKinds/PawnKinds_Wula.xml @@ -196,6 +196,32 @@ + + WULA_Mobile_Bunker + + WULA_Mobile_Bunker + false + PlayerColony + false + 200 + + +
  • + + Wula/Things/WULA_Mobile_Bunker/Bodies/Naked_Thin + Wula/Things/WULA_Cat/AllegianceOverlays/None + CutoutWithOverlay + Graphic_Multi + 3.8 + + (1.4, 1.8, 1.4) + + +
  • +
    + + 0.7 +
    Wula_Mech_Mobile_Factory @@ -593,7 +619,7 @@ Wula_PIA_Legion_Escort_Unit - + WulaSpecies
  • @@ -614,23 +640,24 @@ 500 10~20 10~20 - Poor - Poor - Poor + Legendary + Legendary + Legendary + true + true true + Plasteel -
  • Wula_Armor_Light
  • -
  • Wula_Armor_Shield
  • -
  • WULA_Manpack_Loitering_Munition
  • +
  • Wula_Armor_Super_Heavy
  • -
  • Wula_Melee_Weapon_T2
  • +
  • WULA_MW_Twohanded_ChainBroadsword
  • -
  • WULA_Assault_Troop_PowerArmor
  • -
  • WULA_Assault_Troop_Helmet
  • +
  • WULA_Heavy_Infantry_PowerArmor
  • +
  • WULA_Heavy_Infantry_Helmet
  • - 3000~8000 + 999999~999999 1 1 1 @@ -639,6 +666,10 @@
  • DeathAcidifier
  • + +
  • Advanced
  • +
  • ImplantEmpireCommon
  • +
  • diff --git a/1.6/1.6/Defs/QuestScriptDefs/WULA_Colony_Promotion.xml b/1.6/1.6/Defs/QuestScriptDefs/WULA_Colony_Promotion.xml index d8e78a2e..dd8a8c1b 100644 --- a/1.6/1.6/Defs/QuestScriptDefs/WULA_Colony_Promotion.xml +++ b/1.6/1.6/Defs/QuestScriptDefs/WULA_Colony_Promotion.xml @@ -155,7 +155,7 @@
  • - 2 + 1 Wula_PIA_Legion_Faction Wula_PIA_Legion_Escort_Unit @@ -281,7 +281,7 @@
  • shuttleDelayTicks - 720000 + 360000
  • $shuttleDelayTicks diff --git a/1.6/1.6/Defs/ResearchProjectDefs/WULA_ResearchProjects_Remake.xml b/1.6/1.6/Defs/ResearchProjectDefs/WULA_ResearchProjects_Remake.xml index 140137bb..ec8b13d3 100644 --- a/1.6/1.6/Defs/ResearchProjectDefs/WULA_ResearchProjects_Remake.xml +++ b/1.6/1.6/Defs/ResearchProjectDefs/WULA_ResearchProjects_Remake.xml @@ -201,21 +201,10 @@ 允许殖民地建立信标增加攻击舰队配额,并使得机械乌拉可以调频天线以申请舰队空中支援,包含2艘可以发起轨道炮击的巡洋舰和1艘可以提供航空器支援的航空舰。 600 - 6.00 + 1.00 4.40 -
  • WULA_Colony_License_LV2_Technology
  • - - - - WULA_ConstructionShip_Technology - - 允许殖民地建立信标增加拒止舰队配额,并使得机械乌拉可以调频天线以申请舰队空中支援,包含1艘可以提供轨道支援的拒止舰。 - 600 - 6.00 - 3.80 - -
  • WULA_Colony_License_LV2_Technology
  • +
  • WULA_Colony_License_LV1_Technology
  • diff --git a/1.6/1.6/Defs/Scenarios/Scenarios_WULA.xml b/1.6/1.6/Defs/Scenarios/Scenarios_WULA.xml index 7adc4055..7a23157e 100644 --- a/1.6/1.6/Defs/Scenarios/Scenarios_WULA.xml +++ b/1.6/1.6/Defs/Scenarios/Scenarios_WULA.xml @@ -3,7 +3,7 @@ WULA_Start_Scenario - 乌拉帝国开发署的舰队已经抵达边缘世界,一支负责建立地面前哨站的边境殖民地 + 乌拉帝国开发署的舰队已经抵达边缘世界,一支负责建立地面前哨站的先遣队被部署到星球上。 以三位机械乌拉为初始殖民者开始游戏。 @@ -56,9 +56,20 @@
  • StartingThing_Defined - WULA_RW_Base_AR + WULA_RW_Beam_Base_AR 1
  • +
  • + StartingThing_Defined + WULA_RW_Fractal_RF + 1 +
  • +
  • + StartingThing_Defined + WULA_MW_Charge_Mace + Plasteel + Normal +
  • StartingThing_Defined WULA_MW_Charge_Mace diff --git a/1.6/1.6/Defs/ThingDefs_Buildings/WULA_Turret_Buildings.xml b/1.6/1.6/Defs/ThingDefs_Buildings/WULA_Turret_Buildings.xml index 563153d0..f80e583f 100644 --- a/1.6/1.6/Defs/ThingDefs_Buildings/WULA_Turret_Buildings.xml +++ b/1.6/1.6/Defs/ThingDefs_Buildings/WULA_Turret_Buildings.xml @@ -59,7 +59,7 @@
  • - 21 + 28 (1, 1, 1) 0 true @@ -212,6 +212,14 @@ 6 1.5
  • +
  • + WULA_Mobile_Bunker + 6 + 0 + 转换为BUk-1"地堡猫猫" + 让地堡中的两只乌拉猫猫继续操纵地堡中的机枪,剩下的乌拉猫猫抬着地堡移动——虽然很难相信但是事实就是这样的。 + Wula/UI/Commands/WULA_TransformToPawn +
  • @@ -223,11 +231,10 @@ Graphic_Single - 0.5 - 0.3 - 0.25 - 0.12 - 4.8 + 0.8 + 0.5 + 0.35 + 0.25 0 5 0 @@ -236,14 +243,13 @@
  • Verb_Shoot Bullet_WULA_RW_Base_AR - 0 - 21 - 32 - 2 + 28 + 5 + 12 Shot_AssaultRifle GunTail_Medium 9 - 1 + 4
  • diff --git a/1.6/1.6/Defs/ThingDefs_Misc/WULA_Flyover_Item.xml b/1.6/1.6/Defs/ThingDefs_Misc/WULA_Flyover_Item.xml index 09f248c6..2491615d 100644 --- a/1.6/1.6/Defs/ThingDefs_Misc/WULA_Flyover_Item.xml +++ b/1.6/1.6/Defs/ThingDefs_Misc/WULA_Flyover_Item.xml @@ -1210,9 +1210,9 @@ Bullet_WULA_Striker_A_Missile 60 85 - 2 + 4 0.3 - 24 + 48 13 @@ -1560,7 +1560,7 @@ 4 WULA_Firepower_Minigun_Strafe_Damage - 1 + 2
  • diff --git a/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Machine_Weapon.xml b/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Machine_Weapon.xml index cf383c71..a824124a 100644 --- a/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Machine_Weapon.xml +++ b/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Machine_Weapon.xml @@ -573,7 +573,7 @@ Flame - 20 + 35 60 3.9 1.5 diff --git a/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Manpack_Weapon.xml b/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Manpack_Weapon.xml index 3a03d5b1..363d20cf 100644 --- a/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Manpack_Weapon.xml +++ b/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Manpack_Weapon.xml @@ -299,6 +299,7 @@ 25
  • Wula_Melee_Weapon_T3
  • +
  • WULA_MW_Twohanded_ChainBroadsword
  • 0.8 Spacer @@ -622,24 +623,20 @@
    - + WULA_RW_Base_AR 乌拉帝国的基础突击步枪,仍然使用可靠的导气式结构驱动自动射击构件,是一种便宜但好用的武器,通常派发给殖民地作自卫武器之用。它下挂了一个眩光弹发射器,可以发射一枚眩光弹击晕区域内的敌人。 Normal Spacer + true + None Wula/Weapon/WULA_RW_Base_AR Graphic_Single Interact_Rifle - - -
  • WULA_WeaponArmor_Productor
  • -
    - WULA_Synth_Weapon_1_Base_Technology - UnfinishedWeapon -
    + 1300 @@ -669,7 +666,7 @@ 2 -
  • Wula_Ranged_Weapon_T1
  • +
  • Wula_Assault_Cat_Weapon
  • @@ -685,59 +682,6 @@
  • - - - true - WULA_RW_Base_AR_For_Cat - - 乌拉帝国的基础突击步枪,仍然使用可靠的导气式结构驱动自动射击构件,是一种便宜但好用的武器,通常派发给殖民地作自卫武器之用。 - Normal - Spacer - - Wula/Weapon/WULA_RW_Base_AR - Graphic_Single - - Interact_Rifle - None - - -
  • WULA_WeaponArmor_Productor
  • -
    - WULA_Synth_Weapon_1_Base_Technology - UnfinishedWeapon -
    - - 1300 - - 3.5 - 0.75 - 0.75 - 0.65 - 0.45 - 1.2 - - -
  • - Verb_Shoot - true - Bullet_WULA_RW_Base_AR - 1 - 25 - 5 - 5 - Shot_AssaultRifle - GunTail_Medium - 7 -
  • -
    - - 40 - 2 - - -
  • Wula_Assault_Cat_Weapon
  • -
    -
    Bullet_WULA_RW_Base_AR @@ -806,6 +750,96 @@ 30 + + WULA_RW_Fractal_RF + + 乌拉帝国的磁轨狙击枪,通过引导强大的动能发射钢针,射速较慢,但是在击中目标后仍能继续飞行,对路径上的多个敌人造成伤害。 + Spacer + + Wula/Weapon/WULA_RW_Fractal_RF/WULA_RW_Fractal_RF + Graphic_Single + 1.4 + + + Interact_Rifle + + + +
  • WULA_WeaponArmor_Productor
  • +
    + WULA_Synth_Weapon_1_Base_Technology + UnfinishedWeapon +
    + + 1200 + 3.5 + 0.3 + 0.7 + 1 + 1 + 0.5 + + + 60 + 3 + + +
  • + WulaFallenEmpire.Verb_ShootWithOffset + true + Bullet_WULA_RW_Fractal_RF + 1.25 + 55 + 1 + WULA_RW_Railgun_Shootingsound + GunTail_Medium + 9 +
  • +
    + +
  • Wula_Ranged_Weapon_T1
  • +
    + +
  • + Wula/Weapon/WULA_RW_Fractal_RF/WULA_RW_Fractal_RF_Anim + 8 + 8 +
  • +
    + +
  • + +
  • (0, -1.0)
  • + + +
    +
    + + Bullet_WULA_RW_Fractal_RF + + WulaFallenEmpire.Projectile_WulaLineAttack + +
  • + -1 + 0 + true + WULA_GunTail_Lighting +
  • +
    + + Wula/Projectile/WULA_Bullet_ChargeLanceShot_Red + Graphic_Single + TransparentPostLight + 1.4 + + + Bullet + 25 + 230 + 0.5 + 5 + +
    WULA_RW_StarDrift_SG @@ -892,101 +926,6 @@ - - WULA_RW_Fractal_RF - - 乌拉帝国的磁轨狙击枪,通过引导强大的动能发射钢针,射速较慢,但是在击中目标后仍能继续飞行,对路径上的多个敌人造成伤害。 - Spacer - - Wula/Weapon/WULA_RW_Fractal_RF/WULA_RW_Fractal_RF - Graphic_Single - 1.4 - - - Interact_Rifle - -
  • LongShots
  • -
  • RangedHeavy
  • -
    - - - -
  • WULA_WeaponArmor_Productor
  • -
    - WULA_Synth_Weapon_2_Bullet_Technology - UnfinishedWeapon -
    - - 2000 - 3.5 - 0.3 - 0.7 - 1 - 1 - 0.8 - - - 60 - 4 - 2 - - -
  • - WulaFallenEmpire.Verb_ShootWithOffset - true - Bullet_WULA_RW_Fractal_RF - 4 - 85 - 1 - WULA_RW_Railgun_Shootingsound - GunTail_Medium - 9 -
  • -
    - -
  • Wula_Ranged_Weapon_T2
  • -
    - -
  • - Wula/Weapon/WULA_RW_Fractal_RF/WULA_RW_Fractal_RF_Anim - 8 - 8 -
  • -
    - -
  • - -
  • (0, -1.0)
  • - - -
    -
    - - Bullet_WULA_RW_Fractal_RF - - WulaFallenEmpire.Projectile_WulaLineAttack - -
  • - -1 - 0 - true - WULA_GunTail_Lighting -
  • -
    - - Wula/Projectile/WULA_Bullet_ChargeLanceShot_Red - Graphic_Single - TransparentPostLight - 1.4 - - - Bullet - 25 - 230 - 0.5 - 5 - -
    WULA_RW_AutoCannon @@ -1160,11 +1099,11 @@
  • WULA_WeaponArmor_Productor
  • - WULA_Synth_Weapon_2_Laser_Technology + WULA_Synth_Weapon_1_Base_Technology UnfinishedWeapon - 1500 + 1000 3.5 0.75 @@ -1179,7 +1118,7 @@ true Bullet_WULA_RW_Penetrating_Rifle 3 - 20 + 26 3 12 Shot_BeamRepeater @@ -1191,7 +1130,6 @@ 70 - 6 2 @@ -2048,7 +1986,7 @@ 25 Flame 7 - 20 + 50 0.25 10 @@ -2129,7 +2067,7 @@ 8 -
  • Wula_Ranged_Weapon_T2
  • +
  • Wula_Ranged_Weapon_T1
  • diff --git a/1.6/1.6/Defs/ThingDefs_Races/Races_Wulaspecies.xml b/1.6/1.6/Defs/ThingDefs_Races/Races_Wulaspecies.xml index 5dd19c1e..b256ae65 100644 --- a/1.6/1.6/Defs/ThingDefs_Races/Races_Wulaspecies.xml +++ b/1.6/1.6/Defs/ThingDefs_Races/Races_Wulaspecies.xml @@ -660,6 +660,7 @@ Steel WULA_Machine_Body + 0.9 @@ -885,6 +886,8 @@ 0 + 0.5 + 1.5
  • MechanoidFullyFormed @@ -917,12 +920,20 @@
  • - + Mech_WULA_Cat - 乌拉帝国的一种小型自律机械体,无需监管者,可以执行包括搬运、烹饪、种植收割、清理、急救和灭火一类的简单工作,因为似猫的外形受到乌拉星人欢迎。 + 乌拉帝国的一种小型自律机械体,无需监管者,可以执行包括搬运、烹饪、种植收割、清理、急救和灭火一类的简单工作,因为似猫的外形受到乌拉星人欢迎。\n\n\n这种机械族可以在非征召状态下拾取地上的武器以供使用。 Wula/Things/WULA_Cat/WULA_Cat_Thin_south + + + true + + + false + + 6 0.001 @@ -944,12 +955,21 @@
  • Firefighter
  • -
    - + + Mech_WULA_Cat_Constructor - 乌拉帝国的一种小型自律机械体,无需监管者,只能执行建造和开采任务,可以跳起来用手上的HAm-1"装修锤"锤烂敌人的膝盖。 + 乌拉帝国的一种小型自律机械体,无需监管者,只能执行建造和开采任务,可以跳起来用手上的HAm-1"装修锤"锤烂敌人的膝盖。\n\n\n这种机械族可以在非征召状态下拾取地上的武器以供使用。 Wula/Things/WULA_Constructor_Cat/WULA_Cat_Thin_south + + + + true + + + false + +
  • Mining
  • @@ -959,12 +979,21 @@ 2 -
    - + + Mech_WULA_Cat_Assault - 乌拉帝国的一种小型自律机械体,无需监管者,可以执行搬运、狩猎和割除任务,身着轻甲,装备了一把DLa-1"页岩",可以给敌方造成不小的麻烦。 + 乌拉帝国的一种小型自律机械体,无需监管者,可以执行搬运、狩猎和割除任务,身着轻甲,装备了一把DLa-1"页岩",可以给敌方造成不小的麻烦。\n\n\n这种机械族可以在非征召状态下拾取地上的武器以供使用。 Wula/Things/WULA_Assault_Cat/WULA_Cat_Thin_south + + + + true + + + false + +
  • Hunting
  • @@ -973,19 +1002,157 @@
    - 0.25 - 0.25 + 0.5 + 0.5 4 -
    + - + + WULA_Mobile_Bunker + + 四只猫猫在抬着地堡移动,虽然很难相信但是事实就是这样的。在地堡的射击窗里还有另外的两只乌拉猫猫,它们会操纵地堡的机枪向外射击。\n\n猫猫可以放下地堡,然后一股脑地钻进去,这会让地堡重新变为建筑。 + + + true + true + + + false + + + + 1 + 3 + + + Mech_Warqueen + 5 + +
  • + MechanoidFullyFormed + 0 + Pawn_Wula_Mech_Mobile_Factory_Call +
  • +
    + 2 +
    + +
  • + + +
  • Blunt
  • + + 360 + 8 + Torso + true + +
    + +
  • + 6 + (120,240,252,0) +
  • +
  • + 0 + WULA_Cat_Bunker_TurretGun + + +
  • + PawnRenderNode_TurretGun + PawnRenderNodeWorker_TurretGun + Body + (2, 2) + 20 + Any + + + -90 + (-1, 0, -1.45) + true + -5 + + + 90 + -5 + (3.25, 0, -1) + + + -90 + (1.5, 0, -1.45) + + + 90 + (-3.25, 0, -1) + + +
  • + + +
  • + 1 + WULA_Cat_Bunker_TurretGun + + +
  • + PawnRenderNode_TurretGun + PawnRenderNodeWorker_TurretGun + Body + (2, 2) + 20 + Any + + + -90 + (1, 0, -1.45) + -5 + + + -90 + (3.25, 0, -1) + + + -90 + (-1.6, 0, -1.45) + + + 90 + (-3.25, 0, -1) + -5 + + +
  • + + + +
  • + WULA_Cat_Bunker + 部署为乌拉猫猫地堡 + 乌拉猫猫们把地堡扔在地上然后钻进去,重新转变为建筑。每一次转变为建筑后,都会有24小时的冷却时间,在此期间不允许重新变为BUk-1"地堡猫猫"。 + Wula/UI/Commands/WULA_TransformToBuilding +
  • +
    +
    + Wula_AI_Heavy_Panzer 乌拉帝国的中型战争机械,以悬浮的方式穿梭于战场之上,使用破坏力巨大的自动炮和车体臼炮打击敌方,是乌拉帝国前锋部队的中流砥柱。 Wula/Things/Wula_AI_Heavy_Panzer/Wula_AI_Heavy_Panzer_Icon + + + +
  • Wula_AI_Heavy_Panzer_Main_Weapon
  • +
    + true + true +
    + + false + +
    1 2 @@ -1001,8 +1168,8 @@ 2 - Mech_Warqueen - 30 + WULA_AI_Heavy_Panzer_Body + 20
  • MechanoidFullyFormed @@ -1015,7 +1182,7 @@ 1 - +
  • @@ -1093,12 +1260,24 @@ Wula/UI/Commands/Wula_Mech_Mobile_Factory_AreaDamage
  • -
    - + + Wula_AI_Rocket_Panzer 乌拉帝国的中型战争机械,以悬浮的方式穿梭于战场之上,拥有车体臼炮和两具可以发射大量燃烧火箭弹的转轮导弹巢,但是未像其姊妹型号那样装备护盾。 Wula/Things/Wula_AI_Heavy_Panzer/Wula_AI_Rocket_Panzer_Icon + + + +
  • Wula_AI_Heavy_Panzer_Main_Weapon
  • +
    + true + true +
    + + false + +
    1 2 @@ -1114,8 +1293,8 @@ 2 - Mech_Warqueen - 30 + WULA_AI_Heavy_Panzer_Body + 20
  • MechanoidFullyFormed @@ -1128,7 +1307,7 @@ 1 - +
  • @@ -1198,11 +1377,23 @@ Wula/UI/Commands/Wula_Mech_Mobile_Factory_AreaDamage
  • -
    - + + Wula_Mech_Mobile_Factory 乌拉帝国的大型战争机械,简直就是一座移动堡垒——它不仅装甲厚实、火炮林立,还能在战场上生产大量的辅助战争机械以形成坚实的弹性阵线,生来就是为了粉碎坚固的要塞和顽强的抵抗。 + + + +
  • WULA_RW_Unlimit_Penetrating_Beam_Cannon
  • +
    + true + true +
    + + false + +
    1 1 @@ -1213,7 +1404,7 @@ Mech_Warqueen - 30 + 50
  • MechanoidFullyFormed @@ -1226,7 +1417,7 @@ 1 - +
  • @@ -1509,7 +1700,7 @@ Wula/UI/Commands/Wula_Mech_Mobile_Factory_AreaDamage
  • -
    + WULA_Mech_Flyer @@ -1602,11 +1793,23 @@ - + Wula_Psi_Titan 由乌拉帝国国教所主持开发的重型灵能机械体,以折跃优雅地穿梭于炮火间,并用强大的护盾抵挡敌方射弹侵袭。该机体的内部镌刻了无数的术式环路,这使其就像一个行走的灵能发射器,可以驱使各种强大的灵能能力。 Wula/Things/Wula_Psi_Titan/Wula_Psi_Titan_Icon + + + +
  • Wula_Psi_Titan_Beam
  • +
    + true + true +
    + + false + +
    1 1 @@ -1620,7 +1823,7 @@ Mech_Warqueen - 30 + 50
  • MechanoidFullyFormed @@ -1633,7 +1836,7 @@ 1 - +
  • @@ -1707,7 +1910,7 @@ Wula/UI/Commands/Wula_Psi_Titan_AreaDamage
  • -
    + diff --git a/Content/Textures/Wula/Things/WULA_Mobile_Bunker/Bodies/Naked_Thin_east.png b/Content/Textures/Wula/Things/WULA_Mobile_Bunker/Bodies/Naked_Thin_east.png new file mode 100644 index 00000000..054c0023 Binary files /dev/null and b/Content/Textures/Wula/Things/WULA_Mobile_Bunker/Bodies/Naked_Thin_east.png differ diff --git a/Content/Textures/Wula/Things/WULA_Mobile_Bunker/Bodies/Naked_Thin_north.png b/Content/Textures/Wula/Things/WULA_Mobile_Bunker/Bodies/Naked_Thin_north.png new file mode 100644 index 00000000..00ec72b0 Binary files /dev/null and b/Content/Textures/Wula/Things/WULA_Mobile_Bunker/Bodies/Naked_Thin_north.png differ diff --git a/Content/Textures/Wula/Things/WULA_Mobile_Bunker/Bodies/Naked_Thin_south.png b/Content/Textures/Wula/Things/WULA_Mobile_Bunker/Bodies/Naked_Thin_south.png new file mode 100644 index 00000000..bd4812ec Binary files /dev/null and b/Content/Textures/Wula/Things/WULA_Mobile_Bunker/Bodies/Naked_Thin_south.png differ diff --git a/Source/WulaFallenEmpire/BuildingComp/WULA_MechanoidRecycler/Building_MechanoidRecycler.cs b/Source/WulaFallenEmpire/BuildingComp/WULA_MechanoidRecycler/Building_MechanoidRecycler.cs index 66a600e2..8471b4fe 100644 --- a/Source/WulaFallenEmpire/BuildingComp/WULA_MechanoidRecycler/Building_MechanoidRecycler.cs +++ b/Source/WulaFallenEmpire/BuildingComp/WULA_MechanoidRecycler/Building_MechanoidRecycler.cs @@ -9,73 +9,29 @@ namespace WulaFallenEmpire { public class Building_MechanoidRecycler : Building { - // 翻译键定义 - public static class TranslationKeys - { - // 消息文本 - public const string NoRecyclableMechanoidsNearby = "WULA_NoRecyclableMechanoidsNearby"; - public const string RecyclerStorageFull = "WULA_RecyclerStorageFull"; - public const string CalledMechanoidsForRecycling = "WULA_CalledMechanoidsForRecycling"; - public const string MechanoidRecycled = "WULA_MechanoidRecycled"; - public const string NoMechanoidsAvailableForConversion = "WULA_NoMechanoidsAvailableForConversion"; - public const string NotEnoughStoredMechanoids = "WULA_NotEnoughStoredMechanoids"; - public const string ConvertingMechanoids = "WULA_ConvertingMechanoids"; - - // Gizmo 文本 - public const string RecycleNearbyMechanoids = "WULA_RecycleNearbyMechanoids"; - public const string RecycleNearbyMechanoidsDesc = "WULA_RecycleNearbyMechanoidsDesc"; - public const string RecycleNearbyMechanoidsDisabled = "WULA_RecycleNearbyMechanoidsDisabled"; - public const string ConvertMechanoids = "WULA_ConvertMechanoids"; - public const string ConvertMechanoidsDesc = "WULA_ConvertMechanoidsDesc"; - public const string ConvertMechanoidsDisabled = "WULA_ConvertMechanoidsDisabled"; - - // 检查字符串 - public const string StoredInfo = "WULA_StoredInfo"; - } - public CompProperties_MechanoidRecycler Props => def.GetCompProperties(); - // 存储的机械族列表 - public List storedMechanoids = new List(); + // 改为存储计数而不是Pawn实例 + private int storedMechanoidCount = 0; + private int spawnTick; // 建筑生成的时间点 - // 生成队列 + // 生成队列(存储Pawn生成请求) private Queue spawnQueue = new Queue(); - - // 是否已经生成初始单位 private bool initialUnitsSpawned = false; - public int StoredCount => storedMechanoids.Count; + public int StoredCount => storedMechanoidCount; public int MaxStorage => Props.maxStorageCapacity; + public bool IsCooldownActive => Find.TickManager.TicksGame - spawnTick < 24 * 2500; // 24小时冷却 - - // 生成初始单位 + // 生成初始单位(改为计数) private void SpawnInitialUnits() { - if (initialUnitsSpawned || Props.initialUnits == null || Props.initialUnits.Count == 0) + if (initialUnitsSpawned || Props.initialUnits == null) return; foreach (var initialUnit in Props.initialUnits) { - if (storedMechanoids.Count >= MaxStorage) - break; - - // 生成初始机械族 - PawnGenerationRequest request = new PawnGenerationRequest( - initialUnit.pawnKindDef, - Faction, // 使用当前建筑的派系 - PawnGenerationContext.NonPlayer, - -1, - forceGenerateNewPawn: true, - allowDead: false, - allowDowned: false, - canGeneratePawnRelations: false, - mustBeCapableOfViolence: true - ); - - Pawn initialMech = PawnGenerator.GeneratePawn(request); - storedMechanoids.Add(initialMech); - - Log.Message($"Mechanoid Recycler spawned initial unit: {initialMech.LabelCap} for faction: {Faction.Name}"); + storedMechanoidCount += initialUnit.count; } initialUnitsSpawned = true; @@ -84,118 +40,48 @@ namespace WulaFallenEmpire public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); + spawnTick = Find.TickManager.TicksGame; - // 如果不是从存档加载,生成初始单位 if (!respawningAfterLoad) { SpawnInitialUnits(); } } - // 回收附近机械族 - public void RecycleNearbyMechanoids() + // 回收机械族(改为增加计数) + public void AcceptMechanoid(Pawn mech) { - if (!CanRecycleNow()) - return; - - List nearbyMechs = FindNearbyRecyclableMechanoids(); - - if (nearbyMechs.Count == 0) + if (storedMechanoidCount >= Props.maxStorageCapacity) { - Messages.Message(TranslationKeys.NoRecyclableMechanoidsNearby.Translate(), MessageTypeDefOf.RejectInput); + Messages.Message("回收器已满", MessageTypeDefOf.RejectInput); return; } - int assignedCount = 0; - foreach (Pawn mech in nearbyMechs) - { - if (StartRecycleJob(mech)) - { - assignedCount++; - } - } + storedMechanoidCount++; + mech.Destroy(); // 直接销毁,不存储实例 - Messages.Message(TranslationKeys.CalledMechanoidsForRecycling.Translate(assignedCount), MessageTypeDefOf.PositiveEvent); + Messages.Message($"机械族 {mech.LabelCap} 已回收 (当前: {storedMechanoidCount}/{Props.maxStorageCapacity})", + MessageTypeDefOf.PositiveEvent); + + // 通知转换组件存储更新 + var transformComp = this.TryGetComp(); + transformComp?.NotifyStorageUpdated(); } - private bool CanRecycleNow() + // 消耗机械族计数 + public bool ConsumeMechanoids(int count) { - if (storedMechanoids.Count >= Props.maxStorageCapacity) - { + if (storedMechanoidCount < count) return false; - } + + storedMechanoidCount -= count; return true; } - private List FindNearbyRecyclableMechanoids() + // 设置机械族计数(用于转换恢复) + public void SetMechanoidCount(int count) { - List result = new List(); - CellRect searchRect = CellRect.CenteredOn(Position, Props.recycleRange); - - foreach (Pawn pawn in Map.mapPawns.AllPawnsSpawned) - { - if (searchRect.Contains(pawn.Position) && - IsRecyclableMechanoid(pawn) && - !storedMechanoids.Contains(pawn) && - !IsAlreadyGoingToRecycler(pawn) && // 检查是否已经在前往回收器 - pawn.CanReach(this, PathEndMode.InteractionCell, Danger.Some)) - { - result.Add(pawn); - } - } - - return result; - } - - private bool IsRecyclableMechanoid(Pawn pawn) - { - return pawn.RaceProps.IsMechanoid && - Props.recyclableRaces.Contains(pawn.def) && - !pawn.Downed && - pawn.Faction == Faction; // 使用当前建筑的派系 - } - - // 检查机械族是否已经在前往此回收器 - private bool IsAlreadyGoingToRecycler(Pawn mech) - { - // 检查当前工作是否是前往此回收器 - Job curJob = mech.CurJob; - if (curJob != null && curJob.def == Props.recycleJobDef && curJob.targetA.Thing == this) - return true; - - return false; - } - - private bool StartRecycleJob(Pawn mech) - { - // 防止重复分配 - if (IsAlreadyGoingToRecycler(mech)) - return false; - - Job job = JobMaker.MakeJob(Props.recycleJobDef, this); - if (mech.jobs.TryTakeOrderedJob(job)) - { - return true; - } - return false; - } - - // 机械族进入建筑 - public void AcceptMechanoid(Pawn mech) - { - if (storedMechanoids.Contains(mech)) - return; - - if (storedMechanoids.Count >= Props.maxStorageCapacity) - { - Messages.Message(TranslationKeys.RecyclerStorageFull.Translate(), MessageTypeDefOf.RejectInput); - return; - } - - storedMechanoids.Add(mech); - mech.DeSpawn(); - - Messages.Message(TranslationKeys.MechanoidRecycled.Translate(mech.LabelCap), MessageTypeDefOf.PositiveEvent); + storedMechanoidCount = Mathf.Clamp(count, 0, Props.maxStorageCapacity); } protected override void Tick() @@ -212,9 +98,9 @@ namespace WulaFallenEmpire // 打开生成界面 public void OpenSpawnInterface() { - if (storedMechanoids.Count == 0) + if (storedMechanoidCount == 0) { - Messages.Message(TranslationKeys.NoMechanoidsAvailableForConversion.Translate(), MessageTypeDefOf.RejectInput); + Messages.Message("没有可用的机械族进行转换", MessageTypeDefOf.RejectInput); return; } @@ -223,7 +109,7 @@ namespace WulaFallenEmpire foreach (PawnKindDef kindDef in Props.spawnablePawnKinds) { kindOptions.Add(new FloatMenuOption( - kindDef.LabelCap, + $"{kindDef.LabelCap}", () => TrySpawnMechanoids(kindDef, 1) )); } @@ -233,27 +119,17 @@ namespace WulaFallenEmpire private void TrySpawnMechanoids(PawnKindDef kindDef, int count) { - if (storedMechanoids.Count < count) + if (!ConsumeMechanoids(count)) { - Messages.Message(TranslationKeys.NotEnoughStoredMechanoids.Translate(), MessageTypeDefOf.RejectInput); + Messages.Message("机械族数量不足", MessageTypeDefOf.RejectInput); return; } - // 消耗存储的机械族并生成 for (int i = 0; i < count; i++) { - if (storedMechanoids.Count > 0) - { - Pawn consumedMech = storedMechanoids[0]; - storedMechanoids.RemoveAt(0); - - if (consumedMech.Spawned) - consumedMech.Destroy(); - } - PawnGenerationRequest request = new PawnGenerationRequest( kindDef, - Faction, // 使用当前建筑的派系 + Faction, PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: true, @@ -267,7 +143,7 @@ namespace WulaFallenEmpire } TrySpawnFromQueue(); - Messages.Message(TranslationKeys.ConvertingMechanoids.Translate(count, kindDef.LabelCap), MessageTypeDefOf.PositiveEvent); + Messages.Message($"正在转换 {count} 个机械族为 {kindDef.LabelCap}", MessageTypeDefOf.PositiveEvent); } private void TrySpawnFromQueue() @@ -318,15 +194,15 @@ namespace WulaFallenEmpire // 回收附近机械族按钮 Command_Action recycleCommand = new Command_Action { - defaultLabel = TranslationKeys.RecycleNearbyMechanoids.Translate(), - defaultDesc = TranslationKeys.RecycleNearbyMechanoidsDesc.Translate(Props.recycleRange), + defaultLabel = "回收附近机械族", + defaultDesc = $"命令附近 {Props.recycleRange} 格内的机械族前来回收", icon = ContentFinder.Get("Wula/UI/Commands/WULA_RecycleNearbyMechanoids"), action = RecycleNearbyMechanoids }; - if (!CanRecycleNow()) + if (storedMechanoidCount >= Props.maxStorageCapacity) { - recycleCommand.Disable(TranslationKeys.RecycleNearbyMechanoidsDisabled.Translate()); + recycleCommand.Disable("储存器已满"); } yield return recycleCommand; @@ -334,19 +210,97 @@ namespace WulaFallenEmpire // 生成机械族按钮 Command_Action spawnCommand = new Command_Action { - defaultLabel = TranslationKeys.ConvertMechanoids.Translate(), - defaultDesc = TranslationKeys.ConvertMechanoidsDesc.Translate(storedMechanoids.Count, Props.maxStorageCapacity), + defaultLabel = "转换机械族", + defaultDesc = $"将储存的机械族转换为其他单位 (当前: {storedMechanoidCount}/{Props.maxStorageCapacity})", icon = ContentFinder.Get("Wula/UI/Commands/WULA_ConvertMechanoids"), action = OpenSpawnInterface }; - if (storedMechanoids.Count == 0) + if (storedMechanoidCount == 0) { - spawnCommand.Disable(TranslationKeys.ConvertMechanoidsDisabled.Translate()); + spawnCommand.Disable("没有可用的机械族"); } yield return spawnCommand; } + + // 回收附近机械族 + public void RecycleNearbyMechanoids() + { + if (storedMechanoidCount >= Props.maxStorageCapacity) + { + Messages.Message("储存器已满", MessageTypeDefOf.RejectInput); + return; + } + + List nearbyMechs = FindNearbyRecyclableMechanoids(); + + if (nearbyMechs.Count == 0) + { + Messages.Message("附近没有可回收的机械族", MessageTypeDefOf.RejectInput); + return; + } + + int assignedCount = 0; + foreach (Pawn mech in nearbyMechs) + { + if (StartRecycleJob(mech)) + { + assignedCount++; + } + } + + Messages.Message($"已命令 {assignedCount} 个机械族前来回收", MessageTypeDefOf.PositiveEvent); + } + + private List FindNearbyRecyclableMechanoids() + { + List result = new List(); + CellRect searchRect = CellRect.CenteredOn(Position, Props.recycleRange); + + foreach (Pawn pawn in Map.mapPawns.AllPawnsSpawned) + { + if (searchRect.Contains(pawn.Position) && + IsRecyclableMechanoid(pawn) && + !IsAlreadyGoingToRecycler(pawn) && + pawn.CanReach(this, PathEndMode.InteractionCell, Danger.Some)) + { + result.Add(pawn); + } + } + + return result; + } + + private bool IsRecyclableMechanoid(Pawn pawn) + { + return pawn.RaceProps.IsMechanoid && + Props.recyclableRaces.Contains(pawn.def) && + !pawn.Downed && + pawn.Faction == Faction; + } + + private bool IsAlreadyGoingToRecycler(Pawn mech) + { + Job curJob = mech.CurJob; + if (curJob != null && curJob.def == Props.recycleJobDef && curJob.targetA.Thing == this) + return true; + + return false; + } + + private bool StartRecycleJob(Pawn mech) + { + if (IsAlreadyGoingToRecycler(mech)) + return false; + + Job job = JobMaker.MakeJob(Props.recycleJobDef, this); + if (mech.jobs.TryTakeOrderedJob(job)) + { + return true; + } + return false; + } public override string GetInspectString() { @@ -358,27 +312,39 @@ namespace WulaFallenEmpire stringBuilder.Append(baseString); } - string storedInfo = TranslationKeys.StoredInfo.Translate(storedMechanoids.Count, Props.maxStorageCapacity); + string storedInfo = $"储存机械族: {storedMechanoidCount}/{Props.maxStorageCapacity}"; if (stringBuilder.Length > 0) stringBuilder.AppendLine(); stringBuilder.Append(storedInfo); + + // 显示冷却状态 + if (IsCooldownActive) + { + stringBuilder.AppendLine(); + stringBuilder.Append($"转换冷却: {GetRemainingCooldownHours():F1} 小时"); + } return stringBuilder.ToString(); } + + public float GetRemainingCooldownHours() + { + int remainingTicks = (24 * 2500) - (Find.TickManager.TicksGame - spawnTick); + return Mathf.Max(0, remainingTicks / 2500f); + } public override void ExposeData() { base.ExposeData(); - Scribe_Collections.Look(ref storedMechanoids, "storedMechanoids", LookMode.Reference); - Scribe_Collections.Look(ref spawnQueue, "spawnQueue", LookMode.Deep); + Scribe_Values.Look(ref storedMechanoidCount, "storedMechanoidCount", 0); + Scribe_Values.Look(ref spawnTick, "spawnTick", 0); Scribe_Values.Look(ref initialUnitsSpawned, "initialUnitsSpawned", false); + Scribe_Collections.Look(ref spawnQueue, "spawnQueue", LookMode.Deep); if (Scribe.mode == LoadSaveMode.PostLoadInit) { - storedMechanoids?.RemoveAll(pawn => pawn == null); - if (spawnQueue == null) spawnQueue = new Queue(); } diff --git a/Source/WulaFallenEmpire/BuildingComp/WULA_MechanoidRecycler/CompProperties_MechanoidRecycler.cs b/Source/WulaFallenEmpire/BuildingComp/WULA_MechanoidRecycler/CompProperties_MechanoidRecycler.cs index a68d1682..a6d6b2d9 100644 --- a/Source/WulaFallenEmpire/BuildingComp/WULA_MechanoidRecycler/CompProperties_MechanoidRecycler.cs +++ b/Source/WulaFallenEmpire/BuildingComp/WULA_MechanoidRecycler/CompProperties_MechanoidRecycler.cs @@ -1,42 +1,35 @@ + +// CompProperties_MechanoidRecycler.cs (简化) using System.Collections.Generic; using RimWorld; using Verse; namespace WulaFallenEmpire { - // 初始单位配置类 public class InitialUnitConfig { public PawnKindDef pawnKindDef; public int count = 1; } - + public class CompProperties_MechanoidRecycler : CompProperties { - // 回收相关 public List recyclableRaces = new List(); public int recycleRange = 15; public JobDef recycleJobDef; public int maxStorageCapacity = 5; - - // 生成相关 + public List spawnablePawnKinds = new List(); - - // 初始单位配置 public List initialUnits = new List(); - - // 归属权配置 - public Faction ownershipFaction = null; // 如果为null,则默认使用玩家派系 - + public CompProperties_MechanoidRecycler() { compClass = typeof(CompMechanoidRecycler); } } - - // 空的组件类,用于属性存储 + public class CompMechanoidRecycler : ThingComp { - // 组件逻辑主要在建筑类中实现 + // 空组件,用于属性存储 } } diff --git a/Source/WulaFallenEmpire/BuildingComp/WULA_TransformAtFullCapacity/CompProperties_TransformAtFullCapacity.cs b/Source/WulaFallenEmpire/BuildingComp/WULA_TransformAtFullCapacity/CompProperties_TransformAtFullCapacity.cs new file mode 100644 index 00000000..f0e7039e --- /dev/null +++ b/Source/WulaFallenEmpire/BuildingComp/WULA_TransformAtFullCapacity/CompProperties_TransformAtFullCapacity.cs @@ -0,0 +1,21 @@ +// CompProperties_TransformAtFullCapacity.cs +using RimWorld; +using Verse; + +namespace WulaFallenEmpire +{ + public class CompProperties_TransformAtFullCapacity : CompProperties + { + public PawnKindDef targetPawnKind; + public int requiredCapacity = 5; + + public string gizmoLabel = "转换为机械单位"; + public string gizmoDesc = "将储存的机械族转换为一个强大的机械单位。"; + public string gizmoIconPath; + + public CompProperties_TransformAtFullCapacity() + { + compClass = typeof(CompTransformAtFullCapacity); + } + } +} \ No newline at end of file diff --git a/Source/WulaFallenEmpire/BuildingComp/WULA_TransformAtFullCapacity/CompProperties_TransformIntoBuilding.cs b/Source/WulaFallenEmpire/BuildingComp/WULA_TransformAtFullCapacity/CompProperties_TransformIntoBuilding.cs new file mode 100644 index 00000000..aaa27041 --- /dev/null +++ b/Source/WulaFallenEmpire/BuildingComp/WULA_TransformAtFullCapacity/CompProperties_TransformIntoBuilding.cs @@ -0,0 +1,21 @@ + +// CompProperties_TransformIntoBuilding.cs +using RimWorld; +using Verse; + +namespace WulaFallenEmpire +{ + public class CompProperties_TransformIntoBuilding : CompProperties + { + public ThingDef targetBuildingDef; + + public string gizmoLabel = "部署为建筑"; + public string gizmoDesc = "转换为功能建筑形态。"; + public string gizmoIconPath; + + public CompProperties_TransformIntoBuilding() + { + compClass = typeof(CompTransformIntoBuilding); + } + } +} \ No newline at end of file diff --git a/Source/WulaFallenEmpire/BuildingComp/WULA_TransformAtFullCapacity/CompTransformAtFullCapacity.cs b/Source/WulaFallenEmpire/BuildingComp/WULA_TransformAtFullCapacity/CompTransformAtFullCapacity.cs new file mode 100644 index 00000000..e25dae48 --- /dev/null +++ b/Source/WulaFallenEmpire/BuildingComp/WULA_TransformAtFullCapacity/CompTransformAtFullCapacity.cs @@ -0,0 +1,172 @@ +using RimWorld; +using System.Collections.Generic; +using UnityEngine; +using Verse; + +namespace WulaFallenEmpire +{ + public class CompTransformAtFullCapacity : ThingComp + { + private CompProperties_TransformAtFullCapacity Props => (CompProperties_TransformAtFullCapacity)props; + + // 存储转换前的计数,用于恢复 + private int storedCountAtTransform = 0; + + public Building_MechanoidRecycler Recycler => parent as Building_MechanoidRecycler; + public bool IsCooldownActive => Recycler?.IsCooldownActive ?? false; + public bool IsAtFullCapacity => Recycler?.StoredCount >= Props.requiredCapacity; + + public override void Initialize(CompProperties props) + { + base.Initialize(props); + } + + public override void PostExposeData() + { + base.PostExposeData(); + Scribe_Values.Look(ref storedCountAtTransform, "storedCountAtTransform", 0); + } + + public override IEnumerable CompGetGizmosExtra() + { + if (parent.Faction == Faction.OfPlayer && Recycler != null) + { + Command_Action command = new Command_Action + { + defaultLabel = Props.gizmoLabel, + defaultDesc = GetGizmoDescription(), + icon = GetGizmoIcon(), + action = TransformToPawn + }; + + // 禁用条件 + if (IsCooldownActive) + { + command.Disable($"建筑刚部署,需要等待 {Recycler.GetRemainingCooldownHours():F1} 小时后才能转换"); + } + else if (!IsAtFullCapacity) + { + command.Disable($"需要储存 {Props.requiredCapacity} 个机械族,当前: {Recycler.StoredCount}/{Props.requiredCapacity}"); + } + + yield return command; + } + } + + private string GetGizmoDescription() + { + string desc = Props.gizmoDesc; + if (IsCooldownActive) + { + desc += $"\n\n冷却时间剩余: {Recycler.GetRemainingCooldownHours():F1} 小时"; + } + desc += $"\n目标单位: {Props.targetPawnKind.LabelCap}"; + return desc; + } + + private Texture2D GetGizmoIcon() + { + if (!Props.gizmoIconPath.NullOrEmpty()) + { + return ContentFinder.Get(Props.gizmoIconPath); + } + return TexCommand.ReleaseAnimals; + } + + public void NotifyStorageUpdated() + { + // 当存储更新时,可以触发视觉效果 + if (IsAtFullCapacity && !IsCooldownActive) + { + // 播放满容量提示效果 + //MoteMaker.ThrowLightningGlow(parent.DrawPos, parent.Map, 2f); + } + } + + public void TransformToPawn() + { + if (Recycler == null || !parent.Spawned) + return; + + Map map = parent.Map; + IntVec3 position = parent.Position; + Faction faction = parent.Faction; + + // 存储当前的机械族计数(用于恢复) + storedCountAtTransform = Recycler.StoredCount; + + // 消耗存储的机械族 + if (!Recycler.ConsumeMechanoids(Props.requiredCapacity)) + { + Messages.Message("机械族数量不足", MessageTypeDefOf.RejectInput); + return; + } + + // 生成目标Pawn + PawnGenerationRequest request = new PawnGenerationRequest( + Props.targetPawnKind, + faction, + PawnGenerationContext.NonPlayer, + -1, + forceGenerateNewPawn: true, + allowDead: false, + allowDowned: false, + canGeneratePawnRelations: false, + mustBeCapableOfViolence: true + ); + + Pawn newPawn = PawnGenerator.GeneratePawn(request); + + // 添加转换组件并设置恢复数据 + var transformComp = newPawn.GetComp(); + if (transformComp != null) + { + transformComp.SetRestoreData(parent.def, storedCountAtTransform); + } + else + { + // 动态添加组件 + var compProps = new CompProperties_TransformIntoBuilding + { + targetBuildingDef = parent.def + }; + transformComp = new CompTransformIntoBuilding(); + transformComp.parent = newPawn; + transformComp.props = compProps; + newPawn.AllComps.Add(transformComp); + transformComp.Initialize(compProps); + transformComp.SetRestoreData(parent.def, storedCountAtTransform); + } + + // 移除建筑 + parent.DeSpawn(DestroyMode.Vanish); + + // 生成Pawn + GenSpawn.Spawn(newPawn, position, map, WipeMode.Vanish); + + // 选中新生成的Pawn + if (Find.Selector.IsSelected(parent)) + { + Find.Selector.Select(newPawn); + } + + Messages.Message($"{parent.Label} 已转换为 {newPawn.LabelCap}", MessageTypeDefOf.PositiveEvent); + + // 播放转换效果 + PlayTransformEffects(position, map); + } + + private void PlayTransformEffects(IntVec3 position, Map map) + { + //// 播放转换视觉效果 + //for (int i = 0; i < 3; i++) + //{ + // MoteMaker.ThrowSmoke(position.ToVector3Shifted() + new Vector3(0, 0, 0.5f), map, 1.5f); + // MoteMaker.ThrowLightningGlow(position.ToVector3Shifted(), map, 2f); + //} + + //// 播放音效 + //SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(position, map)); + } + } +} diff --git a/Source/WulaFallenEmpire/BuildingComp/WULA_TransformAtFullCapacity/CompTransformIntoBuilding.cs b/Source/WulaFallenEmpire/BuildingComp/WULA_TransformAtFullCapacity/CompTransformIntoBuilding.cs new file mode 100644 index 00000000..e719840c --- /dev/null +++ b/Source/WulaFallenEmpire/BuildingComp/WULA_TransformAtFullCapacity/CompTransformIntoBuilding.cs @@ -0,0 +1,170 @@ +using RimWorld; +using System.Collections.Generic; +using UnityEngine; +using Verse; + +namespace WulaFallenEmpire +{ + public class CompTransformIntoBuilding : ThingComp + { + private CompProperties_TransformIntoBuilding Props => (CompProperties_TransformIntoBuilding)props; + private Pawn Pawn => (Pawn)parent; + + // 恢复数据 + private ThingDef restoreBuildingDef; + private int restoreMechanoidCount; + + public override void Initialize(CompProperties props) + { + base.Initialize(props); + } + + public override void PostExposeData() + { + base.PostExposeData(); + Scribe_Defs.Look(ref restoreBuildingDef, "restoreBuildingDef"); + Scribe_Values.Look(ref restoreMechanoidCount, "restoreMechanoidCount", 0); + } + + // 设置恢复数据 + public void SetRestoreData(ThingDef buildingDef, int mechanoidCount) + { + restoreBuildingDef = buildingDef; + restoreMechanoidCount = mechanoidCount; + } + + public override IEnumerable CompGetGizmosExtra() + { + if (parent.Faction == Faction.OfPlayer && Pawn != null) + { + Command_Action command = new Command_Action + { + defaultLabel = Props.gizmoLabel, + defaultDesc = GetGizmoDescription(), + icon = GetGizmoIcon(), + action = TransformToBuilding + }; + + // 检查是否可以转换 + if (!CanTransformNow()) + { + command.Disable("无法在当前位置转换"); + } + + yield return command; + } + } + + private string GetGizmoDescription() + { + string desc = Props.gizmoDesc; + if (restoreBuildingDef != null) + { + desc += $"\n\n将恢复为: {restoreBuildingDef.LabelCap}"; + } + return desc; + } + + private Texture2D GetGizmoIcon() + { + if (!Props.gizmoIconPath.NullOrEmpty()) + { + return ContentFinder.Get(Props.gizmoIconPath); + } + return TexCommand.Install; + } + + private bool CanTransformNow() + { + if (parent == null || !parent.Spawned) + return false; + + // 检查空间是否足够 + ThingDef buildingDef = restoreBuildingDef ?? Props.targetBuildingDef; + if (buildingDef == null) + return false; + + foreach (IntVec3 cell in GenAdj.CellsOccupiedBy(Pawn.Position, Rot4.North, buildingDef.Size)) + { + if (!cell.InBounds(Pawn.Map) || !cell.Walkable(Pawn.Map) || cell.GetEdifice(Pawn.Map) != null) + { + return false; + } + } + + return true; + } + + public void TransformToBuilding() + { + if (Pawn == null || !Pawn.Spawned) + return; + + Map map = Pawn.Map; + IntVec3 position = Pawn.Position; + Faction faction = Pawn.Faction; + + // 确定要生成的建筑类型 + ThingDef buildingDef = restoreBuildingDef ?? Props.targetBuildingDef; + if (buildingDef == null) + { + Messages.Message("无法确定目标建筑类型", MessageTypeDefOf.RejectInput); + return; + } + + // 移除Pawn + Pawn.DeSpawn(DestroyMode.Vanish); + + // 生成建筑 + Building newBuilding = (Building)GenSpawn.Spawn(buildingDef, position, map, WipeMode.Vanish); + newBuilding.SetFaction(faction); + + // 恢复机械族计数 + var recycler = newBuilding as Building_MechanoidRecycler; + if (recycler != null && restoreMechanoidCount > 0) + { + recycler.SetMechanoidCount(restoreMechanoidCount); + } + + // 添加建筑转换组件 + var transformComp = newBuilding.TryGetComp(); + if (transformComp == null) + { + // 动态添加组件 + var compProps = new CompProperties_TransformAtFullCapacity + { + targetPawnKind = Pawn.kindDef + }; + transformComp = new CompTransformAtFullCapacity(); + transformComp.parent = newBuilding; + transformComp.props = compProps; + newBuilding.AllComps.Add(transformComp); + transformComp.Initialize(compProps); + } + + // 选中新生成的建筑 + if (Find.Selector.IsSelected(Pawn)) + { + Find.Selector.Select(newBuilding); + } + + Messages.Message($"{Pawn.LabelCap} 已部署为 {newBuilding.Label}", MessageTypeDefOf.PositiveEvent); + + // 播放转换效果 + PlayTransformEffects(position, map); + } + + private void PlayTransformEffects(IntVec3 position, Map map) + { + //// 播放转换视觉效果 + //for (int i = 0; i < 3; i++) + //{ + // MoteMaker.ThrowSmoke(position.ToVector3Shifted() + new Vector3(0, 0, 0.5f), map, 1.5f); + // MoteMaker.ThrowMicroSparks(position.ToVector3Shifted(), map); + //} + + //// 播放音效 + //SoundDefOf.MechClusterDefeated.PlayOneShot(new TargetInfo(position, map)); + } + } +} diff --git a/Source/WulaFallenEmpire/Pawn/WULA_AutonomousMech/CompAutonomousMech.cs b/Source/WulaFallenEmpire/Pawn/WULA_AutonomousMech/CompAutonomousMech.cs index 31ff8394..cc921a5c 100644 --- a/Source/WulaFallenEmpire/Pawn/WULA_AutonomousMech/CompAutonomousMech.cs +++ b/Source/WulaFallenEmpire/Pawn/WULA_AutonomousMech/CompAutonomousMech.cs @@ -208,11 +208,8 @@ namespace WulaFallenEmpire yield return new DroneGizmo(this); } - // 更换武器按钮(仅当有装备武器时显示) - if (MechPawn.equipment?.Primary != null) - { - yield return CreateWeaponSwitchGizmo(); - } + // 更换武器按钮 + yield return CreateWeaponSwitchGizmo(); } /// diff --git a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj index d625f85b..7f738072 100644 --- a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj +++ b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj @@ -122,6 +122,10 @@ + + + +