Key refactor. They act as pure "item givers" now.
This commit is contained in:
parent
b19c9aa2d8
commit
312c433ed3
5 changed files with 28 additions and 67 deletions
|
|
@ -10,49 +10,30 @@ Class SWWMKey : Key abstract
|
|||
|
||||
Property GestureWeapon : gesture;
|
||||
|
||||
override void DoEffect()
|
||||
override bool TryPickup( in out Actor toucher )
|
||||
{
|
||||
Super.DoEffect();
|
||||
if ( Icon.IsNull() )
|
||||
{
|
||||
// fetch icon from parent (if it exists)
|
||||
Class<Key> pc = Species;
|
||||
if ( !pc ) return;
|
||||
let p = GetDefaultByType(pc);
|
||||
Icon = p.Icon;
|
||||
}
|
||||
}
|
||||
|
||||
override void AttachToOwner( Actor other )
|
||||
{
|
||||
Super.AttachToOwner(other);
|
||||
// also attach the vanilla key that we replace, mainly for script compatibility
|
||||
// attach the vanilla key that we replace
|
||||
let rt = toucher;
|
||||
if ( toucher.player ) rt = toucher.player.mo;
|
||||
Class<Key> pc = Species;
|
||||
if ( pc )
|
||||
if ( pc && !rt.FindInventory(pc) )
|
||||
{
|
||||
if ( rt.player && !deathmatch && !propagated && CVar.GetCVar('swwm_collectanimkey',rt.player).GetBool() )
|
||||
SWWMGesture.SetSpecialGesture(rt.player.mo,gesture);
|
||||
let p = Inventory(Spawn(pc));
|
||||
if ( Owner is 'Demolitionist' )
|
||||
Demolitionist(Owner).key_reentrant = true; // avoid infinite loop
|
||||
p.AttachToOwner(Owner);
|
||||
if ( Owner is 'Demolitionist' )
|
||||
Demolitionist(Owner).key_reentrant = false;
|
||||
SWWMHandler.KeyTagFix(p);
|
||||
p.AttachToOwner(rt);
|
||||
}
|
||||
}
|
||||
|
||||
override bool Use( bool pickup )
|
||||
{
|
||||
if ( Owner.player && !propagated && !deathmatch && (!pickup || CVar.GetCVar('swwm_collectanimkey',Owner.player).GetBool()) )
|
||||
SWWMGesture.SetSpecialGesture(Owner.player.mo,gesture);
|
||||
// clean up the flag
|
||||
propagated = false;
|
||||
return false;
|
||||
GoAwayAndDie();
|
||||
return true;
|
||||
}
|
||||
|
||||
Default
|
||||
{
|
||||
+NOTDMATCH;
|
||||
+FLOATBOB;
|
||||
+INVENTORY.AUTOACTIVATE;
|
||||
FloatBobStrength 0.25;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue