-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Destroy cosmetic pawns when items are unequipped #1244
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,7 +259,8 @@ simulated function XComUnitPawn GetCosmeticPawnInternal(out array<PawnInfo> Pawn | |
return PawnStore[StoreIdx].Cosmetics[CosmeticSlot].Pawn; | ||
} | ||
|
||
/// Start issue #1108 - new function to destroy cosmetic pawns. INTERNAL CHL API, not covered by BC policy. | ||
// Start issue #1108 | ||
// Destroy a cosmetic pawn associated with a particular inventory slot on a particular unit, if there is one. | ||
simulated final function bool DestroyCosmeticPawn_CH(int CosmeticSlot, int UnitRef, bool bUsePhotoboothPawns = false) | ||
{ | ||
local int PawnInfoIndex; | ||
|
@@ -290,8 +291,7 @@ simulated final function bool DestroyCosmeticPawn_CH(int CosmeticSlot, int UnitR | |
return false; | ||
} | ||
|
||
// Helper function used by DestroyCosmeticPawn_CH. Also internal only, and not covered by BC policy. | ||
simulated final function bool DestroyCosmeticPawnInternal_CH(out array<PawnInfo> PawnStore, int CosmeticSlot, int StoreIdx) | ||
simulated private function bool DestroyCosmeticPawnInternal_CH(out array<PawnInfo> PawnStore, int CosmeticSlot, int StoreIdx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that's an actual internal CHL API function, but in this case just adding |
||
{ | ||
local bool bSuccess; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8485,9 +8485,6 @@ simulated function bool RemoveItemFromInventory(XComGameState_Item Item, optiona | |
local X2ArmorTemplate ArmorTemplate; | ||
local int RemoveIndex; | ||
|
||
// Variable for Issue #1108 | ||
local UIPawnMgr PawnMgr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you're not gonna be none-checking the UIPawnMgr - and the user has bigger problems then accessed-none log warnings if UIPawnManager is missing - I decided to get rid of the local var for code brevity. |
||
|
||
if (CanRemoveItemFromInventory(Item, ModifyGameState)) | ||
{ | ||
RemoveIndex = InventoryItems.Find('ObjectID', Item.ObjectID); | ||
|
@@ -8512,15 +8509,14 @@ simulated function bool RemoveItemFromInventory(XComGameState_Item Item, optiona | |
{ | ||
`RedScreen("Attempt to remove item" @ Item.GetMyTemplateName() @ "properly may have failed due to OnUnequippedFn -jbouscher @gameplay"); | ||
} | ||
} | ||
} | ||
|
||
/// HL-Docs: ref:Bugfixes; issue:1108 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general we do want to ship most submissions with a HL-Docs entry, one was missing from this PR. |
||
/// If there is a cosmetic pawn associated with the unequipped item item, remove it. | ||
`PRESBASE.GetUIPawnMgr().DestroyCosmeticPawn_CH(Item.InventorySlot, self.ObjectID); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I understand it, there are two main presentation layers, HQPRES for strategy and PRES for tactical. Both of them extend PRESBASE. Using PRESBASE macro will yield you either HQPRES or PRES depending on where you are. Since |
||
|
||
if (RemoveIndex != INDEX_NONE) | ||
{ | ||
// Start Issue #1108 | ||
// Remove Cosmetic Unit when the item is removed, using newly created function in UIPawnMgr. | ||
PawnMgr = `HQPRES.GetUIPawnMgr(); | ||
PawnMgr.DestroyCosmeticPawn_CH(Item.InventorySlot, self.ObjectID); | ||
// End Issue #1108 | ||
InventoryItems.Remove(RemoveIndex, 1); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's preferable to keep comments to the point, just explaining what the function does, giving its history unless it's relevant is unnecessary.
I for one got mislead by "use the new function", which can be interpreted as there's an old version of
DestroyCosmeticPawn()
.I also decided to remove the mention of "internal CHL API", because that would imply we don't want mods using this new function. I don't see any harm in keeping it open, though I confess I can't come up with a potential use case on the spot.