public static DamageType GetDamageType(this DamageHandlerBase handler) { if (handler == null) { return(DamageType.Unknown); } if (Enum.TryParse <DamageType>(handler.GetType().Name.Replace("DamageHandler", ""), out var type)) { if (type == DamageType.Universal) { var id = (handler as UniversalDamageHandler).TranslationId; if (id < 0 || id > 23) { return(DamageType.Universal); } return((DamageType)id); } return(type); } return(DamageType.Unknown); }
private static bool WriteDamageHandler(NetworkWriter writer, DamageHandlerBase info) { try { if (info?.GetType() == typeof(Turret.SynapseTurretDamageHandler)) { writer?.WriteByte(DamageHandlers.IdsByTypeHash[typeof(CustomReasonDamageHandler).FullName.GetStableHashCode()]); info?.WriteAdditionalData(writer); return(false); } return(true); } catch (Exception ex) { Logger.Get.Error("Synapse-Turret: Failed to write Data of SynapseTurretDamageHandler:\n" + ex); return(true); } }