Skip to content

Commit

Permalink
resource cleanup standardization
Browse files Browse the repository at this point in the history
Signed-off-by: MGZero <[email protected]>
  • Loading branch information
MGZero committed May 28, 2015
1 parent 2f93859 commit 0cc0099
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 84 deletions.
21 changes: 4 additions & 17 deletions King of Thieves/Actors/NPC/Enemies/ArmoredCrab/CArmoredCrab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class CArmoredCrab : CBaseEnemy
public CArmoredCrab() :
base()
{
if (_armoredCrabCount <= 0)
if (!Graphics.CTextures.rawTextures.ContainsKey(SPRITE_NAMESPACE))
{
Graphics.CTextures.rawTextures.Add(SPRITE_NAMESPACE, CMasterControl.glblContent.Load<Texture2D>(@"sprites/npc/armoredCrabNew"));
Graphics.CTextures.addRawTexture(SPRITE_NAMESPACE, @"sprites/npc/armoredCrabNew");

Graphics.CTextures.addTexture(_IDLE, new Graphics.CTextureAtlas(SPRITE_NAMESPACE, 32, 32, 0, "0:0", "0:0", 0));
Graphics.CTextures.addTexture(_WALK, new Graphics.CTextureAtlas(SPRITE_NAMESPACE, 32, 32, 0, "0:0", "3:0", 10));
Expand Down Expand Up @@ -89,24 +89,11 @@ protected override void _addCollidables()

public override void destroy(object sender)
{
_armoredCrabCount--;

if (_armoredCrabCount <= 0)
{
cleanUp();
_armoredCrabCount = 0;
}

_armoredCrabCount -= 1;
_doNpcCountCheck(ref _armoredCrabCount);
base.destroy(sender);
}

protected override void cleanUp()
{
Graphics.CTextures.cleanUp(SPRITE_NAMESPACE);
_armoredCrabCount = 0;
base.cleanUp();
}

private void _chooseNewPoint()
{
int chooseLeftOrRight = (int)Math.Round(_randNum.NextDouble()); //0 == left, 1 == right
Expand Down
5 changes: 4 additions & 1 deletion King of Thieves/Actors/NPC/Enemies/Chuchus/CBaseChuChu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ public override void update(GameTime gameTime)

public override void destroy(object sender)
{
_chuChuCount -= 1;
_chuChuCount-= 1;
_doNpcCountCheck(ref _chuChuCount);
base.destroy(sender);


}
}
}
2 changes: 1 addition & 1 deletion King of Thieves/Actors/NPC/Enemies/FloorTile/CFloorTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CFloorTile : CBaseEnemy
public CFloorTile() :
base()
{
if (_floorTileCount == 0)
if (!Graphics.CTextures.rawTextures.ContainsKey(_SPRITE_NAMESPACE))
{
Graphics.CTextures.addRawTexture(_SPRITE_NAMESPACE, "sprites/npc/floorTile");

Expand Down
3 changes: 2 additions & 1 deletion King of Thieves/Actors/NPC/Enemies/Keese/CBaseKeese.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public CBaseKeese(int foh, params dropRate[] drops)
_attackVector = new Vector2();
_attacking = false;

if (_keeseCount <= 0)
if (!Graphics.CTextures.rawTextures.ContainsKey(_SPRITE_NAMESPACE))
Graphics.CTextures.addRawTexture(_SPRITE_NAMESPACE, "keese");

_keeseCount += 1;
Expand Down Expand Up @@ -265,6 +265,7 @@ public override void update(Microsoft.Xna.Framework.GameTime gameTime)
public override void destroy(object sender)
{
_keeseCount -= 1;
_doNpcCountCheck(ref _keeseCount);
base.destroy(sender);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ public override void init(string name, Microsoft.Xna.Framework.Vector2 position,
_next = additional[1];
}

protected override void cleanUp()
public override void destroy(object sender)
{
Graphics.CTextures.rawTextures.Remove(_NPC_MOLDORM);
_moldormAndTailCount -= 1;
_doNpcCountCheck(ref _moldormAndTailCount);
base.destroy(sender);
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class COvergrownKeese : CBaseEnemy
public COvergrownKeese() :
base()
{
if (_overgrownKeeseCount <= 0)
if (!Graphics.CTextures.rawTextures.ContainsKey(_SPRITE_NAMESPACE))
{
Graphics.CTextures.addRawTexture(_SPRITE_NAMESPACE, "sprites/npc/overgownKeese");

Expand Down Expand Up @@ -135,22 +135,10 @@ public override void timer0(object sender)

}

protected override void cleanUp()
{
Graphics.CTextures.cleanUp(_SPRITE_NAMESPACE);
base.cleanUp();
}

public override void destroy(object sender)
{
_overgrownKeeseCount--;

if (_overgrownKeeseCount <= 0)
{
cleanUp();
_overgrownKeeseCount = 0;
}

_overgrownKeeseCount -= 1;
_doNpcCountCheck(ref _overgrownKeeseCount);
base.destroy(sender);
}

Expand Down
13 changes: 3 additions & 10 deletions King of Thieves/Actors/NPC/Enemies/Poe/CPoe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CPoe : CBaseEnemy
public CPoe() :
base()
{
if (_poeCount <= 0)
if (!Graphics.CTextures.rawTextures.ContainsKey(_SPRITE_NAMESPACE))
{
Graphics.CTextures.addRawTexture(_SPRITE_NAMESPACE, "sprites/npc/poe");

Expand Down Expand Up @@ -83,16 +83,9 @@ public override void timer1(object sender)

public override void destroy(object sender)
{
_poeCount -= 1;
_doNpcCountCheck(ref _poeCount);
base.destroy(sender);
_poeCount--;

if (_poeCount == 0)
cleanUp();
}

protected override void cleanUp()
{
Graphics.CTextures.cleanUp(_SPRITE_NAMESPACE);
}

private void _selectVelocity()
Expand Down
16 changes: 2 additions & 14 deletions King of Thieves/Actors/NPC/Enemies/Rope/CBaseRope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,10 @@ public override void init(string name, Microsoft.Xna.Framework.Vector2 position,

}

protected override void cleanUp()
{
Graphics.CTextures.cleanUp(_SPRITE_NAMESPACE);
base.cleanUp();
}

public override void destroy(object sender)
{
_ropeCount--;

if (_ropeCount <= 0)
{
cleanUp();
_ropeCount = 0;
}

_ropeCount -= 1;
_doNpcCountCheck(ref _ropeCount);
base.destroy(sender);
}

Expand Down
15 changes: 2 additions & 13 deletions King of Thieves/Actors/NPC/Enemies/Wizzrobe/CBaseWizzrobe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,11 @@ public override void create(object sender)

public override void destroy(object sender)
{
_wizzrobeCount--;

if (_wizzrobeCount <= 0)
{
cleanUp();
_wizzrobeCount = 0;
}

_wizzrobeCount -= 1;
_doNpcCountCheck(ref _wizzrobeCount);
base.destroy(sender);
}

protected override void cleanUp()
{
Graphics.CTextures.rawTextures.Remove(_NPC_WIZZROBE);
}

public override void timer0(object sender)
{
base.timer0(sender);
Expand Down
13 changes: 3 additions & 10 deletions King of Thieves/Actors/NPC/Enemies/Zombie/CBaseZombie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CBaseZombie : CBaseEnemy
public CBaseZombie()
: base()
{
if (_zombieCount <= 0)
if (!Graphics.CTextures.rawTextures.ContainsKey(_SPRITE_NAMESPACE))
Graphics.CTextures.addRawTexture(_SPRITE_NAMESPACE, "sprites/npc/zombie");

_zombieCount += 1;
Expand Down Expand Up @@ -68,18 +68,11 @@ protected void _shootScreech()
Map.CMapManager.addActorToComponent(screecher, this.componentAddress);
}

protected override void cleanUp()
{
if (_zombieCount <= 0)
Graphics.CTextures.cleanUp(_SPRITE_NAMESPACE);
}

public override void destroy(object sender)
{
base.destroy(sender);
_zombieCount -= 1;

cleanUp();
_doNpcCountCheck(ref _zombieCount);
base.destroy(sender);
}

protected override void _addCollidables()
Expand Down

0 comments on commit 0cc0099

Please sign in to comment.