暂存
This commit is contained in:
Binary file not shown.
@@ -52,12 +52,18 @@ namespace ArachnaeSwarm
|
|||||||
public float StructurePointsPercent => StructurePoints / StructurePointsMax;
|
public float StructurePointsPercent => StructurePoints / StructurePointsMax;
|
||||||
|
|
||||||
public Building sourceBuilding;
|
public Building sourceBuilding;
|
||||||
private ThingWithComps originalWeapon;
|
private ThingWithComps originalWeapon; // Still needed to store pawn's original weapon
|
||||||
|
private ThingWithComps currentPowerArmorWeapon; // Track the currently equipped power armor weapon
|
||||||
|
|
||||||
public void SetOriginalWeapon(ThingWithComps weapon)
|
public void SetOriginalWeapon(ThingWithComps weapon)
|
||||||
{
|
{
|
||||||
originalWeapon = weapon;
|
originalWeapon = weapon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetCurrentPowerArmorWeapon(ThingWithComps weapon)
|
||||||
|
{
|
||||||
|
currentPowerArmorWeapon = weapon;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Ticker
|
#region Ticker
|
||||||
@@ -118,6 +124,7 @@ namespace ArachnaeSwarm
|
|||||||
Scribe_Values.Look(ref structurePoints, "structurePoints", -1f);
|
Scribe_Values.Look(ref structurePoints, "structurePoints", -1f);
|
||||||
Scribe_References.Look(ref sourceBuilding, "sourceBuilding");
|
Scribe_References.Look(ref sourceBuilding, "sourceBuilding");
|
||||||
Scribe_References.Look(ref originalWeapon, "originalWeapon");
|
Scribe_References.Look(ref originalWeapon, "originalWeapon");
|
||||||
|
Scribe_References.Look(ref currentPowerArmorWeapon, "currentPowerArmorWeapon"); // Save/load current power armor weapon
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -151,23 +158,39 @@ namespace ArachnaeSwarm
|
|||||||
{
|
{
|
||||||
base.Notify_Unequipped(pawn);
|
base.Notify_Unequipped(pawn);
|
||||||
|
|
||||||
// Handle weapon restoration
|
// Handle power armor weapon destruction and original weapon restoration
|
||||||
if (Ext?.powerArmorWeapon != null && pawn?.equipment != null)
|
if (Ext?.powerArmorWeapon != null)
|
||||||
{
|
{
|
||||||
ThingWithComps primaryWeapon = pawn.equipment.Primary;
|
// Destroy the power armor weapon, wherever it might be.
|
||||||
if (primaryWeapon != null && primaryWeapon.def == Ext.powerArmorWeapon)
|
// We track it with currentPowerArmorWeapon, so we don't rely on pawn.equipment.Primary.
|
||||||
|
if (currentPowerArmorWeapon != null)
|
||||||
{
|
{
|
||||||
// Destroy the power armor's weapon instead of dropping it.
|
if (pawn?.equipment != null && pawn.equipment.Contains(currentPowerArmorWeapon))
|
||||||
pawn.equipment.Remove(primaryWeapon);
|
{
|
||||||
primaryWeapon.Destroy();
|
pawn.equipment.Remove(currentPowerArmorWeapon);
|
||||||
|
}
|
||||||
|
else if (pawn?.inventory?.innerContainer != null && pawn.inventory.innerContainer.Contains(currentPowerArmorWeapon))
|
||||||
|
{
|
||||||
|
pawn.inventory.innerContainer.Remove(currentPowerArmorWeapon);
|
||||||
|
}
|
||||||
|
// If it's on the map, destroy it there.
|
||||||
|
else if (currentPowerArmorWeapon.Spawned)
|
||||||
|
{
|
||||||
|
currentPowerArmorWeapon.DeSpawn();
|
||||||
|
}
|
||||||
|
currentPowerArmorWeapon.Destroy();
|
||||||
|
Log.Message($"[PA_Debug] Notify_Unequipped: Destroyed power armor weapon {currentPowerArmorWeapon.Label}.");
|
||||||
|
currentPowerArmorWeapon = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (originalWeapon != null && pawn?.equipment != null)
|
// Restore original weapon if saved
|
||||||
{
|
if (originalWeapon != null && pawn?.equipment != null)
|
||||||
pawn.equipment.MakeRoomFor(originalWeapon);
|
{
|
||||||
pawn.equipment.AddEquipment(originalWeapon);
|
pawn.equipment.MakeRoomFor(originalWeapon);
|
||||||
originalWeapon = null;
|
pawn.equipment.AddEquipment(originalWeapon);
|
||||||
|
originalWeapon = null;
|
||||||
|
Log.Message($"[PA_Debug] Notify_Unequipped: Restored original weapon {originalWeapon.Label}.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Building building = sourceBuilding;
|
Building building = sourceBuilding;
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ namespace ArachnaeSwarm
|
|||||||
|
|
||||||
actor.equipment.MakeRoomFor(weapon);
|
actor.equipment.MakeRoomFor(weapon);
|
||||||
actor.equipment.AddEquipment(weapon);
|
actor.equipment.AddEquipment(weapon);
|
||||||
// Set the weapon as bonded to the pawn, effectively locking it.
|
// Track the power armor weapon so it can be destroyed later
|
||||||
actor.equipment.bondedWeapon = weapon;
|
apparel.SetCurrentPowerArmorWeapon(weapon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Despawn the building
|
// Despawn the building
|
||||||
|
|||||||
Reference in New Issue
Block a user