Refactor IDevourable to IDevourer, as the interface represents an entity that consumes corpses, and not the entity being consumed.

Refactor PlagueBeast to not require additional API by handling the devour goal increase in the property directly.
This commit is contained in:
mark 2009-10-19 01:00:36 +00:00
parent 5d07b8f64a
commit 5624873cd7
4 changed files with 9 additions and 42 deletions

View file

@ -14,7 +14,7 @@ using Server.Network;
namespace Server.Items
{
public interface IDevourable
public interface IDevourer
{
bool Devour( Corpse corpse );
}
@ -66,7 +66,7 @@ namespace Server.Items
private List<Mobile> m_Aggressors; // Anyone from this list will be able to loot this corpse; we attacked them, or they attacked us when we were freely attackable
private string m_CorpseName; // Value of the CorpseNameAttribute attached to the owner when he died -or- null if the owner had no CorpseNameAttribute; use "the remains of ~name~"
private IDevourable m_Devourer; // The creature that devoured this corpse
private IDevourer m_Devourer; // The creature that devoured this corpse
// For notoriety:
private AccessLevel m_AccessLevel; // Which AccessLevel the owner had when he died
@ -646,10 +646,10 @@ namespace Server.Items
public bool DevourCorpse()
{
if( Devoured || Deleted || m_Killer == null || m_Killer.Deleted || !m_Killer.Alive || !(m_Killer is IDevourable) || m_Owner == null || m_Owner.Deleted )
if( Devoured || Deleted || m_Killer == null || m_Killer.Deleted || !m_Killer.Alive || !(m_Killer is IDevourer) || m_Owner == null || m_Owner.Deleted )
return false;
m_Devourer = (IDevourable)m_Killer; // Set the devourer the killer
m_Devourer = (IDevourer)m_Killer; // Set the devourer the killer
return m_Devourer.Devour( this ); // Devour the corpse if it hasn't
}

View file

@ -955,22 +955,6 @@ namespace Server.Mobiles
base.OnBeforeSpawn( location, m );
}
public virtual void OnBeforeParagonConvert()
{
}
public virtual void OnAfterParagonConvert()
{
}
public virtual void OnBeforeParagonUnConvert()
{
}
public virtual void OnAfterParagonUnConvert()
{
}
public override ApplyPoisonResult ApplyPoison( Mobile from, Poison poison )
{
if ( !Alive || IsDeadPet )

View file

@ -46,8 +46,6 @@ namespace Server.Mobiles
if ( bc.IsParagon )
return;
bc.OnBeforeParagonConvert();
bc.Hue = Hue;
if ( bc.HitsMaxSeed >= 0 )
@ -90,8 +88,6 @@ namespace Server.Mobiles
if( Math.Abs( bc.Karma ) > 32000 )
bc.Karma = 32000 * Math.Sign( bc.Karma );
}
bc.OnAfterParagonConvert();
}
public static void UnConvert( BaseCreature bc )
@ -99,7 +95,6 @@ namespace Server.Mobiles
if ( !bc.IsParagon )
return;
bc.OnBeforeParagonUnConvert();
bc.Hue = 0;
if ( bc.HitsMaxSeed >= 0 )
@ -131,8 +126,6 @@ namespace Server.Mobiles
bc.Fame = (int)( bc.Fame / FameBuff );
if ( bc.Karma != 0 )
bc.Karma = (int)( bc.Karma / KarmaBuff );
bc.OnAfterParagonUnConvert();
}
public static bool CheckConvert( BaseCreature bc )

View file

@ -7,7 +7,7 @@ using Server.Network;
namespace Server.Mobiles
{
[CorpseName( "a plague beast corpse" )]
public class PlagueBeast : BaseCreature, IDevourable
public class PlagueBeast : BaseCreature, IDevourer
{
private int m_DevourTotal;
private int m_DevourGoal;
@ -23,7 +23,7 @@ namespace Server.Mobiles
[CommandProperty( AccessLevel.GameMaster )]
public int DevourGoal
{
get { return m_DevourGoal; }
get { return ( this.Paragon ? m_DevourGoal + 25 : m_DevourGoal ); }
set { m_DevourGoal = value; }
}
@ -72,7 +72,7 @@ namespace Server.Mobiles
PackItem( Engines.Plants.Seed.RandomPeculiarSeed(4) );
m_DevourTotal = 0;
m_DevourGoal = Utility.RandomMinMax( 15, 25 ); // The goal amount of how many corpses must devour before metal chest is rewarded
m_DevourGoal = Utility.RandomMinMax( 15, 25 ); // How many corpses must be devoured before a metal chest is awarded
}
public override void GenerateLoot()
@ -82,16 +82,6 @@ namespace Server.Mobiles
// TODO: dungeon chest, healthy gland
}
public override void OnAfterParagonConvert()
{
m_DevourGoal += 25;
}
public override void OnAfterParagonUnConvert()
{
m_DevourGoal -= 25;
}
public override void OnGaveMeleeAttack( Mobile defender )
{
base.OnGaveMeleeAttack( defender );
@ -211,7 +201,7 @@ namespace Server.Mobiles
eable.Free();
}
#region IDevourable Members
#region IDevourer Members
public bool Devour( Corpse corpse )
{
@ -226,7 +216,7 @@ namespace Server.Mobiles
PublicOverheadMessage( MessageType.Emote, 0x3B2, 1053033 ); // * The plague beast absorbs the fleshy remains of the corpse *
if( !m_HasMetalChest && m_DevourTotal >= m_DevourGoal )
if( !m_HasMetalChest && m_DevourTotal >= DevourGoal )
{
PackItem( new MetalChest() );
m_HasMetalChest = true;