private void OnPlayerJoin(IServerPlayer playerJ) { var player = playerJ; var entity = player.Entity; Sapi.Event.RegisterCallback((float dt) => { EntityBehaviorHealth health = (EntityBehaviorHealth)entity.GetBehavior("health"); OnDamagedDelegate previousDelegate = health.onDamaged; health.onDamaged = (float damage, DamageSource source) => { float previousDamage = previousDelegate(damage, source); var allomancy = (EntityBehaviorAllomancy)entity.GetBehavior("allomancy"); return(allomancy.OnDamageAfterArmor(previousDamage, source)); }; }, 100); }
private void OnEntitySpawn(Entity spawnedEntity) { if (spawnedEntity.HasBehavior("health")) { var entity = spawnedEntity; Sapi.Event.RegisterCallback((float dt) => { EntityBehaviorHealth health = (EntityBehaviorHealth)entity.GetBehavior("health"); OnDamagedDelegate previousDelegate = health.onDamaged; health.onDamaged = (float damage, DamageSource source) => { float previousDamage = OnGeneralEntityDamaged(entity, damage, source); return(previousDelegate(previousDamage, source)); }; }, 100); } }