Last active
July 13, 2017 18:36
-
-
Save NiclasOlofsson/61f0caf952447d6f33e4e0d01092d663 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ActionHealthManager : HealthManager | |
{ | |
private readonly Action<Entity> _action; | |
public ActionHealthManager(Entity entity, Action<Entity> action) : base(entity) | |
{ | |
_action = action; | |
} | |
public override void TakeHit(Entity source, int damage = 1, DamageCause cause = DamageCause.Unknown) | |
{ | |
_action?.Invoke(source); | |
} | |
public override void TakeHit(Entity source, Item tool, int damage = 1, DamageCause cause = DamageCause.Unknown) | |
{ | |
_action?.Invoke(source); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Npc : PlayerMob | |
{ | |
private static readonly ILog Log = LogManager.GetLogger(typeof (Npc)); | |
private readonly GameType _gameType; | |
public Npc(string name, Level level, GameManager gameManager, string gameType) : this(name, level, gameManager, (GameType) Enum.Parse(typeof (GameType), gameType, true)) | |
{ | |
} | |
public Npc(string name, Level level, GameManager gameManager, GameType gameType) : base(name, level) | |
{ | |
_gameType = gameType; | |
Skin = new Skin {Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192))}; | |
HealthManager = new ActionHealthManager(this, (source) => | |
{ | |
GamePlayer p = source as GamePlayer; | |
if (p == null) return; | |
p.SendMessage($"§eFinding you a game of §b{gameType}§e..."); | |
Task.Run(() => { gameManager.TransferToGame(p, _gameType); }); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment